-
Notifications
You must be signed in to change notification settings - Fork 0
Refactor logic and fix bugs #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
99373c5
029dbce
4a36db5
1624739
3a051a0
142eacb
944908d
2613575
1746589
ac09481
618ab61
b671374
d220d67
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| export const initialLayout = ` | ||
| <div id="hero-page" class="-Gdl120d,$core750,$core650,$core600 Fnf-mUss H100vh P-$heroPadding;0;5u D-f Jc-c Ai-c"> | ||
| export const initialLayout = ` | ||
| <div id="hero-page" class="-Gdl120d,$core750,$core650,$core600 Fnf-mUss H100p P-$heroPadding;0;5u D-f Jc-c Ai-c"> | ||
|
Ramazanmak marked this conversation as resolved.
Outdated
|
||
|
|
||
| <div class="D-f Jc-c Ai-c Fld-c wrapper"> | ||
|
|
||
|
|
@@ -20,12 +20,13 @@ export const initialLayout = ` | |
| </div> | ||
| </div> | ||
| </div> | ||
| ` | ||
| `; | ||
|
|
||
| export const initialConfig = ` | ||
| @use "@mlut/core"; | ||
|
|
||
| @media (prefers-color-scheme: dark){ | ||
| html{ | ||
| *{ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Почему
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Я его вместо
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Для этого же |
||
| --ml-accent900:#fff; | ||
| --ml-accent850:rgb(209,213,219,1); | ||
| --ml-core750:#121828; | ||
|
|
@@ -35,15 +36,15 @@ export const initialConfig = ` | |
| } | ||
|
|
||
| @media (prefers-color-scheme: light){ | ||
| html{ | ||
| *{ | ||
| --ml-accent900:rgb(17,24,39); | ||
| --ml-accent850:rgb(41,42,51,1); | ||
| --ml-core750:rgb(236,240,246,0.5); | ||
| --ml-core650:rgba(218,178,255,0.1); | ||
| --ml-core600:rgba(142,197,255,0.4); | ||
| } | ||
| } | ||
| ` | ||
| `; | ||
|
|
||
| export const errorLayout = ` | ||
| <div> | ||
|
|
@@ -55,7 +56,7 @@ export const errorLayout = ` | |
| Check out the console | ||
| </h2> | ||
| </div> | ||
| ` | ||
| `; | ||
|
|
||
| export const errorStyles = ` | ||
| @media (prefers-color-scheme: light){ | ||
|
|
@@ -73,7 +74,7 @@ export const errorStyles = ` | |
| } | ||
| div { | ||
| background-color:var(--ml-core800); | ||
| height: 100vh; | ||
| height: 100%; | ||
| weight: 100%; | ||
| display: flex; | ||
| flex-direction: column; | ||
|
|
@@ -87,4 +88,4 @@ export const errorStyles = ` | |
| padding: 0; | ||
| margin: 0 0 1rem | ||
| } | ||
| ` | ||
| `; | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| import { createNanoEvents } from 'nanoevents'; | ||
| import { createContext } from '@lit/context'; | ||
|
|
||
| export const eventBusContext = createContext('eventBus'); | ||
| export const eventBus = createNanoEvents(); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,8 @@ | ||
| // replace with normal auth | ||
| //replace with normal auth | ||
| //eslint-disable-next-line | ||
| globalThis.mlut.githubToken += 'ukhbxMg_OmqGHNu4' + 'ilNlnHBDEFpHbfdfqPYkbR1E2vnRbfN6Q7w44ZMECDZuhsGp2EK'; | ||
|
|
||
| const contentLoader = document.querySelector('.loader'); | ||
| window.addEventListener('load', () => { | ||
| contentLoader.classList.remove('loader') | ||
| }) | ||
| window.addEventListener('load', () => { | ||
| contentLoader.classList.remove('loader'); | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,7 +12,7 @@ import { css as langCSS } from '@codemirror/lang-css'; | |
| import { sass as langSASS } from '@codemirror/lang-sass'; | ||
|
|
||
| import { initialLayout, initialConfig } from '../assets/data/initial-code.js'; | ||
| import { eventBusContext } from './main-comp'; | ||
| import { eventBusContext } from '../assets/scripts/eventBusContext.js'; | ||
|
|
||
| const customTheme = Prec.highest(EditorView.theme({ | ||
| '.cm-scroller': { | ||
|
|
@@ -24,11 +24,16 @@ const customTheme = Prec.highest(EditorView.theme({ | |
| })); | ||
|
|
||
| export class CodeEditor extends LitElement { | ||
| _eventBus = new ContextConsumer(this, { context: eventBusContext }); | ||
| _eventBus = new ContextConsumer(this, { | ||
| context: eventBusContext, | ||
| callback: (bus) => { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Для чего это?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Это для того, чтобы не писать везде _eventBus = new ContextConsumer(...).valueне получается - результат будет
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Тогда надо в конструкторе это по нормальному переписать, чтобы не было бесполезного свойства |
||
| this.eventBus = bus; | ||
| } | ||
| }); | ||
|
|
||
| static properties = { | ||
| lang: { type: String }, | ||
| timeoutID: { type: Number, state: false }, | ||
| debounceTimeout: { type: Number, state: false }, | ||
| view: { type: Object }, | ||
| }; | ||
|
|
||
|
|
@@ -40,18 +45,20 @@ export class CodeEditor extends LitElement { | |
| this.view = new EditorView(this.setEditorOptions(this.lang)); | ||
|
|
||
| if (this.lang === 'css') { | ||
| this._eventBus.value.on('update-css', this.updateCss); | ||
| this.unbindUpdateCSS = this.eventBus.on('update-css', this.updateCss); | ||
| } | ||
|
|
||
| this._eventBus.value.on('request-copy', this.handleCopy); | ||
| this.unbindRequestCopy = this.eventBus.on('request-copy', this.handleCopy); | ||
| } | ||
|
|
||
| disconnectedCallback() { | ||
| super.disconnectedCallback(); | ||
|
|
||
| if (this.lang === 'css') { | ||
| this._eventBus.value.off('update-css', this.updateCss); | ||
| this.unbindUpdateCSS(); | ||
| } | ||
|
|
||
| this._eventBus.value.off('request-copy', this.handleCopy); | ||
| this.unbindRequestCopy(); | ||
| } | ||
|
|
||
| setEditorOptions(lang) { | ||
|
|
@@ -102,12 +109,12 @@ export class CodeEditor extends LitElement { | |
| setDocChangeHandler() { | ||
| return EditorView.updateListener.of((update) => { | ||
| if (update.docChanged) { | ||
| clearTimeout(this.timeoutID); | ||
| clearTimeout(this.debounceTimeout); | ||
|
|
||
| if (this.lang !== 'css') { | ||
| this.timeoutID = setTimeout(() => { | ||
| this.debounceTimeout = setTimeout(() => { | ||
|
|
||
| this._eventBus.value.emit(`update-${this.lang}`, { | ||
| this.eventBus.emit(`update-${this.lang}`, { | ||
| detail: { | ||
| target: this, | ||
| updatedData: update.state.doc.toString(), | ||
|
|
@@ -141,7 +148,7 @@ export class CodeEditor extends LitElement { | |
|
|
||
| render() { | ||
| return html` | ||
| <div id="${this.lang}-editor" class="H100p Bgc-$core700 Ov-a Fns10u" style="height: ${this.inProgress ? '0' : '100%'}"> | ||
| <div id="${this.lang}-editor" class="H100p Bgc-$core750 Ov-a Fns4u"> | ||
| </div> | ||
| `; | ||
| } | ||
|
|
||

Uh oh!
There was an error while loading. Please reload this page.