-
Notifications
You must be signed in to change notification settings - Fork 2
feat(arts-page): add arts page and fix hero frame #27
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
base: main
Are you sure you want to change the base?
Changes from all commits
a99235e
af19071
0ab73d1
ba6669a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
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. В новой схеме вообще нет смысла в отдельном шаблоне. Это ведь не универсальная модалка, а только для артов
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. И сейчас стили модалки не упорядочены. Некоторые арты залезают под кнопки |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| <div class="art-modal-overlay Ps-f T0 L0 W100vw H100vh Bgc-$overlay Zi20 O0 Pne -Ts"> | ||
| <div class="Ps-a T15p L50p Tf -Tr-50p;0 W85p md_W60p xl_W50p Apcr3/2 Bdrd8 Ov-h Bd0.5u;s;$brand D-f Fld-c @:o-l:w<768_H80vh"> | ||
| <button class="art-modal-close btn Ps-a Zi20 T4u R4u C-$white100 md_C-$brand_h C-$brand_a -Ts"> | ||
| <svg class="xxl_-Sz24" width="16" height="16"> | ||
| <use href="/assets/img/icons.svg#close-menu"></use> | ||
| </svg> | ||
| </button> | ||
| <div class="art-modal-content -Sz100p <%= it.artBgc %>"> | ||
|
|
||
| </div> | ||
| <div class="Ps-a Zi10 L0 B3u D-f Ai-c Jc-c Gap8u W100p H50 sm_H40 P0;3u"> | ||
| <div class="art-modal-sandbox W100p Mxw240 H100p"> | ||
| <%- include('../link-button.ejs',{ | ||
| url: `http://play.mlut.style/?art=${it.artId}`, | ||
| text: "Open in sandbox", | ||
| variant: "brand" | ||
| }) | ||
| %> | ||
| </div> | ||
| <div class="art-modal-share W100p Mxw240 H100p"> | ||
| <%- include('../link-button.ejs',{ | ||
| text: "Share", | ||
| variant: "white", | ||
| icon: "share", | ||
| iconClass: "C-$brand W20 H20" | ||
| }) | ||
| %> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </div> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| export class ArtModal extends HTMLElement { | ||
| constructor() { | ||
| super(); | ||
| this.overlay = null; | ||
| this.container = null; | ||
| this.contentContainer = null; | ||
| this.closeBtn = null; | ||
| this.sandboxLink = null; | ||
| this.shareBtn = null; | ||
| this._onShare = null; | ||
|
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._currentArtId = null; | ||
| this._handleKeydown = (e) => { | ||
| if (e.key === 'Escape') { | ||
| this.close(); | ||
| } | ||
| }; | ||
| } | ||
|
|
||
| connectedCallback() { | ||
| this.overlay = this.querySelector('.art-modal-overlay'); | ||
| this.container = this.querySelector('.modal-container'); | ||
| this.contentContainer = this.querySelector('.art-modal-content'); | ||
| this.closeBtn = this.querySelector('.art-modal-close'); | ||
| this.sandboxLink = this.querySelector('.art-modal-sandbox a'); | ||
|
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.shareBtn = this.querySelector('.art-modal-share .btn'); | ||
|
|
||
| if (this.overlay) { | ||
|
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.overlay.addEventListener('click', (e) => { | ||
| if (e.target === this.overlay) this.close(); | ||
| }); | ||
| } | ||
| if (this.closeBtn) { | ||
| this.closeBtn.addEventListener('click', () => this.close()); | ||
| } | ||
| if (this.shareBtn) { | ||
| this.shareBtn.addEventListener('click', () => { | ||
| if (this._onShare) this._onShare(this._currentArtId); | ||
| }); | ||
| } | ||
| } | ||
|
|
||
| open(artHTML, artId, bgClass, onShare) { | ||
| if (!this.contentContainer) return; | ||
|
|
||
| if (this.container && this._currentBgClass) { | ||
| this.container.classList.remove(this._currentBgClass); | ||
| } | ||
|
|
||
| this._currentArtId = artId; | ||
| this._onShare = onShare; | ||
| this._currentBgClass = bgClass; | ||
|
|
||
| if (this.sandboxLink) { | ||
| this.sandboxLink.href = `http://play.mlut.style/?art=${artId}`; | ||
| } | ||
|
|
||
| if (this.container && bgClass) { | ||
| this.container.classList.add(bgClass); | ||
| } | ||
|
|
||
| this.contentContainer.innerHTML = artHTML; | ||
| this.overlay.classList.remove('O0', 'Pne'); | ||
| this.overlay.classList.add('O1', 'Pne-a'); | ||
| document.addEventListener('keydown', this._handleKeydown); | ||
| } | ||
|
|
||
| close() { | ||
| if (!this.overlay) return; | ||
|
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. Что-то не так с отступами |
||
|
|
||
| document.removeEventListener('keydown', this._handleKeydown); | ||
| this.overlay.classList.remove('O1', 'Pne-a'); | ||
| this.overlay.classList.add('O0', 'Pne'); | ||
| if (this.container && this._currentBgClass) { | ||
| this.container.classList.remove(this._currentBgClass); | ||
| } | ||
| if (this.contentContainer) this.contentContainer.innerHTML = ''; | ||
| } | ||
| } | ||
|
|
||
| customElements.define('art-modal', ArtModal); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Тут было бы неплохо сделать рефакторинг. Пусть название css переменной с цветом фона будет формироваться по схеме:
$art${artId}. Только id надо будет перевести из cebab-case в camelCaseThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Привет. Небольшой вопрос:
Если я переведу id в camelCase, то мне нужно будет переименовывать все файлы в папке arts (например: robotHare.ejs) и переименовать все переменные цвета (например: --ml-artrobotHare: #........). Делать так?
Пока не исправлял.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Существующий id не меняем. Переводим его только для получения названия CSS переменной. В шаблоне, вместо
art.bgColor, будет что-то типаBgc-$art${cebab2Camel(art.artId)}. CSS переменные с цветами тоже вроде должны быть уже с подходящими названиями. Если какие-то отдельные не будут подходить - поправь