Skip to content

Commit

Permalink
some changes & new components
Browse files Browse the repository at this point in the history
  • Loading branch information
xaota committed Jan 11, 2022
1 parent aeba31a commit c8bc67f
Show file tree
Hide file tree
Showing 56 changed files with 515 additions and 4,301 deletions.
2 changes: 1 addition & 1 deletion components/arrow.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const style = css`

/** Создание элемента в DOM (DOM доступен) / mount @lifecycle
* @param {ShadowRoot} node корневой узел элемента
* @return {UIArrow} @this текущий компонент
* @return {UIArrow} #this текущий компонент
*/
mount(node) {
super.mount(node, attributes, properties);
Expand Down
2 changes: 1 addition & 1 deletion components/blur.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const style = css`

/** Создание элемента в DOM (DOM доступен) / mount @lifecycle
* @param {ShadowRoot} node корневой узел элемента
* @return {UIBlur} @this текущий компонент
* @return {UIBlur} #this текущий компонент
*/
mount(node) {
super.mount(node, attributes, properties);
Expand Down
2 changes: 1 addition & 1 deletion components/calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const style = css`

/** Создание элемента в DOM (DOM доступен) / mount @lifecycle
* @param {ShadowRoot} node корневой узел элемента
* @return {UICalendar} @this текущий компонент
* @return {UICalendar} #this текущий компонент
*/
mount(node) {
super.mount(node, attributes, properties);
Expand Down
7 changes: 7 additions & 0 deletions components/caption.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ const style = css`
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
}
slot {
color: var(--foreground);
}
::slotted(a) {
color: var(--foreground);
text-decoration: none;
}`;

const attributes = {}
Expand Down
2 changes: 1 addition & 1 deletion components/chronics-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const style = css`

/** Создание элемента в DOM (DOM доступен) / mount @lifecycle
* @param {ShadowRoot} node корневой узел элемента
* @return {UIChronicsItem} @this текущий компонент
* @return {UIChronicsItem} #this текущий компонент
*/
mount(node) {
super.mount(node, attributes, properties);
Expand Down
2 changes: 1 addition & 1 deletion components/chronics.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const style = css`

/** Создание элемента в DOM (DOM доступен) / mount @lifecycle
* @param {ShadowRoot} node корневой узел элемента
* @return {UIChronics} @this текущий компонент
* @return {UIChronics} #this текущий компонент
*/
mount(node) {
super.mount(node, attributes, properties);
Expand Down
2 changes: 1 addition & 1 deletion components/copy-icon.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const style = css`

/** Создание элемента в DOM (DOM доступен) / mount @lifecycle
* @param {ShadowRoot} node корневой узел элемента
* @return {UICopyIcon} @this текущий компонент
* @return {UICopyIcon} #this текущий компонент
*/
mount(node) {
super.mount(node, attributes, properties);
Expand Down
2 changes: 1 addition & 1 deletion components/copy.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const style = css`

/** Создание элемента в DOM (DOM доступен) / mount @lifecycle
* @param {ShadowRoot} node корневой узел элемента
* @return {UICopy} @this текущий компонент
* @return {UICopy} #this текущий компонент
*/
mount(node) {
super.mount(node, attributes, properties);
Expand Down
107 changes: 107 additions & 0 deletions components/cover.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
import Component, { html, css } from '../script/Component.js';
import $, { slottedValue } from '../script/DOM.js';

const attributes = {};
const properties = {};

const style = css`
:host {
display: inline-block;
--cover-width-default: 200px;
--cover-padding: 6px;
position: relative;
text-align: left;
}
:host([view="empty"]) {
--cover-width-default: 120px;
}
:host([view="list"]) {
display: inline-flex;
}
:host([view="list"]), :host([view="text"]) {
--cover-width-default: 40px;
}
#cover {
width: var(--cover-width, var(--cover-width-default));
height: var(--cover-width, var(--cover-width-default));
background-size: cover;
background-position: center center;
background-repeat: no-repeat;
border-radius: var(--cover-padding);
}
:host([view="text"]) #cover {
display: none;
}
slot {
font-size: calc(var(--cover-padding) * 2);
display: block;
}
slot:not([name]) {
display: none;
}
slot[name="caption"] {
/* color: rgba(255, 255, 255, 0.92); */
color: var(--foreground);
}
slot[name="description"], slot[name="author"] {
/* color: rgba(255, 255, 255, 0.64); */
color: var(--foreground-light);
}
#info {
padding: var(--cover-padding);
}
:host([view="compact"]) #info {
padding: 0;
position: absolute;
bottom: 0;
left: 0;
right: 0;
background: linear-gradient(transparent, rgba(0, 0, 0, 0.5) 20%, black 90%);
}
:host([view="empty"]) #info {
display: none;
}`;

/** Cover {UICover} @class @ui @component <ui-cover />
* Covers for media elements
*/
export default class UICover extends Component {
static template = html`
<template>
<style>${style}</style>
<div id="cover"></div>
<div id="info">
<slot name="caption"></slot>
<slot name="description"></slot>
<slot name="author"></slot>
<slot name="keywords"></slot>
<slot name="actions"></slot>
<slot name="timestamp"></slot>
</div>
<slot></slot>
</template>`;

// /** Создание компонента {UICover} @constructor
// */
// constructor(store) {
// super();
// }

/** Создание элемента в DOM (DOM доступен) / mount @lifecycle
* @param {ShadowRoot} node корневой узел элемента
* @return {UICover} this текущий компонент
*/
mount(node) {
super.mount(node, attributes, properties);
const slotDefault = $('slot:not([name])', node);
const cover = $('#cover', node);
slotDefault.addEventListener('slotchange', () => {
const url = slottedValue(slotDefault);
console.log(url);
cover.style.backgroundImage = `url(${url})`;
});
return this;
}
}

Component.init(UICover, 'ui-cover', { attributes, properties });
9 changes: 7 additions & 2 deletions components/dialog.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import Component, { html, css } from '../script/Component.js';
import { updateChildrenText } from '../script/DOM.js';
import Deferred from 'javascript-toolbox/library/Deferred.js';
import UIButton from './button.js';
// eslint-disable-next-line no-unused-vars
import UICaption from './caption.js';
Expand Down Expand Up @@ -111,7 +110,13 @@ const properties = {}
this.cache.root = root;
this.cache.z = z;

this.promise = new Deferred();
// this.promise = new Deferred();
// @TODO:
const promise = new Promise((resolve, reject) => {
promise.resolve = resolve;
promise.reject = reject;
});
this.promise = promise;

this.splash = document.createElement('div'); // #ui-popup-splash
const style = {
Expand Down
2 changes: 1 addition & 1 deletion components/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const style = css`

/** Создание элемента в DOM (DOM доступен) / mount @lifecycle
* @param {ShadowRoot} node корневой узел элемента
* @return {UIDownload} @this текущий компонент
* @return {UIDownload} #this текущий компонент
*/
mount(node) {
super.mount(node, attributes, properties);
Expand Down
2 changes: 1 addition & 1 deletion components/fab-tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const style = css`

/** Создание элемента в DOM (DOM доступен) / mount @lifecycle
* @param {ShadowRoot} node корневой узел элемента
* @return {UIFABTooltip} @this текущий компонент
* @return {UIFABTooltip} #this текущий компонент
*/
mount(node) {
super.mount(node, attributes, properties);
Expand Down
2 changes: 1 addition & 1 deletion components/footer.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const style = css`

/** Создание элемента в DOM (DOM доступен) / mount @lifecycle
* @param {ShadowRoot} node корневой узел элемента
* @return {UIFooter} @this текущий компонент
* @return {UIFooter} #this текущий компонент
*/
mount(node) {
super.mount(node, attributes, properties);
Expand Down
50 changes: 33 additions & 17 deletions components/grid.js
Original file line number Diff line number Diff line change
@@ -1,43 +1,59 @@
import Component, { html, css } from '../script/Component.js';
import { cssVariable } from '../script/DOM.js';

const attributes = {};
const attributes = {
/** / columns */
columns(root, value) {
const temp = value.replace(/\s+/g, '');
const valid = /^(\d+-)+\d$/.test(temp);
const data = valid
? temp.split('-').map(e => e + 'fr').join(' ')
: 'initial';
cssVariable('slot', 'grid-columns', data, root);
}
};
const properties = {};

const style = css`
:host {
--grid-width: auto;
--grid-height: auto;
--grid-padding: 40px;
--grid-gap: 0;
--grid-columns: 1fr;
}
:host, main, slot {
display: block;
}
main {
margin: 0 auto;
}
slot {
display: block;
display: grid;
margin: 0 auto;
width: var(--grid-width);
height: var(--grid-height);
padding: var(--grid-padding);
gap: var(--grid-gap);
grid-template-columns: var(--grid-columns);
}`;

/** Grid {UIGrid} @class @ui @component <ui-grid />
* Раскладка
* Разделение блоков по сетке
*/
export default class UIGrid extends Component {
static template = html`
<template>
<style>${style}</style>
<slot></slot>
<main><slot></slot></main>
</template>`;

/** Создание компонента {UIGrid} @constructor
* @param {type} store type
*/
constructor(store) {
super();
this.store({ store });
}

/** Создание элемента в DOM (DOM доступен) / mount @lifecycle
* @param {ShadowRoot} node корневой узел элемента
* @return {UIGrid} @this текущий компонент
* @return {UIGrid} #this текущий компонент
*/
mount(node) {
super.mount(node, attributes, properties);

const { store } = this.store();
return this;
return super.mount(node, attributes, properties);
}
}

Expand Down
35 changes: 24 additions & 11 deletions components/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,20 @@ const properties = {};

const style = css`
:host {
display: block;
display: flex;
height: 72px;
box-shadow: 0 2px 4px rgb(0 0 0 / 50%);
padding: 0 24px;
justify-content: space-between;
align-items: center;
flex-wrap: nowrap;
background: var(--background);
}
slot {
slot:not(:empty) {
display: block;
}
slot[name="navigation"]::slotted(ui-navigation) {
height: 100%;
}`;

/** Header {UIHeader} @class @ui @component <ui-header />
Expand All @@ -18,25 +28,28 @@ const style = css`
static template = html`
<template>
<style>${style}</style>
<slot name="logo"></slot>
<slot></slot>
<slot name="navigation"></slot>
<slot name="profile"></slot>
</template>`;

/** Создание компонента {UIHeader} @constructor
* @param {type} store type
*/
constructor(store) {
super();
this.store({ store });
}
// /** Создание компонента {UIHeader} @constructor
// * @param {type} store type
// */
// constructor(store) {
// super();
// this.store({ store });
// }

/** Создание элемента в DOM (DOM доступен) / mount @lifecycle
* @param {ShadowRoot} node корневой узел элемента
* @return {UIHeader} @this текущий компонент
* @return {UIHeader} #this текущий компонент
*/
mount(node) {
super.mount(node, attributes, properties);

const { store } = this.store();
// const { store } = this.store();
return this;
}
}
Expand Down
4 changes: 2 additions & 2 deletions components/icon.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const properties = {}

/** Создание элемента в DOM (DOM доступен) / mount @lifecycle
* @param {ShadowRoot} node корневой узел элемента
* @return {UIIcon} @this
* @return {UIIcon} this
*/
mount(node) {
super.mount(node, attributes, properties);
Expand Down Expand Up @@ -82,7 +82,7 @@ Component.init(UIIcon, 'ui-icon', { attributes, properties });

const fragment = document.createElement('template');
fragment.innerHTML = SVG.trim();
const svg = fragment.content.firstChild;
const svg = fragment.content.firstChild; // querySelector('svg')
svg.id = id;
root.appendChild(svg);
return svg;
Expand Down
2 changes: 1 addition & 1 deletion components/layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const style = css`

/** Создание элемента в DOM (DOM доступен) / mount @lifecycle
* @param {ShadowRoot} node корневой узел элемента
* @return {UILayer} @this текущий компонент
* @return {UILayer} #this текущий компонент
*/
mount(node) {
super.mount(node, attributes, properties);
Expand Down
Loading

0 comments on commit c8bc67f

Please sign in to comment.