@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.
- package/LICENSE +22 -0
- package/README.md +10 -0
- package/package.json +62 -0
- package/s/demo/demo.bundle.ts +42 -0
- package/s/demo/demo.css +120 -0
- package/s/demo/views/demonstration/style.css.ts +108 -0
- package/s/demo/views/demonstration/view.ts +49 -0
- package/s/icons/tabler/ABOUT.md +7 -0
- package/s/icons/tabler/LICENSE +23 -0
- package/s/icons/tabler/clipboard-check-filled.svg.ts +4 -0
- package/s/icons/tabler/clipboard-x-filled.svg.ts +4 -0
- package/s/icons/tabler/clipboard.svg.ts +4 -0
- package/s/icons/tabler/copy.svg.ts +4 -0
- package/s/index.html.ts +37 -0
- package/s/index.ts +7 -0
- package/s/tests.test.ts +5 -0
- package/s/themes/basic.css.ts +18 -0
- package/s/themes/index.barrel.ts +3 -0
- package/s/themes/index.ts +3 -0
- package/s/tools/untab.ts +30 -0
- package/s/ui/components.ts +9 -0
- package/s/ui/copy/component.ts +66 -0
- package/s/ui/copy/style.css.ts +46 -0
- package/s/ui/example/component.ts +25 -0
- package/s/ui/example/style.css.ts +11 -0
- package/s/ui/framework.ts +8 -0
- package/s/ui/themers.ts +28 -0
- package/x/demo/demo.bundle.d.ts +1 -0
- package/x/demo/demo.bundle.js +37 -0
- package/x/demo/demo.bundle.js.map +1 -0
- package/x/demo/demo.bundle.min.js +277 -0
- package/x/demo/demo.bundle.min.js.map +7 -0
- package/x/demo/demo.css +120 -0
- package/x/demo/views/demonstration/style.css.d.ts +2 -0
- package/x/demo/views/demonstration/style.css.js +107 -0
- package/x/demo/views/demonstration/style.css.js.map +1 -0
- package/x/demo/views/demonstration/view.d.ts +10 -0
- package/x/demo/views/demonstration/view.js +36 -0
- package/x/demo/views/demonstration/view.js.map +1 -0
- package/x/icons/tabler/clipboard-check-filled.svg.d.ts +2 -0
- package/x/icons/tabler/clipboard-check-filled.svg.js +3 -0
- package/x/icons/tabler/clipboard-check-filled.svg.js.map +1 -0
- package/x/icons/tabler/clipboard-x-filled.svg.d.ts +2 -0
- package/x/icons/tabler/clipboard-x-filled.svg.js +3 -0
- package/x/icons/tabler/clipboard-x-filled.svg.js.map +1 -0
- package/x/icons/tabler/clipboard.svg.d.ts +2 -0
- package/x/icons/tabler/clipboard.svg.js +3 -0
- package/x/icons/tabler/clipboard.svg.js.map +1 -0
- package/x/icons/tabler/copy.svg.d.ts +2 -0
- package/x/icons/tabler/copy.svg.js +3 -0
- package/x/icons/tabler/copy.svg.js.map +1 -0
- package/x/index.d.ts +5 -0
- package/x/index.html +157 -0
- package/x/index.html.d.ts +2 -0
- package/x/index.html.js +33 -0
- package/x/index.html.js.map +1 -0
- package/x/index.js +6 -0
- package/x/index.js.map +1 -0
- package/x/tests.test.d.ts +1 -0
- package/x/tests.test.js +3 -0
- package/x/tests.test.js.map +1 -0
- package/x/themes/basic.css.d.ts +1 -0
- package/x/themes/basic.css.js +17 -0
- package/x/themes/basic.css.js.map +1 -0
- package/x/themes/index.barrel.d.ts +1 -0
- package/x/themes/index.barrel.js +2 -0
- package/x/themes/index.barrel.js.map +1 -0
- package/x/themes/index.d.ts +1 -0
- package/x/themes/index.js +2 -0
- package/x/themes/index.js.map +1 -0
- package/x/tools/untab.d.ts +1 -0
- package/x/tools/untab.js +26 -0
- package/x/tools/untab.js.map +1 -0
- package/x/ui/components.d.ts +6 -0
- package/x/ui/components.js +7 -0
- package/x/ui/components.js.map +1 -0
- package/x/ui/copy/component.d.ts +372 -0
- package/x/ui/copy/component.js +56 -0
- package/x/ui/copy/component.js.map +1 -0
- package/x/ui/copy/style.css.d.ts +2 -0
- package/x/ui/copy/style.css.js +45 -0
- package/x/ui/copy/style.css.js.map +1 -0
- package/x/ui/example/component.d.ts +371 -0
- package/x/ui/example/component.js +20 -0
- package/x/ui/example/component.js.map +1 -0
- package/x/ui/example/style.css.d.ts +2 -0
- package/x/ui/example/style.css.js +10 -0
- package/x/ui/example/style.css.js.map +1 -0
- package/x/ui/framework.d.ts +4 -0
- package/x/ui/framework.js +6 -0
- package/x/ui/framework.js.map +1 -0
- package/x/ui/themers.d.ts +8 -0
- package/x/ui/themers.js +12 -0
- 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
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
|
+
|
package/s/demo/demo.css
ADDED
|
@@ -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,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
|
+
|
package/s/index.html.ts
ADDED
|
@@ -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
package/s/tests.test.ts
ADDED
|
@@ -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
|
+
|
package/s/tools/untab.ts
ADDED
|
@@ -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,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
|
+
|