Skip to content

Commit

Permalink
Merge pull request #67 from reuters-graphics/storybook-7
Browse files Browse the repository at this point in the history
Upgrade Storybook to 7.0
  • Loading branch information
hobbes7878 authored Jun 10, 2023
2 parents 9a5a6d9 + 58d4d44 commit 9a243a8
Show file tree
Hide file tree
Showing 544 changed files with 10,386 additions and 56,572 deletions.
2 changes: 1 addition & 1 deletion .storybook/Theme.js → .storybook/Theme.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { create } from '@storybook/theming';
import { create } from '@storybook/theming/create';

export default create({
base: 'light',
Expand Down
43 changes: 0 additions & 43 deletions .storybook/main.cjs

This file was deleted.

17 changes: 17 additions & 0 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import type { StorybookConfig } from '@storybook/svelte-vite';

const config: StorybookConfig = {
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx|svelte)'],
addons: [
'@storybook/addon-links',
'@storybook/addon-essentials',
'@storybook/addon-interactions',
'@storybook/addon-svelte-csf',
],
framework: '@storybook/svelte-vite',
core: { disableTelemetry: true },
docs: {
autodocs: true,
},
};
export default config;
3 changes: 1 addition & 2 deletions .storybook/manager.js → .storybook/manager.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { addons } from '@storybook/addons';
import { addons } from '@storybook/manager-api';
import theme from './Theme';

addons.setConfig({
Expand All @@ -8,7 +8,6 @@ addons.setConfig({
panelPosition: 'bottom',
enableShortcuts: true,
showToolbar: true,
theme: undefined,
selectedPanel: undefined,
initialActive: 'sidebar',
sidebar: {
Expand Down
44 changes: 23 additions & 21 deletions .storybook/preview.scss
Original file line number Diff line number Diff line change
Expand Up @@ -39,31 +39,35 @@ div.sbdocs-content {
}
}

p.sbdocs-p, ul.sbdocs-ul, li.sbdocs-li {
font-size: 18px;
line-height: 29px;
.sbdocs {
@include font-display;

.highlight {
background-color: rgb(254, 254, 160);
padding: 0 4px;
}
.bold {
font-weight: bold;
h1 {
@include font-display;
}
}

a.sbdocs-a {
@include font-display;
color: $tr-muted-blue;
text-decoration: none;
&:hover {
text-decoration: underline;
p, ul, li {
font-size: 18px;
line-height: 29px;
@include font-display;

.highlight {
background-color: rgb(254, 254, 160);
padding: 0 4px;
}
.bold {
font-weight: bold;
}
}
}

.sbdocs {
@include font-display;
a {
@include font-display;
color: $tr-muted-blue;
text-decoration: none;
&:hover {
text-decoration: underline;
}
}

&:not(.sbdocs-preview) {
code {
Expand All @@ -88,8 +92,6 @@ a.sbdocs-a {
}
}



div.reset-article {
width: calc(100% + 30px);
margin-left: -15px;
Expand Down
2 changes: 1 addition & 1 deletion .storybook/preview.js → .storybook/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,4 @@ export const parameters = {
}
};

export const decorators = [() => ({ Component: Wrapper })];
export const decorators = [() => Wrapper];
2 changes: 1 addition & 1 deletion bin/buildPackage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import picomatch from 'picomatch';
import processOther from './process/other.js';
import processSvelte from './process/svelte.js';
import processTypescript from './process/typescript.js';
import rimraf from 'rimraf';
import { rimraf } from 'rimraf';

const require = createRequire(import.meta.url);

Expand Down
4 changes: 2 additions & 2 deletions bin/buildPackage/process/svelte.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { DIST, LIB } from './../locations.js';

import fs from 'fs-extra';
import path from 'path';
import preprocess from '../../preprocess/index.cjs';
import { preprocess as svelte } from 'svelte/compiler';
import { sveltePreprocess } from '../../preprocess/index.js';

const stripLangTags = (source) =>
source
Expand All @@ -13,7 +13,7 @@ const stripLangTags = (source) =>
export default async (file) => {
const filename = path.join(LIB, file);
let source = fs.readFileSync(filename, 'utf8');
source = (await svelte(source, preprocess.sveltePreprocess, { filename })).code
source = (await svelte(source, sveltePreprocess, { filename })).code
const writePath = path.join(DIST, file);
fs.ensureDirSync(path.dirname(writePath));
fs.writeFileSync(writePath, stripLangTags(source));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
// @ts-ignore
import SharkImg from './stories/shark.jpg';
const meta = {
title: 'Components/YourComponent',
component: YourComponent,
const metaProps = {
...withComponentDocs(componentDocs),
// https://storybook.js.org/docs/svelte/essentials/controls
argTypes: {
Expand All @@ -27,7 +25,11 @@
};
</script>

<Meta {...meta} />
<Meta
title='Components/YourComponent'
component={YourComponent}
{...metaProps}
/>

<Template let:args>
<YourComponent {...args} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

---

```svelte
```html
<script>
import { YourComponent } from '@reuters-graphics/graphics-components';
</script>
Expand Down
15 changes: 5 additions & 10 deletions bin/preprocess/index.cjs → bin/preprocess/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const autoprefixer = require('autoprefixer');
const preprocess = require('svelte-preprocess');
import autoprefixer from 'autoprefixer';
import preprocess from 'svelte-preprocess';

const scss = {
export const scss = {
includePaths: ['src/', 'node_modules/bootstrap/scss/'],
importer: [
(url) => {
if (/^\$lib/.test(url)){ return { file: `src/${url.replace('$lib', '')}` }; }
if (/^\$lib/.test(url)) { return { file: `src/${url.replace('$lib', '')}` }; }
// Redirect tilde-prefixed imports to node_modules
if (/^~/.test(url)) { return { file: `node_modules/${url.replace('~', '')}` }; }
return null;
Expand All @@ -14,16 +14,11 @@ const scss = {
quietDeps: true,
};

const sveltePreprocess = preprocess({
export const sveltePreprocess = preprocess({
preserve: ['ld+json'],
typescript: true,
scss,
postcss: {
plugins: [autoprefixer],
},
});

module.exports = {
scss,
sveltePreprocess
}
2 changes: 0 additions & 2 deletions docs/0.e90a374750c335ef9b52.manager.bundle.js

This file was deleted.

8 changes: 0 additions & 8 deletions docs/0.e90a374750c335ef9b52.manager.bundle.js.LICENSE.txt

This file was deleted.

1 change: 0 additions & 1 deletion docs/1.1d7ea4bae8cba34894e3.manager.bundle.js

This file was deleted.

2 changes: 0 additions & 2 deletions docs/5.cc0b259fd92705c30956.manager.bundle.js

This file was deleted.

31 changes: 0 additions & 31 deletions docs/5.cc0b259fd92705c30956.manager.bundle.js.LICENSE.txt

This file was deleted.

1 change: 0 additions & 1 deletion docs/6.df1051eafc33ea00df71.manager.bundle.js

This file was deleted.

1 change: 0 additions & 1 deletion docs/7.c98a4f665f9515fdf781.manager.bundle.js

This file was deleted.

2 changes: 0 additions & 2 deletions docs/8.45653ed03d608fc0ec24.manager.bundle.js

This file was deleted.

12 changes: 0 additions & 12 deletions docs/8.45653ed03d608fc0ec24.manager.bundle.js.LICENSE.txt

This file was deleted.

1 change: 0 additions & 1 deletion docs/9.42821f19fb40e6ca259a.manager.bundle.js

This file was deleted.

Loading

0 comments on commit 9a243a8

Please sign in to comment.