Skip to content

Commit

Permalink
some components
Browse files Browse the repository at this point in the history
  • Loading branch information
xaota committed Oct 20, 2022
1 parent 1e457d3 commit 4c7bda3
Show file tree
Hide file tree
Showing 11 changed files with 801 additions and 264 deletions.
5 changes: 5 additions & 0 deletions components/caption.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,18 @@ const style = css`
font-size: 24px;
font-family: var(--font);
font-weight: 300;
margin-top: 1em;
margin-bottom: 0.5em;
}
:host([size="small"]) {
font-size: 18px;
}
:host([size="large"]) {
font-size: 30px;
}
:host([size="header"]) {
font-size: 48px;
}
:host([center]) {
text-align: center;
}
Expand Down
22 changes: 18 additions & 4 deletions components/grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,26 @@ const properties = {};

const style = css`
:host {
--grid-padding-default: 40px;
--grid-width: auto;
--grid-height: auto;
--grid-padding: 40px;
--grid-gap: 0;
--grid-gap: 4px;
--grid-columns: 1fr;
--grid-padding: var(--grid-padding-default);
}
:host([thin]) {
--grid-padding: 0;
}
:host([thin="top"]) {
--grid-padding-top: 0;
--grid-padding: var(--grid-padding-default);
}
:host([thin="bottom"]) {
--grid-padding-bottom: 0;
--grid-padding: var(--grid-padding-default);
}
:host, main, slot {
:host, main {
display: block;
}
main {
Expand All @@ -33,7 +46,8 @@ const style = css`
margin: 0 auto;
width: var(--grid-width);
height: var(--grid-height);
padding: var(--grid-padding);
padding-top: var(--grid-padding-top, var(--grid-padding));
padding-bottom: var(--grid-padding-bottom, var(--grid-padding));
gap: var(--grid-gap);
grid-template-columns: var(--grid-columns);
}`;
Expand Down
4 changes: 4 additions & 0 deletions components/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ const style = css`
}
slot[name="navigation"]::slotted(ui-navigation) {
height: 100%;
}
::slotted(ui-caption) {
margin-top: 0;
margin-bottom: 0;
}`;

/** Header {UIHeader} @class @ui @component <ui-header />
Expand Down
20 changes: 13 additions & 7 deletions components/link.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ const style = css`
display: inline-block;
--link-border-style: solid;
}
:host([block]) {
display: block;
}
:host([blank]) {
--link-border-style: dashed;
}
Expand Down Expand Up @@ -79,13 +82,15 @@ const style = css`
<a><span></span></a>
</template>`;

// /** Создание компонента {UILink} @constructor
// * @param {type} store param-description
// */
// constructor(store) {
// super();
// this.store({ store });
// }
/** Создание компонента {UILink} @constructor
* @param {string} text название ссылки
* @param {string} href адрес ссылки
*/
constructor(text, href) {
super();
if (text) this.innerText = text;
if (href) this.setAttribute('href', href);
}

/** Создание элемента в DOM (DOM доступен) / mount @lifecycle
* @param {ShadowRoot} node корневой узел элемента
Expand All @@ -96,6 +101,7 @@ const style = css`

/** @type {HTMLSlotElement} */
const slot = $('slot', node);

slot.addEventListener('slotchange', () => {
const text = slottedValue(slot);
updateChildrenText(node, 'a span', text);
Expand Down
10 changes: 9 additions & 1 deletion components/panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,21 @@ const style = css`
/*
font-size: 18px;
*/
margin: .5em .3em;
margin: 1em .3em;
text-decoration: none;
font-family: var(--font);
display: block;
color: var(--color-primary-dark);
}
::slotted(*:first-child) {
margin-top: 0;
}
::slotted(*:last-child) {
margin-bottom: 0;
}
::slotted(ui-fieldset) {
margin: 0 .3em;
}
Expand Down
6 changes: 5 additions & 1 deletion components/pipeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import UIPipelineStage from './pipeline-stage.js';
import UIBrick from './brick.js';

const attributes = {
/** */
stage(root, value) {
const stages = parseInt(value) || 0;
manage.call(this, root, stages);
Expand Down Expand Up @@ -82,6 +83,7 @@ const style = css`
Component.init(UIPipeline, 'ui-pipeline', { attributes, properties });

// #region [Private]
/** */
function manage(root, stages) {
const div = $('div', root);
if (!div) return;
Expand All @@ -94,6 +96,7 @@ function manage(root, stages) {
manageBricks.call(this, root);
}

/** */
function manageConnections(node) {
const canvas = $('canvas', node);
if (!canvas) return;
Expand Down Expand Up @@ -140,6 +143,7 @@ function manageConnections(node) {
context.closePath();
}

/** */
function manageBricks(node) {
const slot = $('slot', node);
const div = $('div', node);
Expand All @@ -166,7 +170,7 @@ function manageBricks(node) {

manageConnections.call(this, node);
}

/** */
function getGroups(node, rect) {
const div = $('div', node);
if (!div) return;
Expand Down
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ import Component from './script/Component.js';
export * from './script/Template.js';
export * from './script/DOM.js';
export { default as $ } from './script/DOM.js';

export default Component;
Loading

0 comments on commit 4c7bda3

Please sign in to comment.