@storybook-tiny/webcomponent 1.1.2 → 1.1.4
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/bin/storybook-tiny.js +6 -1
- package/package.json +10 -8
- package/src/Storybook.js +35 -12
- package/src/Storybook.module.css +9 -9
package/bin/storybook-tiny.js
CHANGED
|
@@ -5,7 +5,12 @@ import { fileURLToPath } from 'url'
|
|
|
5
5
|
|
|
6
6
|
const config = {
|
|
7
7
|
rootDir: fileURLToPath(new URL('..', import.meta.url)),
|
|
8
|
-
devDependencies: [
|
|
8
|
+
devDependencies: [
|
|
9
|
+
'@storybook-tiny/webcomponent',
|
|
10
|
+
'mi-element',
|
|
11
|
+
'vite@^5',
|
|
12
|
+
'split.js@^1'
|
|
13
|
+
],
|
|
9
14
|
files: ['stories/*', 'vite.config.js'],
|
|
10
15
|
post: [
|
|
11
16
|
{
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook-tiny/webcomponent",
|
|
3
|
-
"version": "1.1.
|
|
4
|
-
"description": "A tiny storybook for
|
|
3
|
+
"version": "1.1.4",
|
|
4
|
+
"description": "A tiny storybook for web-components",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook",
|
|
7
7
|
"storybook-tiny",
|
|
8
|
-
"webcomponent"
|
|
8
|
+
"webcomponent",
|
|
9
|
+
"web-component"
|
|
9
10
|
],
|
|
10
11
|
"homepage": "https://github.com/commenthol/storybook-tiny/tree/main/packages/webcomponent#readme",
|
|
11
12
|
"bugs": {
|
|
@@ -33,14 +34,15 @@
|
|
|
33
34
|
"vite.config.js"
|
|
34
35
|
],
|
|
35
36
|
"dependencies": {
|
|
36
|
-
"mi-element": "^0.1
|
|
37
|
+
"mi-element": "^0.4.1",
|
|
38
|
+
"split.js": "^1.6.5",
|
|
37
39
|
"@storybook-tiny/setup": "1.0.1"
|
|
38
40
|
},
|
|
39
41
|
"devDependencies": {
|
|
40
|
-
"@eslint/js": "^9.
|
|
41
|
-
"eslint": "^9.
|
|
42
|
-
"globals": "^
|
|
43
|
-
"vite": "^
|
|
42
|
+
"@eslint/js": "^9.32.0",
|
|
43
|
+
"eslint": "^9.32.0",
|
|
44
|
+
"globals": "^16.3.0",
|
|
45
|
+
"vite": "^7.0.6"
|
|
44
46
|
},
|
|
45
47
|
"engines": {
|
|
46
48
|
"node": ">=20.0.0"
|
package/src/Storybook.js
CHANGED
|
@@ -1,17 +1,12 @@
|
|
|
1
1
|
import styles from './Storybook.module.css'
|
|
2
|
+
import split from 'split.js'
|
|
2
3
|
import { MiElement, define, refsBySelector, esc, refsById } from 'mi-element'
|
|
3
4
|
|
|
4
5
|
const getLocationHash = () => decodeURIComponent(location.hash.substring(1))
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
*
|
|
9
|
-
* @returns {string}
|
|
10
|
-
*/
|
|
11
|
-
const cssUnit = (unit) => {
|
|
12
|
-
const n = Number(unit)
|
|
13
|
-
return isNaN(n) ? unit : `${n}px`
|
|
14
|
-
}
|
|
7
|
+
const STORE_ITEM = 'tiny-storybook-x'
|
|
8
|
+
|
|
9
|
+
const getXperc = (px = 130) => (px * 100) / window.innerWidth
|
|
15
10
|
|
|
16
11
|
const defaultStory = `
|
|
17
12
|
<p class="${styles.storybookSectionP}">
|
|
@@ -41,17 +36,46 @@ class Storybook extends MiElement {
|
|
|
41
36
|
}
|
|
42
37
|
|
|
43
38
|
static template = `
|
|
39
|
+
<style>
|
|
40
|
+
.${styles.storybook} > .gutter {
|
|
41
|
+
background-color: #eee;
|
|
42
|
+
background-repeat: no-repeat;
|
|
43
|
+
background-position: 50%;
|
|
44
|
+
}
|
|
45
|
+
.${styles.storybook} > .gutter.gutter-horizontal {
|
|
46
|
+
background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAeCAYAAADkftS9AAAAIklEQVQoU2M4c+bMfxAGAgYYmwGrIIiDjrELjpo5aiZeMwF+yNnOs5KSvgAAAABJRU5ErkJggg==');
|
|
47
|
+
cursor: col-resize;
|
|
48
|
+
}
|
|
49
|
+
</style>
|
|
44
50
|
<main class="${styles.storybook}">
|
|
45
|
-
<aside>
|
|
51
|
+
<aside id="split-0">
|
|
46
52
|
<h4><a></a></h4>
|
|
47
53
|
<nav></nav>
|
|
48
54
|
</aside>
|
|
49
|
-
<section class="stories">
|
|
55
|
+
<section id="split-1" class="stories">
|
|
50
56
|
</section>
|
|
51
57
|
</main>
|
|
52
58
|
`
|
|
53
59
|
|
|
54
60
|
render() {
|
|
61
|
+
let xperc = getXperc()
|
|
62
|
+
try {
|
|
63
|
+
xperc = JSON.parse(localStorage.getItem(STORE_ITEM)) || xperc
|
|
64
|
+
if (isNaN(xperc)) {
|
|
65
|
+
xperc = getXperc()
|
|
66
|
+
}
|
|
67
|
+
} catch (_err) {
|
|
68
|
+
// noop
|
|
69
|
+
}
|
|
70
|
+
split(['#split-0', '#split-1'], {
|
|
71
|
+
sizes: [xperc, 100 - xperc],
|
|
72
|
+
minSize: 0,
|
|
73
|
+
gutterSize: 4,
|
|
74
|
+
onDragEnd: (sizes) => {
|
|
75
|
+
const [xperc] = sizes
|
|
76
|
+
localStorage.setItem(STORE_ITEM, xperc)
|
|
77
|
+
}
|
|
78
|
+
})
|
|
55
79
|
this.refs = refsBySelector(this.renderRoot, {
|
|
56
80
|
aside: 'main > aside',
|
|
57
81
|
h4: 'main > aside h4 a',
|
|
@@ -65,7 +89,6 @@ class Storybook extends MiElement {
|
|
|
65
89
|
const { refs } = this
|
|
66
90
|
refs.h4.textContent = this.header
|
|
67
91
|
refs.h4.href = this.href
|
|
68
|
-
refs.aside.style.flexBasis = cssUnit(this.width)
|
|
69
92
|
refs.nav.innerHTML = ''
|
|
70
93
|
for (const story of this.stories) {
|
|
71
94
|
const $el = document.createElement('storybook-tiny-story')
|
package/src/Storybook.module.css
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
.storybook {
|
|
2
2
|
font-family: Arial, Helvetica, sans-serif;
|
|
3
3
|
display: flex;
|
|
4
|
+
flex-direction: row;
|
|
4
5
|
}
|
|
5
6
|
|
|
6
|
-
.storybook>aside {
|
|
7
|
+
.storybook > aside {
|
|
7
8
|
border-right: 1px solid rgba(0, 0, 0, 0.1);
|
|
8
|
-
overflow-y:
|
|
9
|
+
overflow-y: hidden;
|
|
9
10
|
max-height: calc(100vh - 3em);
|
|
10
11
|
flex-grow: 0;
|
|
11
12
|
flex-shrink: 0;
|
|
12
|
-
flex-basis: 130px;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
.storybook>aside
|
|
15
|
+
.storybook > aside > * {
|
|
16
16
|
padding-left: 5px;
|
|
17
17
|
padding-right: 5px;
|
|
18
18
|
}
|
|
@@ -26,19 +26,19 @@
|
|
|
26
26
|
font-weight: bold;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
.storybook>aside>small {
|
|
29
|
+
.storybook > aside > small {
|
|
30
30
|
padding-top: 0.5em;
|
|
31
31
|
padding-bottom: 0.25em;
|
|
32
32
|
display: block;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
.storybook>aside>h4 {
|
|
35
|
+
.storybook > aside > h4 {
|
|
36
36
|
padding-top: 5px;
|
|
37
37
|
margin-top: 0;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
.storybook>aside>h4 a,
|
|
41
|
-
.storybook>aside>h4 a:visited {
|
|
40
|
+
.storybook > aside > h4 a,
|
|
41
|
+
.storybook > aside > h4 a:visited {
|
|
42
42
|
text-decoration: none;
|
|
43
43
|
color: unset;
|
|
44
44
|
}
|
|
@@ -60,4 +60,4 @@
|
|
|
60
60
|
.error {
|
|
61
61
|
padding: 0 1em 1em;
|
|
62
62
|
background-color: rgb(255, 0, 115, 0.1);
|
|
63
|
-
}
|
|
63
|
+
}
|