@storybook-tiny/webcomponent 1.1.4 → 1.2.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.
@@ -7,8 +7,8 @@ const config = {
7
7
  rootDir: fileURLToPath(new URL('..', import.meta.url)),
8
8
  devDependencies: [
9
9
  '@storybook-tiny/webcomponent',
10
- 'mi-element',
11
- 'vite@^5',
10
+ 'mi-element@0.7.x',
11
+ 'vite',
12
12
  'split.js@^1'
13
13
  ],
14
14
  files: ['stories/*', 'vite.config.js'],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook-tiny/webcomponent",
3
- "version": "1.1.4",
3
+ "version": "1.2.0",
4
4
  "description": "A tiny storybook for web-components",
5
5
  "keywords": [
6
6
  "storybook",
@@ -34,15 +34,15 @@
34
34
  "vite.config.js"
35
35
  ],
36
36
  "dependencies": {
37
- "mi-element": "^0.4.1",
37
+ "mi-element": "^0.7.0",
38
38
  "split.js": "^1.6.5",
39
- "@storybook-tiny/setup": "1.0.1"
39
+ "@storybook-tiny/setup": "1.0.2"
40
40
  },
41
41
  "devDependencies": {
42
- "@eslint/js": "^9.32.0",
43
- "eslint": "^9.32.0",
44
- "globals": "^16.3.0",
45
- "vite": "^7.0.6"
42
+ "@eslint/js": "^9.39.2",
43
+ "eslint": "^9.39.2",
44
+ "globals": "^16.5.0",
45
+ "vite": "^7.3.0"
46
46
  },
47
47
  "engines": {
48
48
  "node": ">=20.0.0"
package/src/Storybook.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import styles from './Storybook.module.css'
2
2
  import split from 'split.js'
3
- import { MiElement, define, refsBySelector, esc, refsById } from 'mi-element'
3
+ import { MiElement, define, html } from 'mi-element'
4
4
 
5
5
  const getLocationHash = () => decodeURIComponent(location.hash.substring(1))
6
6
 
@@ -8,34 +8,34 @@ const STORE_ITEM = 'tiny-storybook-x'
8
8
 
9
9
  const getXperc = (px = 130) => (px * 100) / window.innerWidth
10
10
 
11
- const defaultStory = `
12
- <p class="${styles.storybookSectionP}">
13
- The tiny storybook for
14
- <a
15
- href="https://developer.mozilla.org/en-US/docs/Web/API/Web_components"
16
- target="_blanc"
17
- rel="norel noreferrer"
18
- >
19
- webcomponents
20
- </a>
21
- </p>
11
+ const defaultStory = html`
12
+ <p class="${styles.storybookSectionP}">
13
+ The tiny storybook for
14
+ <a
15
+ href="https://developer.mozilla.org/en-US/docs/Web/API/Web_components"
16
+ target="_blanc"
17
+ rel="norel noreferrer"
18
+ >
19
+ Web Components
20
+ </a>
21
+ </p>
22
22
  `
23
23
 
24
24
  class Storybook extends MiElement {
25
25
  state = {}
26
26
 
27
- static shadowRootOptions = null
27
+ static shadowRootInit = null
28
28
 
29
- static get attributes() {
29
+ static get properties() {
30
30
  return {
31
- header: 'Storybook Tiny',
32
- href: '/stories/index.html',
33
- width: 130,
34
- stories: []
31
+ header: { initial: 'Storybook Tiny' },
32
+ href: { initial: '/stories/index.html' },
33
+ width: { initial: 130, type: Number },
34
+ stories: { initial: [], attribute: false }
35
35
  }
36
36
  }
37
37
 
38
- static template = `
38
+ static template = html`
39
39
  <style>
40
40
  .${styles.storybook} > .gutter {
41
41
  background-color: #eee;
@@ -76,7 +76,7 @@ class Storybook extends MiElement {
76
76
  localStorage.setItem(STORE_ITEM, xperc)
77
77
  }
78
78
  })
79
- this.refs = refsBySelector(this.renderRoot, {
79
+ this.refs = this.refsBySelector({
80
80
  aside: 'main > aside',
81
81
  h4: 'main > aside h4 a',
82
82
  nav: 'main > aside nav',
@@ -127,11 +127,11 @@ class Storybook extends MiElement {
127
127
  // try rendering the story
128
128
  refs.story.innerHTML = ''
129
129
  try {
130
- switch (typeof renderStory) {
131
- case 'string':
130
+ switch (toString.call(renderStory).slice(8, -1)) {
131
+ case 'String':
132
132
  refs.story.innerHTML = renderStory
133
133
  break
134
- case 'function':
134
+ case 'Function':
135
135
  refs.story.appendChild(renderStory())
136
136
  break
137
137
  default:
@@ -152,12 +152,12 @@ class Storybook extends MiElement {
152
152
  define('storybook-tiny', Storybook)
153
153
 
154
154
  class Story extends MiElement {
155
- static shadowRootOptions = null
155
+ static shadowRootInit = null
156
156
 
157
- static get attributes() {
157
+ static get properties() {
158
158
  return {
159
- active: false,
160
- story: ''
159
+ active: { initial: false, type: Boolean },
160
+ story: { initial: '' }
161
161
  }
162
162
  }
163
163
 
@@ -169,10 +169,10 @@ class Story extends MiElement {
169
169
 
170
170
  const { title } = this.story
171
171
 
172
- this.renderRoot.innerHTML = esc`
173
- <div>
174
- <a href="#${title}">${title}</a>
175
- </div>
172
+ this.renderRoot.innerHTML = html`
173
+ <div>
174
+ <a href="#${title}">${title}</a>
175
+ </div>
176
176
  `
177
177
  this.refs = { a: this.querySelector('a') }
178
178
  this.refs.a.className = this.active ? styles.active : ''
@@ -182,10 +182,13 @@ class Story extends MiElement {
182
182
  define('storybook-tiny-story', Story)
183
183
 
184
184
  class StoryError extends MiElement {
185
- static shadowRootOptions = null
185
+ static shadowRootInit = null
186
186
 
187
- static get attributes() {
188
- return { message: '', stack: '' }
187
+ static get properties() {
188
+ return {
189
+ message: { initial: '' },
190
+ stack: { initial: '' }
191
+ }
189
192
  }
190
193
 
191
194
  static template = `
@@ -198,7 +201,10 @@ class StoryError extends MiElement {
198
201
  `
199
202
 
200
203
  render() {
201
- this.refs = refsById(this.renderRoot)
204
+ this.refs = this.refsBySelector({
205
+ message: '#message',
206
+ stack: '#stack'
207
+ })
202
208
  }
203
209
 
204
210
  update() {
@@ -3,7 +3,7 @@ import {
3
3
  storyButton,
4
4
  storyCounter,
5
5
  storyError
6
- } from './some.stories'
6
+ } from './some.stories.js'
7
7
 
8
8
  const storybook = document.createElement('storybook-tiny')
9
9
  storybook.stories = [