@esportsplus/ui 0.12.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -55,9 +55,11 @@ declare const _default: {
55
55
  text?: Record<string, unknown>;
56
56
  title?: unknown;
57
57
  tooltip?: {
58
- direction?: unknown;
58
+ content?: Record<string, unknown>;
59
59
  } & Record<string, unknown>;
60
- } & Record<string, unknown>) => import("@esportsplus/template/build/types").RenderableTemplate;
60
+ } & Record<string, unknown> & {
61
+ scrollbar?: Record<string, unknown>;
62
+ }) => import("@esportsplus/template/build/types").RenderableTemplate;
61
63
  switch: (data: Parameters<typeof checkbox>[0]) => import("@esportsplus/template/build/types").RenderableTemplate;
62
64
  textarea: (data: Parameters<typeof text>[0]) => import("@esportsplus/template/build/types").RenderableTemplate;
63
65
  text: (data: {
@@ -1,3 +1,4 @@
1
+ import scrollbar from '../../components/scrollbar/index.js';
1
2
  type Data<T extends Record<number | string, number | string>> = {
2
3
  class?: string;
3
4
  content?: unknown;
@@ -15,8 +16,8 @@ type Data<T extends Record<number | string, number | string>> = {
15
16
  text?: Record<string, unknown>;
16
17
  title?: unknown;
17
18
  tooltip?: {
18
- direction?: unknown;
19
+ content?: Record<string, unknown>;
19
20
  } & Record<string, unknown>;
20
- } & Record<string, unknown>;
21
+ } & Parameters<typeof scrollbar>[0] & Record<string, unknown>;
21
22
  declare const _default: <T extends Record<number | string, number | string>>(data: Data<T>) => import("@esportsplus/template/build/types").RenderableTemplate;
22
23
  export default _default;
@@ -1,9 +1,9 @@
1
1
  import { reactive } from '@esportsplus/reactivity';
2
2
  import { html } from '@esportsplus/template';
3
- import { omit } from '@esportsplus/utilities';
3
+ import { isArray, omit } from '@esportsplus/utilities';
4
4
  import form from '../../components/form/index.js';
5
- import scrollbar from '../../components/scrollbar/index.js';
6
5
  import root from '../../components/root/index.js';
6
+ import scrollbar from '../../components/scrollbar/index.js';
7
7
  import description from './description.js';
8
8
  import error from './error.js';
9
9
  import title from './title.js';
@@ -18,7 +18,6 @@ const FIELD_OMIT = [
18
18
  'selected', 'scrollbar',
19
19
  'tag', 'text', 'title', 'tooltip'
20
20
  ];
21
- const TOOLTIP_OMIT = ['direction'];
22
21
  function parse(keys, selected) {
23
22
  let options = {};
24
23
  for (let key of keys) {
@@ -32,22 +31,20 @@ function parse(keys, selected) {
32
31
  }
33
32
  function template(data, state) {
34
33
  data.scrollbar ??= {};
35
- data.scrollbar.style = data.scrollbar.style || '--background-default: var(--color-black-400);';
34
+ data.scrollbar.style ??= '--background-default: var(--color-black-400);';
36
35
  data.tooltip ??= {};
37
- data.tooltip.class = `tooltip-content--${data.tooltip?.direction || 's'} ${data.tooltip?.class || ''}`;
38
- data.tooltip.direction ??= 's';
39
- let { html: h, parent: { attributes: a } } = scrollbar({
40
- attributes: data.scrollbar,
41
- fixed: true
42
- });
43
- return html `
36
+ let content = data.tooltip.content ??= {};
37
+ if (isArray(content.class)) {
38
+ content.class.push('tooltip-content tooltip-content--s --flex-column --width-full');
39
+ }
40
+ else {
41
+ content.class = [content.class, 'tooltip-content tooltip-content--s --flex-column --width-full'];
42
+ }
43
+ content.scrollbar = data.scrollbar;
44
+ return scrollbar(content, html `
44
45
  <div
45
- class='tooltip-content --flex-column --width-full'
46
- ${omit(data.tooltip, TOOLTIP_OMIT)}
47
- >
48
- <div
49
- class='row --flex-column'
50
- onclick='${(e) => {
46
+ class='row --flex-column'
47
+ onclick='${(e) => {
51
48
  let key = e?.target?.dataset?.key;
52
49
  if (key === undefined) {
53
50
  return;
@@ -60,28 +57,24 @@ function template(data, state) {
60
57
  data.effect(key);
61
58
  }
62
59
  }}'
63
- ${a}
64
- >
65
- ${Object.keys(data.options || {}).map((key) => html `
66
- <div
67
- class='
68
- ${() => state.options[key] && '--active'}
69
- link
70
- --flex-vertical
71
- '
72
- data-key='${key}'
73
- ${data.option}
74
- >
75
- <span class='--text-truncate'>
76
- ${data.options[key]}
77
- </span>
78
- </div>
79
- `)}
80
- </div>
81
-
82
- ${h}
60
+ >
61
+ ${Object.keys(data.options || {}).map((key) => html `
62
+ <div
63
+ class='
64
+ ${() => state.options[key] && '--active'}
65
+ link
66
+ --flex-vertical
67
+ '
68
+ data-key='${key}'
69
+ ${data.option}
70
+ >
71
+ <span class='--text-truncate'>
72
+ ${data.options[key]}
73
+ </span>
74
+ </div>
75
+ `)}
83
76
  </div>
84
- `;
77
+ `);
85
78
  }
86
79
  export default (data) => {
87
80
  let state = reactive(Object.assign({
@@ -30,6 +30,7 @@ export * as row from './row/index.js';
30
30
  export { default as scrollbar } from './scrollbar/index.js';
31
31
  export * as sidebar from './sidebar/index.js';
32
32
  export { default as site } from './site/index.js';
33
+ export { default as svg } from './svg/index.js';
33
34
  export * as text from './text/index.js';
34
35
  export * as thumbnail from './thumbnail/index.js';
35
36
  export { default as tooltip } from './tooltip/index.js';
@@ -30,6 +30,7 @@ export * as row from './row/index.js';
30
30
  export { default as scrollbar } from './scrollbar/index.js';
31
31
  export * as sidebar from './sidebar/index.js';
32
32
  export { default as site } from './site/index.js';
33
+ export { default as svg } from './svg/index.js';
33
34
  export * as text from './text/index.js';
34
35
  export * as thumbnail from './thumbnail/index.js';
35
36
  export { default as tooltip } from './tooltip/index.js';
@@ -33,12 +33,16 @@ export default ({ attributes, hide }) => {
33
33
  }
34
34
  return {
35
35
  html: html `
36
- <div class='magnet' style='${() => `
37
- height: ${state.height ? `${state.height}px` : '100%'};
38
- opacity: ${state.opacity};
39
- transform: translate(${state.left}px, ${state.top}px);
40
- width: ${state.width}px;
41
- `}' ${attributes}></div>
36
+ <div
37
+ class='magnet'
38
+ style='${() => `
39
+ height: ${state.height ? `${state.height}px` : '100%'};
40
+ opacity: ${state.opacity};
41
+ transform: translate(${state.left}px, ${state.top}px);
42
+ width: ${state.width}px;
43
+ `}'
44
+ ${attributes}
45
+ ></div>
42
46
  `,
43
47
  sibling: {
44
48
  attributes: events
@@ -1 +1,4 @@
1
+ import scrollbar from '../../components/scrollbar/index.js';
1
2
  import './scss/index.scss';
3
+ declare const _default: (data: Parameters<typeof scrollbar>[0], content: unknown) => import("@esportsplus/template/build/types").RenderableTemplate;
4
+ export default _default;
@@ -1 +1,10 @@
1
+ import { isArray } from '@esportsplus/utilities';
2
+ import scrollbar from '../../components/scrollbar/index.js';
1
3
  import './scss/index.scss';
4
+ export default (data, content) => {
5
+ if (!isArray(data.class)) {
6
+ data.class = data.class ? [data.class] : [];
7
+ }
8
+ data.class.push('modal');
9
+ return scrollbar(data, content);
10
+ };
@@ -1,14 +1,5 @@
1
1
  import './scss/index.scss';
2
- declare const _default: ({ attributes, fixed }?: {
3
- attributes?: Record<string, unknown>;
4
- fixed?: boolean;
5
- }) => {
6
- html: import("@esportsplus/template/build/types").RenderableTemplate;
7
- parent: {
8
- attributes: {
9
- class: string;
10
- onscroll: (this: HTMLElement) => void;
11
- };
12
- };
13
- };
2
+ declare const _default: (data: Record<string, unknown> & {
3
+ scrollbar?: Record<string, unknown>;
4
+ }, content: unknown) => import("@esportsplus/template/build/types").RenderableTemplate;
14
5
  export default _default;
@@ -1,17 +1,31 @@
1
1
  import { reactive } from '@esportsplus/reactivity';
2
2
  import { html } from '@esportsplus/template';
3
+ import { omit } from '@esportsplus/utilities';
3
4
  import './scss/index.scss';
4
5
  let root = document.body, width;
5
- export default ({ attributes, fixed } = {}) => {
6
+ export default (data, content) => {
6
7
  let state = reactive({
7
8
  height: 100,
8
9
  translate: 0
9
10
  });
10
- return {
11
- html: html `
11
+ return html `
12
+ <div
13
+ onscroll='${function () {
14
+ if (width === undefined) {
15
+ width = this.offsetWidth - this.clientWidth;
16
+ if (width && width !== 17) {
17
+ root.style.setProperty('--scrollbar-width', `${width}px`);
18
+ }
19
+ }
20
+ state.height = (this.clientHeight / this.scrollHeight) * 100;
21
+ state.translate = (this.scrollTop / this.clientHeight) * 100;
22
+ }}'
23
+ ${omit(data, ['scrollbar'])}
24
+ >
25
+ ${content}
26
+
12
27
  <div
13
28
  class='
14
- ${fixed && 'scrollbar--fixed'}
15
29
  ${() => state.height >= 100 && 'scrollbar--hidden'}
16
30
  scrollbar
17
31
  '
@@ -19,24 +33,9 @@ export default ({ attributes, fixed } = {}) => {
19
33
  --translate: translate3d(0, ${state.translate}%, 0);
20
34
  --height: ${state.height}%;
21
35
  `}'
22
- ${attributes}
36
+ ${data.scrollbar}
23
37
  >
24
38
  </div>
25
- `,
26
- parent: {
27
- attributes: {
28
- class: 'scrollbar-content',
29
- onscroll: function () {
30
- if (width === undefined) {
31
- width = this.offsetWidth - this.clientWidth;
32
- if (width && width !== 17) {
33
- root.style.setProperty('--scrollbar-width', `${width}px`);
34
- }
35
- }
36
- state.height = (this.clientHeight / this.scrollHeight) * 100;
37
- state.translate = (this.scrollTop / this.clientHeight) * 100;
38
- }
39
- }
40
- }
41
- };
39
+ </div>
40
+ `;
42
41
  };
@@ -1 +1,4 @@
1
+ import scrollbar from '../../components/scrollbar/index.js';
1
2
  import './scss/index.scss';
3
+ declare const _default: (data: Parameters<typeof scrollbar>[0], content: unknown) => import("@esportsplus/template/build/types").RenderableTemplate;
4
+ export default _default;
@@ -1 +1,10 @@
1
+ import { isArray } from '@esportsplus/utilities';
2
+ import scrollbar from '../../components/scrollbar/index.js';
1
3
  import './scss/index.scss';
4
+ export default (data, content) => {
5
+ if (!isArray(data.class)) {
6
+ data.class = data.class ? [data.class] : [];
7
+ }
8
+ data.class.push('sidebar');
9
+ return scrollbar(data, content);
10
+ };
@@ -1,9 +1,4 @@
1
1
  import scrollbar from '../../components/scrollbar/index.js';
2
2
  import './scss/index.scss';
3
- type Data = {
4
- attributes?: Record<string, unknown>;
5
- content?: any;
6
- scrollbar?: Parameters<typeof scrollbar>[0];
7
- };
8
- declare const _default: ({ attributes, content, scrollbar: sb }: Data) => import("@esportsplus/template/build/types").RenderableTemplate;
3
+ declare const _default: (data: Parameters<typeof scrollbar>[0], content: unknown) => import("@esportsplus/template/build/types").RenderableTemplate;
9
4
  export default _default;
@@ -1,17 +1,13 @@
1
- import { html } from '@esportsplus/template';
1
+ import { isArray } from '@esportsplus/utilities';
2
2
  import { onclick } from '../../components/root/index.js';
3
3
  import scrollbar from '../../components/scrollbar/index.js';
4
4
  import './scss/index.scss';
5
- export default ({ attributes, content, scrollbar: sb }) => {
6
- sb ??= {};
7
- sb.attributes ??= {};
8
- sb.attributes.style ??= '--background-default: var(--color-black-400);';
9
- sb.fixed ??= true;
10
- let { html: h, parent } = scrollbar(sb);
11
- return html `
12
- <section class='site' ${attributes} ${{ onclick }} ${parent.attributes}>
13
- ${content || ''}
14
- ${h}
15
- </section>
16
- `;
5
+ export default (data, content) => {
6
+ data.style ??= '--background-default: var(--color-black-400);';
7
+ if (!isArray(data.class)) {
8
+ data.class = data.class ? [data.class] : [];
9
+ }
10
+ data.class.push('site');
11
+ data.onclick = onclick;
12
+ return scrollbar(data, content);
17
13
  };
@@ -0,0 +1,3 @@
1
+ import { svg } from '@esportsplus/template';
2
+ declare const _default: (attributes: Record<string, unknown>, icon: Parameters<typeof svg.sprite>[0]) => import("@esportsplus/template/build/types").RenderableTemplate;
3
+ export default _default;
@@ -0,0 +1,8 @@
1
+ import { html, svg } from '@esportsplus/template';
2
+ export default (attributes, icon) => {
3
+ return html `
4
+ <div class='icon' ${attributes}>
5
+ ${svg.sprite(icon)}
6
+ </div>
7
+ `;
8
+ };
@@ -1,24 +1,11 @@
1
1
  import './scss/index.scss';
2
2
  declare const _default: {
3
- onclick: (data?: {
3
+ onclick: (data: Record<string, unknown> & {
4
4
  active?: boolean;
5
5
  toggle?: boolean;
6
- }) => {
7
- attributes: {
8
- class: () => string;
9
- onclick: (this: HTMLElement, e: Event) => void;
10
- };
11
- state: Prettify<{ [K in keyof T]: import("@esportsplus/reactivity").Infer<T[K]>; } & {
12
- dispose: VoidFunction;
13
- }>;
14
- };
15
- onhover: (active?: boolean) => {
16
- attributes: {
17
- class: () => string;
18
- onmouseover: () => void;
19
- onmouseout: () => void;
20
- };
21
- toggle: () => void;
22
- };
6
+ }, content: unknown) => import("@esportsplus/template/build/types").RenderableTemplate;
7
+ onhover: (data: Record<string, unknown> & {
8
+ active?: boolean;
9
+ }, content: unknown) => import("@esportsplus/template/build/types").RenderableTemplate;
23
10
  };
24
11
  export default _default;
@@ -1,64 +1,78 @@
1
1
  import { reactive } from '@esportsplus/reactivity';
2
+ import { html } from '@esportsplus/template';
3
+ import { isArray, omit } from '@esportsplus/utilities';
2
4
  import root from '../../components/root/index.js';
3
5
  import './scss/index.scss';
4
6
  let queue = [], running = false, scheduled = false;
5
- async function frame() {
7
+ function frame() {
6
8
  if (running) {
7
9
  return;
8
10
  }
9
11
  running = true;
10
12
  let item;
11
13
  while (item = queue.pop()) {
12
- await item();
14
+ item();
13
15
  }
14
16
  running = false;
15
17
  }
16
- const onclick = (data = {}) => {
18
+ const onclick = (data, content) => {
17
19
  let state = reactive({
18
20
  active: data.active || false
19
21
  });
20
- return {
21
- attributes: {
22
- class: () => {
23
- return `tooltip ${state.active ? '--active' : ''}`;
24
- },
25
- onclick: function (e) {
26
- let active = true, node = e.target;
27
- if (data.toggle && (this.contains(node) || this.isSameNode(node))) {
28
- active = !state.active;
29
- }
22
+ if (!isArray(data.class)) {
23
+ data.class = data.class ? [data.class] : [];
24
+ }
25
+ data.class.push(() => {
26
+ return state.active && '--active';
27
+ });
28
+ return html `
29
+ <div
30
+ class='tooltip'
31
+ onclick='${function (e) {
32
+ let active = true, node = e.target;
33
+ if (data.toggle && (this.contains(node) || this.isSameNode(node))) {
34
+ active = !state.active;
35
+ }
36
+ frame();
37
+ state.active = active;
38
+ if (active) {
39
+ queue.push(() => state.active = false);
40
+ }
41
+ if (!scheduled) {
42
+ root.onclick.push(() => {
30
43
  frame();
31
- state.active = active;
32
- if (active) {
33
- queue.push(() => state.active = false);
34
- }
35
- if (!scheduled) {
36
- root.onclick.push(() => {
37
- frame();
38
- scheduled = false;
39
- });
40
- scheduled = true;
41
- }
42
- }
43
- },
44
- state
45
- };
46
- };
47
- const onhover = (active = false) => {
48
- let state = reactive({ active });
49
- return {
50
- attributes: {
51
- class: () => `tooltip ${state.active ? '--active' : ''}`,
52
- onmouseover: () => {
53
- state.active = true;
54
- },
55
- onmouseout: () => {
56
- state.active = false;
57
- }
58
- },
59
- toggle: () => {
60
- state.active = !state.active;
44
+ scheduled = false;
45
+ });
46
+ scheduled = true;
61
47
  }
62
- };
48
+ }}}'
49
+ ${omit(data, ['active', 'toggle'])}
50
+ >
51
+ ${content}
52
+ </div>
53
+ `;
54
+ };
55
+ const onhover = (data, content) => {
56
+ let state = reactive({ active: data.active || false });
57
+ if (!isArray(data.class)) {
58
+ data.class = data.class ? [data.class] : [];
59
+ }
60
+ data.class.push(() => {
61
+ return state.active && '--active';
62
+ });
63
+ return html `
64
+ <div
65
+ class='tooltip'
66
+ onmouseover='${() => {
67
+ state.active = true;
68
+ }}}'
69
+ onmouseout='${() => {
70
+ state.active = false;
71
+ }}'
72
+ ${omit(data, ['active', 'toggle'])}
73
+ >
74
+ ${content}
75
+ </div>
76
+ `;
63
77
  };
64
78
  export default { onclick, onhover };
package/package.json CHANGED
@@ -47,7 +47,7 @@
47
47
  "private": false,
48
48
  "sideEffects": false,
49
49
  "type": "module",
50
- "version": "0.12.0",
50
+ "version": "0.13.0",
51
51
  "scripts": {
52
52
  "build": "run-s build:vite build:ts",
53
53
  "build:ts": "tsc && tsc-alias",
@@ -1,9 +1,9 @@
1
1
  import { reactive } from '@esportsplus/reactivity';
2
2
  import { html } from '@esportsplus/template';
3
- import { omit } from '@esportsplus/utilities';
3
+ import { isArray, omit } from '@esportsplus/utilities';
4
4
  import form from '~/components/form';
5
- import scrollbar from '~/components/scrollbar';
6
5
  import root from '~/components/root';
6
+ import scrollbar from '~/components/scrollbar';
7
7
  import description from './description';
8
8
  import error from './error';
9
9
  import title from './title';
@@ -26,9 +26,9 @@ type Data<T extends Record<number | string, number | string>> = {
26
26
  text?: Record<string, unknown>;
27
27
  title?: unknown;
28
28
  tooltip?: {
29
- direction?: unknown;
29
+ content?: Record<string, unknown>;
30
30
  } & Record<string, unknown>;
31
- } & Record<string, unknown>;
31
+ } & Parameters<typeof scrollbar>[0] & Record<string, unknown>;
32
32
 
33
33
 
34
34
  const FIELD_OMIT: (keyof Data<any>)[] = [
@@ -43,8 +43,6 @@ const FIELD_OMIT: (keyof Data<any>)[] = [
43
43
  'tag', 'text', 'title', 'tooltip'
44
44
  ];
45
45
 
46
- const TOOLTIP_OMIT: (keyof NonNullable<Data<any>['tooltip']>)[] = ['direction'];
47
-
48
46
 
49
47
  function parse(keys: (number | string)[], selected: number | string) {
50
48
  let options: Record<string, boolean> = {};
@@ -63,63 +61,58 @@ function parse(keys: (number | string)[], selected: number | string) {
63
61
 
64
62
  function template<T extends Record<number | string, number | string>>(data: Data<T>, state: { active: boolean, options: Record<number | string, boolean>, selected: number | string }) {
65
63
  data.scrollbar ??= {};
66
- data.scrollbar.style = data.scrollbar.style || '--background-default: var(--color-black-400);';
67
-
64
+ data.scrollbar.style ??= '--background-default: var(--color-black-400);';
68
65
  data.tooltip ??= {};
69
- data.tooltip.class = `tooltip-content--${data.tooltip?.direction || 's'} ${data.tooltip?.class || ''}`;
70
- data.tooltip.direction ??= 's';
71
66
 
72
- let { html: h, parent: { attributes: a } } = scrollbar({
73
- attributes: data.scrollbar,
74
- fixed: true
75
- });
67
+ let content = data.tooltip.content ??= {};
76
68
 
77
- return html`
69
+ if (isArray(content.class)) {
70
+ content.class.push('tooltip-content tooltip-content--s --flex-column --width-full');
71
+ }
72
+ else {
73
+ content.class = [content.class, 'tooltip-content tooltip-content--s --flex-column --width-full'];
74
+ }
75
+
76
+ content.scrollbar = data.scrollbar;
77
+
78
+ return scrollbar(content, html`
78
79
  <div
79
- class='tooltip-content --flex-column --width-full'
80
- ${omit(data.tooltip, TOOLTIP_OMIT)}
80
+ class='row --flex-column'
81
+ onclick='${(e: Event) => {
82
+ let key = (e?.target as HTMLElement)?.dataset?.key;
83
+
84
+ if (key === undefined) {
85
+ return;
86
+ }
87
+
88
+ state.options[key] = true;
89
+ state.options[state.selected] = false;
90
+
91
+ state.active = false;
92
+ state.selected = key;
93
+
94
+ if (data.effect) {
95
+ data.effect(key);
96
+ }
97
+ }}'
81
98
  >
82
- <div
83
- class='row --flex-column'
84
- onclick='${(e: Event) => {
85
- let key = (e?.target as HTMLElement)?.dataset?.key;
86
-
87
- if (key === undefined) {
88
- return;
89
- }
90
-
91
- state.options[key] = true;
92
- state.options[state.selected] = false;
93
-
94
- state.active = false;
95
- state.selected = key;
96
-
97
- if (data.effect) {
98
- data.effect(key);
99
- }
100
- }}'
101
- ${a}
102
- >
103
- ${Object.keys( data.options || {} ).map((key: number | string) => html`
104
- <div
105
- class='
106
- ${() => state.options[key] && '--active'}
107
- link
108
- --flex-vertical
109
- '
110
- data-key='${key}'
111
- ${data.option}
112
- >
113
- <span class='--text-truncate'>
114
- ${data.options[key]}
115
- </span>
116
- </div>
117
- `)}
118
- </div>
119
-
120
- ${h}
99
+ ${Object.keys( data.options || {} ).map((key: number | string) => html`
100
+ <div
101
+ class='
102
+ ${() => state.options[key] && '--active'}
103
+ link
104
+ --flex-vertical
105
+ '
106
+ data-key='${key}'
107
+ ${data.option}
108
+ >
109
+ <span class='--text-truncate'>
110
+ ${data.options[key]}
111
+ </span>
112
+ </div>
113
+ `)}
121
114
  </div>
122
- `;
115
+ `);
123
116
  }
124
117
 
125
118
 
@@ -30,6 +30,7 @@ export * as row from './row';
30
30
  export { default as scrollbar } from './scrollbar';
31
31
  export * as sidebar from './sidebar';
32
32
  export { default as site } from './site';
33
+ export { default as svg } from './svg';
33
34
  export * as text from './text';
34
35
  export * as thumbnail from './thumbnail';
35
36
  export { default as tooltip } from './tooltip';
@@ -42,12 +42,16 @@ export default ({ attributes, hide }: { attributes?: Record<string, unknown>, hi
42
42
 
43
43
  return {
44
44
  html: html`
45
- <div class='magnet' style='${() => `
46
- height: ${state.height ? `${state.height}px` : '100%'};
47
- opacity: ${state.opacity};
48
- transform: translate(${state.left}px, ${state.top}px);
49
- width: ${state.width}px;
50
- `}' ${attributes}></div>
45
+ <div
46
+ class='magnet'
47
+ style='${() => `
48
+ height: ${state.height ? `${state.height}px` : '100%'};
49
+ opacity: ${state.opacity};
50
+ transform: translate(${state.left}px, ${state.top}px);
51
+ width: ${state.width}px;
52
+ `}'
53
+ ${attributes}
54
+ ></div>
51
55
  `,
52
56
  sibling: {
53
57
  attributes: events
@@ -1 +1,14 @@
1
- import './scss/index.scss';
1
+ import { isArray } from '@esportsplus/utilities';
2
+ import scrollbar from '~/components/scrollbar';
3
+ import './scss/index.scss';
4
+
5
+
6
+ export default (data: Parameters<typeof scrollbar>[0], content: unknown) => {
7
+ if (!isArray(data.class)) {
8
+ data.class = data.class ? [data.class] : [];
9
+ }
10
+
11
+ (data.class as unknown[]).push('modal');
12
+
13
+ return scrollbar(data, content);
14
+ };
@@ -1,5 +1,6 @@
1
1
  import { reactive } from '@esportsplus/reactivity';
2
2
  import { html } from '@esportsplus/template';
3
+ import { omit } from '@esportsplus/utilities';
3
4
  import './scss/index.scss';
4
5
 
5
6
 
@@ -7,19 +8,33 @@ let root = document.body,
7
8
  width: number | undefined;
8
9
 
9
10
 
10
- // Convert to wrapper object/container instead of manually placing attributes and html
11
- // Look into scrollbar customization options
12
- export default ({ attributes, fixed }: { attributes?: Record<string, unknown>, fixed?: boolean } = {}) => {
11
+ // TODO: Look into scrollbar customization options
12
+ export default (data: Record<string, unknown> & { scrollbar?: Record<string, unknown> }, content: unknown) => {
13
13
  let state = reactive({
14
14
  height: 100,
15
15
  translate: 0
16
16
  });
17
17
 
18
- return {
19
- html: html`
18
+ return html`
19
+ <div
20
+ onscroll='${function(this: HTMLElement) {
21
+ if (width === undefined) {
22
+ width = this.offsetWidth - this.clientWidth;
23
+
24
+ if (width && width !== 17) {
25
+ root.style.setProperty('--scrollbar-width', `${width}px`);
26
+ }
27
+ }
28
+
29
+ state.height = (this.clientHeight / this.scrollHeight) * 100;
30
+ state.translate = (this.scrollTop / this.clientHeight) * 100;
31
+ }}'
32
+ ${omit(data, ['scrollbar'])}
33
+ >
34
+ ${content}
35
+
20
36
  <div
21
37
  class='
22
- ${fixed && 'scrollbar--fixed'}
23
38
  ${() => state.height >= 100 && 'scrollbar--hidden'}
24
39
  scrollbar
25
40
  '
@@ -27,26 +42,9 @@ export default ({ attributes, fixed }: { attributes?: Record<string, unknown>, f
27
42
  --translate: translate3d(0, ${state.translate}%, 0);
28
43
  --height: ${state.height}%;
29
44
  `}'
30
- ${attributes}
45
+ ${data.scrollbar}
31
46
  >
32
47
  </div>
33
- `,
34
- parent: {
35
- attributes: {
36
- class: 'scrollbar-content',
37
- onscroll: function(this: HTMLElement) {
38
- if (width === undefined) {
39
- width = this.offsetWidth - this.clientWidth;
40
-
41
- if (width && width !== 17) {
42
- root.style.setProperty('--scrollbar-width', `${width}px`);
43
- }
44
- }
45
-
46
- state.height = (this.clientHeight / this.scrollHeight) * 100;
47
- state.translate = (this.scrollTop / this.clientHeight) * 100;
48
- }
49
- }
50
- }
51
- };
48
+ </div>
49
+ `;
52
50
  };
@@ -1 +1,14 @@
1
- import './scss/index.scss';
1
+ import { isArray } from '@esportsplus/utilities';
2
+ import scrollbar from '~/components/scrollbar';
3
+ import './scss/index.scss';
4
+
5
+
6
+ export default (data: Parameters<typeof scrollbar>[0], content: unknown) => {
7
+ if (!isArray(data.class)) {
8
+ data.class = data.class ? [data.class] : [];
9
+ }
10
+
11
+ (data.class as unknown[]).push('sidebar');
12
+
13
+ return scrollbar(data, content);
14
+ };
@@ -1,28 +1,19 @@
1
- import { html } from '@esportsplus/template';
1
+ import { isArray } from '@esportsplus/utilities';
2
2
  import { onclick } from '~/components/root';
3
3
  import scrollbar from '~/components/scrollbar';
4
4
  import './scss/index.scss';
5
5
 
6
6
 
7
- type Data = {
8
- attributes?: Record<string, unknown>;
9
- content?: any;
10
- scrollbar?: Parameters<typeof scrollbar>[0];
11
- };
7
+ export default (data: Parameters<typeof scrollbar>[0], content: unknown) => {
8
+ data.style ??= '--background-default: var(--color-black-400);';
12
9
 
10
+ if (!isArray(data.class)) {
11
+ data.class = data.class ? [data.class] : [];
12
+ }
13
13
 
14
- export default ({ attributes, content, scrollbar: sb }: Data) => {
15
- sb ??= {};
16
- sb.attributes ??= {};
17
- sb.attributes.style ??= '--background-default: var(--color-black-400);';
18
- sb.fixed ??= true;
14
+ (data.class as unknown[]).push('site');
19
15
 
20
- let { html: h, parent } = scrollbar(sb);
16
+ data.onclick = onclick;
21
17
 
22
- return html`
23
- <section class='site' ${attributes} ${{ onclick }} ${parent.attributes}>
24
- ${content || ''}
25
- ${h}
26
- </section>
27
- `;
18
+ return scrollbar(data, content);
28
19
  };
@@ -0,0 +1,10 @@
1
+ import { html, svg } from '@esportsplus/template';
2
+
3
+
4
+ export default (attributes: Record<string, unknown>, icon: Parameters<typeof svg.sprite>[0]) => {
5
+ return html`
6
+ <div class='icon' ${attributes}>
7
+ ${svg.sprite(icon)}
8
+ </div>
9
+ `;
10
+ };
@@ -1,14 +1,16 @@
1
1
  import { reactive } from '@esportsplus/reactivity';
2
+ import { html } from '@esportsplus/template';
3
+ import { isArray, omit } from '@esportsplus/utilities';
2
4
  import root from '~/components/root';
3
5
  import './scss/index.scss';
4
6
 
5
7
 
6
- let queue: (VoidFunction | (() => Promise<void>))[] = [],
8
+ let queue: VoidFunction[] = [],
7
9
  running = false,
8
10
  scheduled = false;
9
11
 
10
12
 
11
- async function frame() {
13
+ function frame() {
12
14
  if (running) {
13
15
  return;
14
16
  }
@@ -18,24 +20,30 @@ async function frame() {
18
20
  let item;
19
21
 
20
22
  while (item = queue.pop()) {
21
- await item();
23
+ item();
22
24
  }
23
25
 
24
26
  running = false;
25
27
  }
26
28
 
27
29
 
28
- const onclick = (data: { active?: boolean, toggle?: boolean } = {}) => {
30
+ const onclick = (data: Record<string, unknown> & { active?: boolean, toggle?: boolean }, content: unknown) => {
29
31
  let state = reactive({
30
32
  active: data.active || false
31
33
  });
32
34
 
33
- return {
34
- attributes: {
35
- class: () => {
36
- return `tooltip ${state.active ? '--active' : ''}`;
37
- },
38
- onclick: function(this: HTMLElement, e: Event) {
35
+ if (!isArray(data.class)) {
36
+ data.class = data.class ? [data.class] : [];
37
+ }
38
+
39
+ (data.class as unknown[]).push(() => {
40
+ return state.active && '--active';
41
+ });
42
+
43
+ return html`
44
+ <div
45
+ class='tooltip'
46
+ onclick='${function(this: HTMLElement, e: Event) {
39
47
  let active = true,
40
48
  node = e.target as Node | null;
41
49
 
@@ -57,29 +65,39 @@ const onclick = (data: { active?: boolean, toggle?: boolean } = {}) => {
57
65
  });
58
66
  scheduled = true;
59
67
  }
60
- }
61
- },
62
- state
63
- };
68
+ }}}'
69
+ ${omit(data, ['active', 'toggle'])}
70
+ >
71
+ ${content}
72
+ </div>
73
+ `;
64
74
  };
65
75
 
66
- const onhover = (active: boolean = false) => {
67
- let state = reactive({ active });
76
+ const onhover = (data: Record<string, unknown> & { active?: boolean }, content: unknown) => {
77
+ let state = reactive({ active: data.active || false });
78
+
79
+ if (!isArray(data.class)) {
80
+ data.class = data.class ? [data.class] : [];
81
+ }
82
+
83
+ (data.class as unknown[]).push(() => {
84
+ return state.active && '--active';
85
+ });
68
86
 
69
- return {
70
- attributes: {
71
- class: () => `tooltip ${state.active ? '--active' : ''}`,
72
- onmouseover: () => {
87
+ return html`
88
+ <div
89
+ class='tooltip'
90
+ onmouseover='${() => {
73
91
  state.active = true;
74
- },
75
- onmouseout: () => {
92
+ }}}'
93
+ onmouseout='${() => {
76
94
  state.active = false;
77
- }
78
- },
79
- toggle: () => {
80
- state.active = !state.active;
81
- }
82
- };
95
+ }}'
96
+ ${omit(data, ['active', 'toggle'])}
97
+ >
98
+ ${content}
99
+ </div>
100
+ `;
83
101
  };
84
102
 
85
103