Skip to content

Commit 8e7b851

Browse files
JesmoDeviOvergaard
andauthored
deps(Storybook): Storybook 8 Upgrade (#889)
* remove storybook * install storybook 8 * add umbraco text styling * Fix form control mixin * add new web component analyzer * add custom elements * add autodocs * cleanup button * button stories * fix preview * css classes * add spread directive * more button stories * add size story * more button stories * button story * action bar stories * add folder * avatar stories * simple import * avatar group * exclude decorators from source * badge wip * fix icon registry setup * fix badge attention type * remove unused import * badge stories * formcontrolmixin mdx * add id * uui box wip * fix web component formatter * uui box * breadcrumbs * button group * button group * inline button create * uui card wip * go back to old component analyzer * remove events from spread directive * uui card * card block type * renderSlots helper * content node card * card media * card user * caret * filter out slots * js docs * add slot to slot names * add rendering slots from args in renderSlots * cleanup and update render slots to add newlines in the start and after slots * checkbox init * checkbox * Prevent false positives in renderSlots * Prevent false positives in spread * color area * color picker * color slider * add event to all event names to prevent them from overriding properties with same name * color swatch * color swatches * fix jsdocs types * fix ts configs * combobox init * combobox wip * auto format source * combobox * combobox list * dialog and dialog layout * file dropzone * file preview * revert pristine changes in formcontrolmixin * form * form layout * add missing import * form validation message * icon * icon registry mdx * icon registry essential * icon registry essential * input * input file * input lock * input password * render slots * shortcuts * label * loaders * menu item * modal * pagination * popover * popover container * progress bar * radio * range slider * ref * ref * ref list * ref node * ref node data type * ref node document type * ref node form * ref node member * ref node package * ref node user * scroll container * select * slider * symbol expand * symbol file dropzone * symbol file thumbnail * symbol file * symbol folder * symbol lock * symbol more * symbol sort * table * table row * table cell * clean * tabs * tag * textarea * toast notification * toast notification container * toast notification layout * toggle * visually hidden * css * css stuff * add readme * add readme * use old package lock * fix package.json * cleanup * fix lint for storybook * add theme * combine new and old mdx (remove new part of name) * add stories from stories folder * include the stories * fix padding * update to storybook 8.3.5 * add missing readonly story * add missing import * add a11y addon * fix: override lit version * fix uui icon build * chore: npm dedupe * update button stories * chore: mark property as readonly * build(deps-dev): update chromatic to 11.12.5 * chore: remove old story files * chore: rename stories to .story * chore: use .story.ts files * chore: correct imports to .story.ts * feat: update theme * docs: include 'images' in storybook output * chore: remove uncommented code * update packageManager field --------- Co-authored-by: Jacob Overgaard <[email protected]>
1 parent 4d296a4 commit 8e7b851

File tree

119 files changed

+16882
-29434
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+16882
-29434
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,5 @@ out-css
3838

3939
# old source
4040
/src
41+
42+
*storybook.log

.storybook/main.js

-72
This file was deleted.

.storybook/main.ts

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import type { StorybookConfig } from '@storybook/web-components-vite';
2+
import { html } from 'lit';
3+
import { join, dirname } from 'path';
4+
5+
/**
6+
* This function is used to resolve the absolute path of a package.
7+
* It is needed in projects that use Yarn PnP or are set up within a monorepo.
8+
*/
9+
function getAbsolutePath(value: string): any {
10+
return dirname(require.resolve(join(value, 'package.json')));
11+
}
12+
13+
const config: StorybookConfig = {
14+
stories: [
15+
'../packages/**/*.mdx',
16+
'../packages/**/*.story.@(js|jsx|mjs|ts|tsx)',
17+
'../stories/**/*.story.@(js|jsx|mjs|ts|tsx)',
18+
],
19+
staticDirs: ['./images'],
20+
addons: [
21+
getAbsolutePath('@storybook/addon-links'),
22+
getAbsolutePath('@storybook/addon-essentials'),
23+
getAbsolutePath('@chromatic-com/storybook'),
24+
getAbsolutePath('@storybook/addon-a11y'),
25+
'../storyhelpers/storybook-readme',
26+
],
27+
framework: {
28+
name: getAbsolutePath('@storybook/web-components-vite'),
29+
options: {},
30+
},
31+
};
32+
export default config;

.storybook/manager.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { addons } from '@storybook/addons';
1+
import { addons } from '@storybook/manager-api';
22
import umbracoTheme from './umbraco-theme';
33

44
addons.setConfig({

.storybook/preview-body.html

-4
This file was deleted.

.storybook/preview-head.html

-51
This file was deleted.
+38-35
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,41 @@
1+
import {
2+
setCustomElementsManifest,
3+
type Preview,
4+
} from '@storybook/web-components';
15
import '../packages/uui-css/lib/uui-css.css';
2-
import 'element-internals-polyfill';
3-
4-
import { setCustomElements } from '@storybook/web-components';
5-
66
import customElements from '../custom-elements.json';
7+
import { html } from 'lit';
78

8-
export const parameters = {
9-
layout: 'padded',
10-
actions: { argTypesRegex: '^on[A-Z].*' },
11-
controls: {
12-
matchers: {
13-
color: /(background|color)/i,
14-
date: /Date$/,
9+
import '@umbraco-ui/uui-icon-registry-essential/lib';
10+
11+
const preview: Preview = {
12+
parameters: {
13+
controls: {
14+
matchers: {
15+
color: /(background|color)$/i,
16+
date: /Date$/i,
17+
},
1518
},
16-
},
17-
docs: {
18-
source: { state: 'open' },
19-
},
20-
options: {
21-
method: 'alphabetical',
22-
storySort: (a, b) => {
23-
//NOTE: This has to be an inline function for some reason
24-
if (a.title === 'Overview') {
25-
return 0;
26-
}
27-
if (b.title === 'Overview') {
28-
return 1;
29-
}
30-
return a.title > b.title;
19+
docs: {
20+
source: {
21+
excludeDecorators: true,
22+
format: 'html', // see storybook docs for more info on this format https://storybook.js.org/docs/api/doc-blocks/doc-block-source#format
23+
},
3124
},
3225
},
26+
tags: ['autodocs'],
27+
28+
decorators: [
29+
story => {
30+
return html`<uui-icon-registry-essential class="uui-font uui-text"
31+
>${story()}</uui-icon-registry-essential
32+
>`;
33+
},
34+
],
3335
};
3436

3537
WebComponentFormatter(customElements);
36-
37-
setCustomElements(customElements);
38+
setCustomElementsManifest(customElements);
3839

3940
function WebComponentFormatter(customElements) {
4041
for (let tag of customElements.tags || []) {
@@ -59,19 +60,19 @@ function WebComponentFormatter(customElements) {
5960
}
6061
}
6162

62-
// Find all names of properties
63-
const propertyNames = (tag.properties || []).map(p => p.name);
63+
// add 'Event' to the name of all events
64+
for (let event of tag.events || []) {
65+
event.name = `${event.name} event`;
66+
}
6467

6568
// Run through all slots to clean them up a bit
6669
for (let slot of tag.slots || []) {
6770
// Replace the name of the default slot so Storybook will show it
6871
if (typeof slot.name === 'string' && slot.name.length === 0) {
6972
slot.name = 'slot';
70-
}
71-
72-
// If the slot has the same name as a property, then add the word 'slot' to the name
73-
// Bug reported to Storybook here: https://github.com/storybookjs/storybook/issues/17733
74-
if (propertyNames.includes(slot.name)) {
73+
} else {
74+
// Add slot to the name. This will allow us to filter out slots in various situations. Example the spread directive.
75+
// Bug reported to Storybook here: https://github.com/storybookjs/storybook/issues/17733
7576
slot.name = `${slot.name} slot`;
7677
}
7778

@@ -84,3 +85,5 @@ function WebComponentFormatter(customElements) {
8485

8586
return customElements;
8687
}
88+
89+
export default preview;

.storybook/umbraco-theme.js

+2-27
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

eslint.config.mjs

+6-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,12 @@ export default [
2626
// Global ignores
2727
includeIgnoreFile(gitignorePath),
2828
{
29-
ignores: ['**/*.{cjs,mjs,js}', 'vite.config.ts', 'stories/'],
29+
ignores: [
30+
'**/*.{cjs,mjs,js}',
31+
'vite.config.ts',
32+
'stories/',
33+
'**/.storybook/**',
34+
],
3035
},
3136

3237
// Global config

0 commit comments

Comments
 (0)