@e280/shiny 0.1.0-1

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.
Files changed (94) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +10 -0
  3. package/package.json +62 -0
  4. package/s/demo/demo.bundle.ts +42 -0
  5. package/s/demo/demo.css +120 -0
  6. package/s/demo/views/demonstration/style.css.ts +108 -0
  7. package/s/demo/views/demonstration/view.ts +49 -0
  8. package/s/icons/tabler/ABOUT.md +7 -0
  9. package/s/icons/tabler/LICENSE +23 -0
  10. package/s/icons/tabler/clipboard-check-filled.svg.ts +4 -0
  11. package/s/icons/tabler/clipboard-x-filled.svg.ts +4 -0
  12. package/s/icons/tabler/clipboard.svg.ts +4 -0
  13. package/s/icons/tabler/copy.svg.ts +4 -0
  14. package/s/index.html.ts +37 -0
  15. package/s/index.ts +7 -0
  16. package/s/tests.test.ts +5 -0
  17. package/s/themes/basic.css.ts +18 -0
  18. package/s/themes/index.barrel.ts +3 -0
  19. package/s/themes/index.ts +3 -0
  20. package/s/tools/untab.ts +30 -0
  21. package/s/ui/components.ts +9 -0
  22. package/s/ui/copy/component.ts +66 -0
  23. package/s/ui/copy/style.css.ts +46 -0
  24. package/s/ui/example/component.ts +25 -0
  25. package/s/ui/example/style.css.ts +11 -0
  26. package/s/ui/framework.ts +8 -0
  27. package/s/ui/themers.ts +28 -0
  28. package/x/demo/demo.bundle.d.ts +1 -0
  29. package/x/demo/demo.bundle.js +37 -0
  30. package/x/demo/demo.bundle.js.map +1 -0
  31. package/x/demo/demo.bundle.min.js +277 -0
  32. package/x/demo/demo.bundle.min.js.map +7 -0
  33. package/x/demo/demo.css +120 -0
  34. package/x/demo/views/demonstration/style.css.d.ts +2 -0
  35. package/x/demo/views/demonstration/style.css.js +107 -0
  36. package/x/demo/views/demonstration/style.css.js.map +1 -0
  37. package/x/demo/views/demonstration/view.d.ts +10 -0
  38. package/x/demo/views/demonstration/view.js +36 -0
  39. package/x/demo/views/demonstration/view.js.map +1 -0
  40. package/x/icons/tabler/clipboard-check-filled.svg.d.ts +2 -0
  41. package/x/icons/tabler/clipboard-check-filled.svg.js +3 -0
  42. package/x/icons/tabler/clipboard-check-filled.svg.js.map +1 -0
  43. package/x/icons/tabler/clipboard-x-filled.svg.d.ts +2 -0
  44. package/x/icons/tabler/clipboard-x-filled.svg.js +3 -0
  45. package/x/icons/tabler/clipboard-x-filled.svg.js.map +1 -0
  46. package/x/icons/tabler/clipboard.svg.d.ts +2 -0
  47. package/x/icons/tabler/clipboard.svg.js +3 -0
  48. package/x/icons/tabler/clipboard.svg.js.map +1 -0
  49. package/x/icons/tabler/copy.svg.d.ts +2 -0
  50. package/x/icons/tabler/copy.svg.js +3 -0
  51. package/x/icons/tabler/copy.svg.js.map +1 -0
  52. package/x/index.d.ts +5 -0
  53. package/x/index.html +157 -0
  54. package/x/index.html.d.ts +2 -0
  55. package/x/index.html.js +33 -0
  56. package/x/index.html.js.map +1 -0
  57. package/x/index.js +6 -0
  58. package/x/index.js.map +1 -0
  59. package/x/tests.test.d.ts +1 -0
  60. package/x/tests.test.js +3 -0
  61. package/x/tests.test.js.map +1 -0
  62. package/x/themes/basic.css.d.ts +1 -0
  63. package/x/themes/basic.css.js +17 -0
  64. package/x/themes/basic.css.js.map +1 -0
  65. package/x/themes/index.barrel.d.ts +1 -0
  66. package/x/themes/index.barrel.js +2 -0
  67. package/x/themes/index.barrel.js.map +1 -0
  68. package/x/themes/index.d.ts +1 -0
  69. package/x/themes/index.js +2 -0
  70. package/x/themes/index.js.map +1 -0
  71. package/x/tools/untab.d.ts +1 -0
  72. package/x/tools/untab.js +26 -0
  73. package/x/tools/untab.js.map +1 -0
  74. package/x/ui/components.d.ts +6 -0
  75. package/x/ui/components.js +7 -0
  76. package/x/ui/components.js.map +1 -0
  77. package/x/ui/copy/component.d.ts +372 -0
  78. package/x/ui/copy/component.js +56 -0
  79. package/x/ui/copy/component.js.map +1 -0
  80. package/x/ui/copy/style.css.d.ts +2 -0
  81. package/x/ui/copy/style.css.js +45 -0
  82. package/x/ui/copy/style.css.js.map +1 -0
  83. package/x/ui/example/component.d.ts +371 -0
  84. package/x/ui/example/component.js +20 -0
  85. package/x/ui/example/component.js.map +1 -0
  86. package/x/ui/example/style.css.d.ts +2 -0
  87. package/x/ui/example/style.css.js +10 -0
  88. package/x/ui/example/style.css.js.map +1 -0
  89. package/x/ui/framework.d.ts +4 -0
  90. package/x/ui/framework.js +6 -0
  91. package/x/ui/framework.js.map +1 -0
  92. package/x/ui/themers.d.ts +8 -0
  93. package/x/ui/themers.js +12 -0
  94. package/x/ui/themers.js.map +1 -0
package/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+
2
+ MIT License
3
+
4
+ Copyright (c) 2025 Chase Moskal
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,10 @@
1
+
2
+ <div align="center"><img alt="" width="256" src="./assets/favicon.png"/></div>
3
+
4
+ # ✨ shiny
5
+ > *web ui components*
6
+
7
+ https://shiny.e280.org/
8
+
9
+ <br/><br/>
10
+
package/package.json ADDED
@@ -0,0 +1,62 @@
1
+ {
2
+ "name": "@e280/shiny",
3
+ "version": "0.1.0-1",
4
+ "description": "✨ web ui components",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "main": "./x/index.js",
8
+ "sideEffects": false,
9
+ "exports": {
10
+ ".": "./x/index.js"
11
+ },
12
+ "files": [
13
+ "x",
14
+ "s"
15
+ ],
16
+ "peerDependencies": {
17
+ "@e280/sly": "^0.2.0-21",
18
+ "lit": "^3.3.1"
19
+ },
20
+ "dependencies": {
21
+ "@e280/strata": "^0.2.0-14",
22
+ "@e280/stz": "^0.2.6"
23
+ },
24
+ "devDependencies": {
25
+ "@e280/science": "^0.1.2",
26
+ "@e280/scute": "^0.1.0",
27
+ "http-server": "^14.1.1",
28
+ "npm-run-all": "^4.1.5",
29
+ "typescript": "^5.9.2"
30
+ },
31
+ "scripts": {
32
+ "build": "run-s _clean _ln _tsc _scute",
33
+ "start": "octo 'scute -vw' 'tsc -w' 'node --watch x/tests.test.js' 'http-server x'",
34
+ "count": "find s -path '*/_archive' -prune -o -name '*.ts' -exec wc -l {} +",
35
+ "test": "node x/tests.test.js",
36
+ "test-inspect": "node inspect x/tests.test.js",
37
+ "_clean": "rm -rf x && mkdir x",
38
+ "_tsc": "tsc",
39
+ "_scute": "scute -v",
40
+ "_ln": "run-s _ln:s _ln:assets",
41
+ "_ln:s": "ln -s \"$(realpath s)\" x/s",
42
+ "_ln:assets": "ln -s \"$(realpath assets)\" x/assets",
43
+ "_lnx:stz": "rm -rf node_modules/@e280/stz && ln -s \"$(realpath ../stz)\" node_modules/@e280/stz"
44
+ },
45
+ "author": "Chase Moskal <chasemoskal@gmail.com>",
46
+ "homepage": "https://github.com/e280/shiny#readme",
47
+ "repository": {
48
+ "type": "git",
49
+ "url": "git+https://github.com/e280/shiny.git"
50
+ },
51
+ "bugs": {
52
+ "url": "https://github.com/e280/shiny/issues"
53
+ },
54
+ "keywords": [
55
+ "web ui",
56
+ "ui library",
57
+ "components",
58
+ "web components",
59
+ "lit",
60
+ "sly"
61
+ ]
62
+ }
@@ -0,0 +1,42 @@
1
+
2
+ import {css, html} from "lit"
3
+ import {dom, view} from "@e280/sly"
4
+ import {themes} from "../themes/index.js"
5
+ import {themeViews} from "../ui/themers.js"
6
+ import {Demonstration} from "./views/demonstration/view.js"
7
+
8
+ const views = themeViews(themes.basic)
9
+
10
+ dom.register({ShinyDemo: view.component(use => {
11
+ use.styles(css`
12
+ :host {
13
+ display: flex;
14
+ flex-direction: column;
15
+ gap: 1em;
16
+ }
17
+
18
+ [view="shiny-copy"]::part(content) {
19
+ font-size: 4em;
20
+ }
21
+ `)
22
+
23
+ return [
24
+ Demonstration({
25
+ views,
26
+ name: "shiny-copy",
27
+ explain: html`
28
+ <p>button for click-to-copy text</p>
29
+ `,
30
+ exampleView: `
31
+ ShinyCopy("hello world")
32
+ `,
33
+ exampleComponent: `
34
+ <shiny-copy text="hello world"></shiny-copy>
35
+ `,
36
+ content: views.ShinyCopy("hello world"),
37
+ }),
38
+ ]
39
+ })})
40
+
41
+ console.log("✨ shiny")
42
+
@@ -0,0 +1,120 @@
1
+
2
+ @layer vars, core, page;
3
+
4
+ @layer vars {
5
+ :root {
6
+ --bg: #333;
7
+ --color: #fff;
8
+ --prime: #d068ff;
9
+ --link: cyan;
10
+
11
+ --selection: white;
12
+ --selection-bg: #f70;
13
+ }
14
+ }
15
+
16
+ @layer core {
17
+ * {
18
+ margin: 0;
19
+ padding: 0;
20
+ box-sizing: border-box;
21
+
22
+ scrollbar-width: thin;
23
+ scrollbar-color: #444 transparent;
24
+ }
25
+
26
+ :not(:defined) {
27
+ display: none;
28
+ }
29
+
30
+ ::selection {
31
+ color: var(--selection);
32
+ background-color: var(--selection-bg);
33
+ }
34
+
35
+ ::-webkit-scrollbar { width: 8px; }
36
+ ::-webkit-scrollbar-track { background: transparent; }
37
+ ::-webkit-scrollbar-thumb { background: #444; border-radius: 1em; }
38
+ ::-webkit-scrollbar-thumb:hover { background: #666; }
39
+
40
+ a {
41
+ color: var(--link);
42
+ text-decoration: none;
43
+
44
+ &:visited {
45
+ color: color-mix(in srgb, purple, var(--link) 70%);
46
+ }
47
+
48
+ &:hover {
49
+ color: color-mix(in srgb, white, var(--link) 90%);
50
+ text-decoration: underline;
51
+ }
52
+
53
+ &:active {
54
+ color: color-mix(in srgb, white, var(--link) 50%);
55
+ }
56
+ }
57
+ }
58
+
59
+ @layer page {
60
+ :root {
61
+ height: 100%;
62
+ font-size: 16px;
63
+ font-family: sans-serif;
64
+
65
+ color-scheme: dark;
66
+ scrollbar-gutter: stable;
67
+
68
+ color: var(--color);
69
+ background: var(--bg);
70
+
71
+ --tint: #070429aa;
72
+ background:
73
+ linear-gradient(0deg, var(--tint), var(--tint)),
74
+ #141519 url("/assets/bg.webp") center 60% / cover no-repeat;
75
+
76
+ background-attachment: fixed, fixed;
77
+
78
+ text-shadow: 0.1em 0.1em 0.2em #0008;
79
+ }
80
+
81
+ body {
82
+ width: 100%;
83
+ min-height: 100%;
84
+ max-width: 60em;
85
+ margin: auto;
86
+ padding: 1em;
87
+ padding-bottom: 6em;
88
+
89
+ display: flex;
90
+ flex-direction: column;
91
+ gap: 1em;
92
+ }
93
+
94
+ h1 {
95
+ font-size: 1.5em;
96
+ display: flex;
97
+ flex-direction: column;
98
+ text-align: center;
99
+
100
+ strong {
101
+ font-size: 1.5em;
102
+ color: var(--prime);
103
+ }
104
+
105
+ small {
106
+ opacity: 0.6;
107
+ font-size: 0.7em;
108
+ font-weight: normal;
109
+ }
110
+ }
111
+
112
+ body > section {
113
+ display: flex;
114
+ flex-direction: column;
115
+ align-items: center;
116
+ justify-content: center;
117
+ margin-bottom: 1em;
118
+ }
119
+ }
120
+
@@ -0,0 +1,108 @@
1
+
2
+ import {css} from "lit"
3
+ export default css`
4
+
5
+ :host {
6
+ position: relative;
7
+
8
+ display: flex;
9
+ flex-wrap: wrap;
10
+
11
+ padding: 1em;
12
+ border-radius: 0.5em;
13
+ gap: 1em;
14
+
15
+ background: linear-gradient(to right top, #252dd985, #aa6affbd);
16
+ backdrop-filter: blur(0.5em);
17
+
18
+ box-shadow: 0 0 5em #5d1fadaa;
19
+ border-top: 2px solid #fff4;
20
+
21
+ &::before {
22
+ content: "";
23
+ display: block;
24
+ position: absolute;
25
+ inset: 0;
26
+ border-radius: 0.5em;
27
+ background: #0007;
28
+ width: calc(100% - 0.3em);
29
+ height: calc(100% - 0.3em);
30
+ margin: auto;
31
+ z-index: 0;
32
+ }
33
+
34
+ > * {
35
+ position: relative;
36
+ z-index: 1;
37
+ }
38
+ }
39
+
40
+ .meta {
41
+ flex: 1 1 10em;
42
+ display: flex;
43
+ flex-direction: column;
44
+ gap: 0.5em;
45
+
46
+ h2 {
47
+ color: var(--prime);
48
+ }
49
+
50
+ .codes {
51
+ display: flex;
52
+ flex-direction: column;
53
+ gap: 0.2em;
54
+ }
55
+
56
+ .codeblock {
57
+ display: flex;
58
+ background: #0002;
59
+ border-radius: 0.3em;
60
+ border-bottom: 1px solid #fff2;
61
+ box-shadow: inset 0.2em 0.3em 2em #0004;
62
+
63
+ .zone {
64
+ flex: 1 1 auto;
65
+ display: flex;
66
+ flex-direction: column;
67
+ padding: 0.5em;
68
+
69
+ h3 {
70
+ opacity: 0.4;
71
+ font-size: 0.7em;
72
+ font-weight: normal;
73
+ font-style: italic;
74
+ }
75
+
76
+ code {
77
+ display: block;
78
+ white-space: pre;
79
+ text-wrap: wrap;
80
+ tab-size: 2;
81
+
82
+ font-size: 0.8em;
83
+ font-family: monospace;
84
+ color: #8f8;
85
+ }
86
+ }
87
+
88
+ [view="shiny-copy"] {
89
+ flex: 0 0 0;
90
+ padding: 0.2em;
91
+ }
92
+ }
93
+ }
94
+
95
+ .content {
96
+ flex: 1 1 10rem;
97
+ display: flex;
98
+ flex-direction: column;
99
+ justify-content: center;
100
+ align-items: center;
101
+
102
+ padding: 1rem;
103
+ border-radius: 0.5rem;
104
+ border: 1px dashed #fff4;
105
+ }
106
+
107
+ `
108
+
@@ -0,0 +1,49 @@
1
+
2
+ import {html} from "lit"
3
+ import {Content, view} from "@e280/sly"
4
+ import styleCss from "./style.css.js"
5
+ import {untab} from "../../../tools/untab.js"
6
+ import {ShinyViews} from "../../../ui/themers.js"
7
+ import {basic} from "../../../themes/basic.css.js"
8
+
9
+ export const Demonstration = view(use => (options: {
10
+ name: string
11
+ explain: Content
12
+ views: ShinyViews
13
+ exampleView: string
14
+ exampleComponent: string
15
+ content: Content
16
+ }) => {
17
+
18
+ use.name(options.name)
19
+ use.styles(basic, styleCss)
20
+
21
+ function codeblock(heading: string, code: string) {
22
+ const cleanCode = untab(code).trim()
23
+ return html`
24
+ <div class=codeblock>
25
+ <div class=zone>
26
+ <h3>${heading}</h3>
27
+ <code>${cleanCode}</code>
28
+ </div>
29
+ ${options.views.ShinyCopy(cleanCode)}
30
+ </div>
31
+ `
32
+ }
33
+
34
+ return html`
35
+ <div class=meta>
36
+ <h2>✨ ${options.name}</h2>
37
+ <div class=explain>${options.explain}</div>
38
+ <div class=codes>
39
+ ${codeblock("sly view", options.exampleView)}
40
+ ${codeblock("html web component", options.exampleComponent)}
41
+ </div>
42
+ </div>
43
+
44
+ <div class=content part=content>
45
+ ${options.content}
46
+ </div>
47
+ `
48
+ })
49
+
@@ -0,0 +1,7 @@
1
+
2
+ yo.
3
+
4
+ we've modified these tabler icons to export them as lit svgs.
5
+
6
+ we got 'em from here: https://github.com/tabler/tabler-icons
7
+
@@ -0,0 +1,23 @@
1
+
2
+ MIT License
3
+
4
+ Copyright (c) 2020-2025 Paweł Kuna
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
23
+
@@ -0,0 +1,4 @@
1
+
2
+ import {svg} from "lit"
3
+ export default svg`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" class="icon icon-tabler icons-tabler-filled icon-tabler-clipboard-check"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M17.997 4.17a3 3 0 0 1 2.003 2.83v12a3 3 0 0 1 -3 3h-10a3 3 0 0 1 -3 -3v-12a3 3 0 0 1 2.003 -2.83a4 4 0 0 0 3.997 3.83h4a4 4 0 0 0 3.98 -3.597zm-3.704 7.123l-3.293 3.292l-1.293 -1.292a1 1 0 1 0 -1.414 1.414l2 2a1 1 0 0 0 1.414 0l4 -4a1 1 0 0 0 -1.414 -1.414m-.293 -9.293a2 2 0 1 1 0 4h-4a2 2 0 1 1 0 -4z" /></svg>`
4
+
@@ -0,0 +1,4 @@
1
+
2
+ import {svg} from "lit"
3
+ export default svg`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" class="icon icon-tabler icons-tabler-filled icon-tabler-clipboard-x"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M17.997 4.17a3 3 0 0 1 2.003 2.83v12a3 3 0 0 1 -3 3h-10a3 3 0 0 1 -3 -3v-12a3 3 0 0 1 2.003 -2.83a4 4 0 0 0 3.997 3.83h4a4 4 0 0 0 3.98 -3.597zm-7.29 7.123a1 1 0 0 0 -1.414 0l-.083 .094a1 1 0 0 0 .083 1.32l1.292 1.293l-1.292 1.293a1 1 0 0 0 0 1.414l.094 .083a1 1 0 0 0 1.32 -.083l1.293 -1.293l1.293 1.293a1 1 0 0 0 1.414 0l.083 -.094a1 1 0 0 0 -.083 -1.32l-1.293 -1.293l1.293 -1.293a1 1 0 0 0 0 -1.414l-.094 -.083a1 1 0 0 0 -1.32 .083l-1.293 1.292zm3.293 -9.293a2 2 0 1 1 0 4h-4a2 2 0 1 1 0 -4z" /></svg>`
4
+
@@ -0,0 +1,4 @@
1
+
2
+ import {svg} from "lit"
3
+ export default svg`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon icon-tabler icons-tabler-outline icon-tabler-clipboard"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M9 5h-2a2 2 0 0 0 -2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-12a2 2 0 0 0 -2 -2h-2" /><path d="M9 3m0 2a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2v0a2 2 0 0 1 -2 2h-2a2 2 0 0 1 -2 -2z" /></svg>`
4
+
@@ -0,0 +1,4 @@
1
+
2
+ import {svg} from "lit"
3
+ export default svg`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon icon-tabler icons-tabler-outline icon-tabler-copy"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M7 7m0 2.667a2.667 2.667 0 0 1 2.667 -2.667h8.666a2.667 2.667 0 0 1 2.667 2.667v8.666a2.667 2.667 0 0 1 -2.667 2.667h-8.666a2.667 2.667 0 0 1 -2.667 -2.667z" /><path d="M4.012 16.737a2.005 2.005 0 0 1 -1.012 -1.737v-10c0 -1.1 .9 -2 2 -2h10c.75 0 1.158 .385 1.5 1" /></svg>`
4
+
@@ -0,0 +1,37 @@
1
+
2
+ import {ssg, html} from "@e280/scute"
3
+
4
+ const title = "shiny"
5
+ const description = "✨ web ui components"
6
+ const domain = "shiny.e280.org"
7
+ const favicon = "/assets/favicon.png"
8
+
9
+ export default ssg.page(import.meta.url, async orb => ({
10
+ title,
11
+ js: "demo/demo.bundle.min.js",
12
+ css: "demo/demo.css",
13
+ favicon,
14
+ dark: true,
15
+ socialCard: {
16
+ themeColor: "#d068ff",
17
+ title,
18
+ description,
19
+ siteName: "@e280/shiny",
20
+ image: "https://" + domain + favicon,
21
+ },
22
+
23
+ body: html`
24
+ <h1>
25
+ <strong>✨ @e280/shiny</strong>
26
+ <small>v${orb.packageVersion()}</small>
27
+ </h1>
28
+
29
+ <section>
30
+ <p>web ui components</p>
31
+ <p><a href="https://github.com/e280/shiny#readme">readme</a></p>
32
+ </section>
33
+
34
+ <shiny-demo></shiny-demo>
35
+ `,
36
+ }))
37
+
package/s/index.ts ADDED
@@ -0,0 +1,7 @@
1
+
2
+ export * from "./themes/index.js"
3
+ export * from "./ui/example/component.js"
4
+ export * from "./ui/copy/component.js"
5
+ export * from "./ui/themers.js"
6
+ export * from "./ui/components.js"
7
+
@@ -0,0 +1,5 @@
1
+
2
+ import {Science} from "@e280/science"
3
+
4
+ await Science.run({})
5
+
@@ -0,0 +1,18 @@
1
+
2
+ import {css} from "lit"
3
+ import {cssReset} from "@e280/sly"
4
+ export const basic = css`
5
+
6
+ ${cssReset}
7
+
8
+ :host {
9
+ display: block;
10
+ --bg: var(--shiny-bg, #111);
11
+ --alpha: var(--shiny-alpha, #afa);
12
+ --good: var(--shiny-good, #0f4);
13
+ --bad: var(--shiny-bad, #f40);
14
+ --invalid: var(--shiny-invalid, #8888);
15
+ }
16
+
17
+ `
18
+
@@ -0,0 +1,3 @@
1
+
2
+ export * from "./basic.css.js"
3
+
@@ -0,0 +1,3 @@
1
+
2
+ export * as themes from "./index.barrel.js"
3
+
@@ -0,0 +1,30 @@
1
+
2
+ export function untab(code: string) {
3
+ const lines = code.split(/\r|\n/)
4
+ let baseTabLevel: number | undefined
5
+
6
+ for (const line of lines) {
7
+ const isOnlyWhitespace = /^\s+$/.test(line)
8
+ if (!isOnlyWhitespace) {
9
+ const tabMatch = line.match(/^(\t+).+/)
10
+ if (tabMatch) {
11
+ const tabCount = tabMatch[1].length
12
+ baseTabLevel = baseTabLevel === undefined
13
+ ? tabCount
14
+ : tabCount < baseTabLevel
15
+ ? tabCount
16
+ : baseTabLevel
17
+ if (baseTabLevel === 0)
18
+ break
19
+ }
20
+ }
21
+ }
22
+
23
+ const rebaseTabRegex = new RegExp(`^\\t{${baseTabLevel}}`)
24
+
25
+ return lines
26
+ .map(line => /^\s+$/.test(line) ? "" : line)
27
+ .map(line => line.replace(rebaseTabRegex, ""))
28
+ .join("\n")
29
+ }
30
+
@@ -0,0 +1,9 @@
1
+
2
+ import {ShinyCopy} from "./copy/component.js"
3
+ import {ShinyExample} from "./example/component.js"
4
+
5
+ export const components = {
6
+ ShinyCopy,
7
+ ShinyExample,
8
+ }
9
+
@@ -0,0 +1,66 @@
1
+
2
+ import {debounce} from "@e280/stz"
3
+ import {dom, view} from "@e280/sly"
4
+
5
+ import {CSSResult, html} from "lit"
6
+ import styleCss from "./style.css.js"
7
+ import {ShinyElement} from "../framework.js"
8
+ import clipboardSvg from "../../icons/tabler/clipboard.svg.js"
9
+ import clipboardXFilledSvg from "../../icons/tabler/clipboard-x-filled.svg.js"
10
+ import clipboardCheckFilledSvg from "../../icons/tabler/clipboard-check-filled.svg.js"
11
+
12
+ export class ShinyCopy extends (
13
+ view(use => (theme: CSSResult, text: string | undefined, ms = 1000) => {
14
+ use.name("shiny-copy")
15
+ use.styles(theme, styleCss)
16
+
17
+ type Status = "neutral" | "good" | "bad" | "invalid"
18
+
19
+ const baseStatus = () => (
20
+ text === undefined
21
+ ? "invalid"
22
+ : "neutral"
23
+ )
24
+
25
+ const $status = use.signal<Status>(baseStatus())
26
+ const statusReset = use.once(() => debounce(ms, () => $status.set(baseStatus())))
27
+ const statusFlash = use.once(() => async(status: Status) => {
28
+ await $status.set(status)
29
+ await statusReset()
30
+ })
31
+
32
+ async function click() {
33
+ if (text === undefined) return
34
+ try {
35
+ await navigator.clipboard.writeText(text)
36
+ await statusFlash("good")
37
+ }
38
+ catch (error) {
39
+ console.error(error)
40
+ await statusFlash("bad")
41
+ }
42
+ }
43
+
44
+ const icon = (() => {switch ($status.get()) {
45
+ case "neutral": return clipboardSvg
46
+ case "invalid": return clipboardSvg
47
+ case "good": return clipboardCheckFilledSvg
48
+ case "bad": return clipboardXFilledSvg
49
+ default: throw new Error(`invalid copy status`)
50
+ }})()
51
+
52
+ return html`
53
+ <button data-status="${$status.get()}" @click="${click}">
54
+ ${icon}
55
+ </button>
56
+ `
57
+ })
58
+ .component(class extends ShinyElement {
59
+ attrs = dom.attrs(this).spec({
60
+ text: String,
61
+ ms: Number,
62
+ })
63
+ })
64
+ .props(el => [el.theme, el.attrs.text, el.attrs.ms])
65
+ ) {}
66
+