Skip to content

Refactor logic and fix bugs#4

Merged
mr150 merged 13 commits into
mainfrom
fix/logic
Jan 11, 2026
Merged

Refactor logic and fix bugs#4
mr150 merged 13 commits into
mainfrom
fix/logic

Conversation

@Ramazanmak
Copy link
Copy Markdown
Collaborator

No description provided.

@Ramazanmak Ramazanmak requested a review from mr150 January 2, 2026 18:39
@Ramazanmak Ramazanmak self-assigned this Jan 2, 2026
Comment thread src/assets/data/initial-code.js Outdated

@media (prefers-color-scheme: dark){
html{
*{
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Почему *? Это ухудшает перфоманс

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Я его вместо html поставил, потому что в shadow DOM нет html тега теперь. Но может, стоит просто что-то вроде body поставить по умолчанию, чтобы на него стили повесить, действительно.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Для этого же :root есть

Comment thread src/components/code-editor.js Outdated
_eventBus = new ContextConsumer(this, { context: eventBusContext });
_eventBus = new ContextConsumer(this, {
context: eventBusContext,
callback: (bus) => {
Copy link
Copy Markdown
Contributor

@mr150 mr150 Jan 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Для чего это?

Copy link
Copy Markdown
Collaborator Author

@Ramazanmak Ramazanmak Jan 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Это для того, чтобы не писать везде this._eventBus.value, а писать просто this.eventBus. Просто так напрямую сделать присвоение такого типа:

_eventBus = new ContextConsumer(...).value

не получается - результат будет undefined в том месте, где нам надо. А callback - удобный и простой способ.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(new ContextConsumer(...)).value - тоже не работает?)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Нет, не работает)

export class CodePreview extends LitElement {
	eventBus = (new ContextConsumer(this, { context: eventBusContext })).value;

	async firstUpdated() {
		console.log(this.eventBus)
		...
	}
	...
}

Получается вот это:
image

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тогда надо в конструкторе это по нормальному переписать, чтобы не было бесполезного свойства _eventBus и дублирующего публичного eventBus

Comment thread package.json Outdated
Comment thread src/components/code-preview.js Outdated
Comment thread src/assets/data/initial-code.js Outdated
Comment thread src/components/tab-switch.js Outdated
}
handleChange(event) {
this.checkedLang = event.target.id;
console.log(event.target);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

В итоговом коде логов быть не должно

Comment thread src/components/main-comp.js Outdated
this.unbindLoaderRemover();
}

removeLoader = () => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Этот способ работы с лоадером хуже, чем был ранее с inProgress

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не исправлено

Copy link
Copy Markdown
Contributor

@mr150 mr150 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

!

Comment thread index.html Outdated
Comment thread src/assets/data/initial-code.js Outdated
Comment thread src/assets/style/style.scss
Comment thread src/components/code-preview.js Outdated
Comment thread src/components/code-preview.js Outdated
Comment thread src/components/code-preview.js Outdated
doc.head.innerHTML = `
<style>${styles}</style>
`;
doc.body.innerHTML = `${layout}`;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Почему не класть просто layout? Там же строка

Comment thread src/assets/data/initial-code.js Outdated
Comment thread src/assets/data/initial-code.js Outdated
Comment thread index.html
@Ramazanmak Ramazanmak requested a review from mr150 January 8, 2026 19:34
Comment thread index.html Outdated
"imports": {
"immutable": "https://unpkg.com/immutable@^4.0.0",
"sass": "https://unpkg.com/sass@^1.63.0/sass.default.js",
"@octokit/plugin-retry": "/src/api/github/octokit.js",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

src/api/github - еще хуже, чем первый вариант. Давай его в src/lib/ каталог

Copy link
Copy Markdown
Contributor

@mr150 mr150 Jan 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

И с path надо то же самое проделать. Бандлить пакет path-browserify-esm - забыл про него сразу сказать

Comment thread index.html Outdated
}
}
</script>
<link rel="stylesheet" href="src/assets/style/style.css" />
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Снова некорректный путь до стилей

Comment thread src/assets/data/initial-code.js Outdated
<div class="D-f Fld-r W100p Flw-w Jc-c Gap3u M0;0;5u P0;5u">
</div>
<button class="btn W70p Mxw50u H8u P1u;3u Bdrd1u M0;a;5u Ts-$shortTs Bd1;s;$brand Bgc-$brand Bgc-$brand500_h C#fff">
<span class="D Fns0.9r">
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Зачем эти стили тут и вообще зачем span?

@Ramazanmak Ramazanmak requested a review from mr150 January 9, 2026 03:02
Comment thread index.html Outdated
<div class="H-calc(100%;-;var(--ml-headerH)) W100p Ps-r loader">
<main-comp class="H100p Ps-r ">
<main class="D-f Ai-str H100p Ps-r">
<div class="H-calc(100%;-;var(--ml-headerH)) W100p Ps loader">
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<div class="H-calc(100%;-;var(--ml-headerH)) W100p Ps loader">
<div class="H-calc(100%;-;$headerH) W100p Ps loader">

Comment thread src/assets/data/initial-code.js Outdated

<div class="D-f Fld-r W100p Flw-w Jc-c Gap3u M0;0;5u P0;5u">
</div>
<button class="btn W70p Mxw50u H8u Fns0.9r P1u;3u Bdrd1u Bgc-$brand Bgc-$brand500_h C#fff">
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Уже писал ранее, что фиксированная высота - антипаттерн. И все размеры по дефолту либо в u либо в gg

Comment thread index.html Outdated
"sass": "https://unpkg.com/sass@^1.63.0/sass.default.js",
"@octokit/plugin-retry": "/src/lib/engine-dependencies.js",
"@octokit/rest": "/src/lib/engine-dependencies.js",
"path-browserify-esm": "/src/lib/engine-dependencies.js"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Проверил, там сейчас есть проблемы с этим, так что пока убираем

Comment thread vite.config.js Outdated
const mlut = vite({
input: 'src/assets/style/style.scss',
output: 'dist/assets/style.css',
output: 'assets/style.css',
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
output: 'assets/style.css',
output: 'dist/assets/style.css',

Comment thread src/assets/data/initial-code.js Outdated
</div>
<button class="btn W70p Mxw50u H8u Fns0.9r P1u;3u Bdrd1u Bgc-$brand Bgc-$brand500_h C#fff">
Getting started
</button>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тут еще чуть надо форматирование поправить

@Ramazanmak Ramazanmak requested a review from mr150 January 9, 2026 12:23
Comment thread index.html Outdated
"immutable": "https://unpkg.com/immutable@^4.0.0",
"sass": "https://unpkg.com/sass@^1.63.0/sass.default.js",
"@octokit/plugin-retry": "/src/lib/engine-dependencies.js",
"@octokit/rest": "/src/lib/engine-dependencies.js"
Copy link
Copy Markdown
Contributor

@mr150 mr150 Jan 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

После сборки остаются эти же пути, а не меняются на бандл

Comment thread src/lib/engine-dependencies.entry.js Outdated
@@ -0,0 +1,4 @@
export * from '@octokit/plugin-retry';
export * from '@octokit/rest';
export { immutable } from 'https://unpkg.com/immutable@^4.0.0';
Copy link
Copy Markdown
Contributor

@mr150 mr150 Jan 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А зачем здесь то, что с cdn загружается? Еще и дублируется код из index.html

@Ramazanmak Ramazanmak requested a review from mr150 January 11, 2026 15:06
@mr150 mr150 merged commit c9afc9d into main Jan 11, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants