Skip to content

Frontend mvp#3

Merged
mr150 merged 10 commits into
mainfrom
feat/logic
Dec 29, 2025
Merged

Frontend mvp#3
mr150 merged 10 commits into
mainfrom
feat/logic

Conversation

@Ramazanmak
Copy link
Copy Markdown
Collaborator

No description provided.

@Ramazanmak Ramazanmak requested a review from mr150 December 24, 2025 19:54
@Ramazanmak Ramazanmak self-assigned this Dec 24, 2025
Comment thread index.html Outdated
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>mlut playground</title>
<link rel="stylesheet" href="/src/assets/style/style.css" />
<script type="module" src="/src/components/code-editor.js"></script>
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.

Все скрипты должны быть не в head а в концу body

Comment thread index.html Outdated
</button>
</div>
<!-- HTML part's body-->
<div class="H-calc(100%;-;var(--ml-sectionHeaderH)) Bgc-$core700">
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 package.json Outdated
"thememirror": "^2.0.1"
},
"devDependencies": {
"@codemirror/lang-html": "^6.4.11",
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.

Это не dev зависимость. Хотя если vite в бандл все собирает, то можно и все в dev

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.

Случайно по инерции в dev-зависимости записал :)

Comment thread src/assets/scripts/lit-context.js Outdated
@@ -0,0 +1,189 @@
import {signal} from "@lit-labs/signals"

const layout = signal( `
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.

А почему это выглядит странно? Лучше объявление сигналов сделать в отдельном месте, а данные держать отдельно?

Comment thread src/components/code-editor.js Outdated
import { LitElement, html } from 'lit';
import { watch, SignalWatcher } from '@lit-labs/signals';

// General CodeMirror imports
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.

Зачем эти комменты - все очевидно же. Максимум, можно пустой строкой отделить

}))

export class CodeEditor extends LitElement {

Copy link
Copy Markdown
Contributor

@mr150 mr150 Dec 24, 2025

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
export class MainComp extends LitElement {

createRenderRoot() {
return this.querySelector('main');
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.

Зачем здесь shadow dom?

Comment thread src/components/style-tab.js Outdated
textareas.forEach((el, index) => {
if (el.id === `${this.radioId.toLowerCase()}-area`) {
displayEditor() {
const editors = document.querySelectorAll('div[data-type="style"]');
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
@@ -0,0 +1,52 @@
const initialLayout = `
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
const initialLayout = `
export const initialLayout = `

@@ -0,0 +1,26 @@
export class EventBus {
Copy link
Copy Markdown
Contributor

@mr150 mr150 Dec 28, 2025

Choose a reason for hiding this comment

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

Зачем писать свой с багами, если можно взять готовую либу? Вот эту например, 108 байт весит

Comment thread index.html Outdated
<script type="importmap">
{
"imports": {
"@mlut/core": "../packages/core/dist/index.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 index.html Outdated
}
</script>
<script type="module">
const contentLoader = document.querySelector('.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.

Зачем это отдельным скриптом, да еще и в теге?

Comment thread src/assets/data/initial-code.js Outdated
`
const initialConfig = `
@use "@mlut/core/tools";
@use "@mlut/core/dist/sass/css/styles";
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.

Зачем здесь это? Достаточно @mlut/core импортировать

Comment thread src/assets/data/initial-code.js Outdated
}
}
`
const loaderStyles = `
Copy link
Copy Markdown
Contributor

@mr150 mr150 Dec 28, 2025

Choose a reason for hiding this comment

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

Это зачем?

this.view = new EditorView(this.setEditorOptions(this.lang));

if (this.lang === 'css') {
this._eventBus.value.on('update-css', this.updateCss);
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.value если можно сразу в свойство записать это value?

Comment thread src/components/code-editor.js Outdated
this.timeoutID = setTimeout(() => {

if (this.lang === 'html') {
this._eventBus.value.emit('update-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.

Зачем здесь дублирование кода, если можно было использовать один код с 'update-${this.lang}l'?


static properties = {
lang: { type: String },
timeoutID: { type: Number, state: false },
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.

По названию непонятно, что за timeoutID

Comment thread src/components/code-preview.js Outdated
this._eventBus.value.on('update-sass', this.handleUpdate);
const { jitEngine } = await import('https://unpkg.com/@mlut/core@latest/dist/index.js');
await jitEngine.init(['config.scss', initialConfig]);
jitEngine.putContent('index.html', initialLayout);
Copy link
Copy Markdown
Contributor

@mr150 mr150 Dec 28, 2025

Choose a reason for hiding this comment

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

Зачем здесь отдельно делается putContent, если есть функция для обновления? Тут только инициализация должна быть. Еще и разный путь (название) до файлов

async firstUpdated() {
this._eventBus.value.on('update-html', this.handleUpdate);
this._eventBus.value.on('update-sass', this.handleUpdate);
const { jitEngine } = await import('https://unpkg.com/@mlut/core@latest/dist/index.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.

Почему динамический, а не обычный импорт?

@@ -0,0 +1,16 @@
import { LitElement, html } from 'lit';

export class ContentLoader extends LitElement {
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.

Зачем отдельный компонент для лоадера? Недостаточно 1 css класса?

Comment thread src/components/error-fallback.js Outdated
@@ -0,0 +1,23 @@
import { LitElement, html } from 'lit';

export class ErrorFallback extends LitElement {
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.

Зачем этот компонент? Надо просто 1 абзац стилизованного текста показать, если ошибка


import { EventBus } from '../assets/scripts/event-bus.js';

export const eventBusContext = createContext('eventBus');
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.

Контекст должен в отдельном модуле объявляться. В доке же есть пример


constructor() {
super();
this.cssChecked = 'unchecked';
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/code-editor.js Outdated

render() {
return html`
<div id="${this.lang}-editor" class="H100p Bgc-$core700 Ov-a" style="height: ${this.inProgress ? '0' : '100%'}">
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?

}

return html`
<iframe srcdoc='<!DOCTYPE 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.

Тут что-то странное делается. По идее, надо отправлять в iframe по api. Либо попробуй shadow dom, чтобы такое же простое обновление сохранить

@Ramazanmak Ramazanmak force-pushed the feat/logic branch 2 times, most recently from d8f1199 to df774bb Compare December 29, 2025 14:16
@mr150 mr150 changed the title feat: draft commit with core logic Frontend mvp Dec 29, 2025
@mr150 mr150 merged commit a0c4ef1 into main Dec 29, 2025
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