Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Look mom no storybook #2654

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 25 additions & 14 deletions apps/preact/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,25 @@
<meta charset="utf-8" />
<title>React component library</title>
<link rel="stylesheet" href="node_modules/@utrecht/design-tokens/dist/theme.css" />
<style>
.example-story-canvas {
background-color: white;
border-radius: 4px;
border-width: 1px;
border-style: solid;
border-color: rgba(0, 0, 0, 0.1);
box-shadow: rgba(0, 0, 0, 0.1) 0px 1px 3px 0px;
margin-block-end: 40px;
margin-block-start: 25px;
padding-block-end: 30px;
padding-block-start: 30px;
padding-inline-end: 20px;
padding-inline-start: 20px;
position: relative;
}
</style>
</head>
<body>
<h1>React components rendered with Preact</h1>
<p>This example uses ES Modules and import maps.</p>
<div id="root"></div>
<script type="importmap">
{
"imports": {
Expand Down Expand Up @@ -64,6 +78,10 @@ <h1>React components rendered with Preact</h1>
"@utrecht/select-combobox-react/dist/css": "./node_modules/@utrecht/component-library-react/node_modules/@utrecht/select-combobox-react/dist/css.mjs",
"@utrecht/textbox-react": "./node_modules/@utrecht/component-library-react/node_modules/@utrecht/textbox-react/dist/index.mjs",
"@utrecht/textbox-react/dist/css": "./node_modules/@utrecht/component-library-react/node_modules/@utrecht/textbox-react/dist/css.mjs",
"@utrecht/storybook-react/": "./node_modules/@utrecht/storybook-react/",
"@utrecht/button-css/": "./node_modules/@utrecht/button-css/",
"@utrecht/design-tokens/": "./node_modules/@utrecht/design-tokens/",
"@utrecht/icon/": "./node_modules/@utrecht/icon/",
"clsx": "./node_modules/@utrecht/button-react/node_modules/clsx/dist/clsx.mjs",
"preact": "./node_modules/preact/dist/preact.mjs",
"preact/compat": "./node_modules/preact/compat/dist/compat.mjs",
Expand All @@ -73,16 +91,9 @@ <h1>React components rendered with Preact</h1>
}
}
</script>
<script type="module">
import { render, createElement } from 'preact';
import { Button } from '@utrecht/button-react/dist/css';
import { Separator } from '@utrecht/component-library-react/dist/css-module';
(async () => {
const root = document.getElementById('root');
if (root) {
render(createElement(Button, { children: 'Click me!', appearance: 'primary-action-button' }), root);
}
})();
</script>
<script type="module" src="story-react.mjs"></script>

<h1>Look no Storybook!</h1>
<story-list-react src="@utrecht/storybook-react/dist/src/stories/Button.stories.js"></story-react>
</body>
</html>
3 changes: 3 additions & 0 deletions apps/preact/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@
"start": "http-server ."
},
"dependencies": {
"@utrecht/storybook-react": "workspace:*",
"@utrecht/button-css": "workspace:*",
"@utrecht/button-react": "workspace:*",
"@utrecht/component-library-react": "workspace:*",
"@utrecht/design-tokens": "workspace:*",
"@utrecht/icon": "workspace:*",
"preact": "10.24.3"
},
"devDependencies": {
Expand Down
78 changes: 78 additions & 0 deletions apps/preact/story-react.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import { render, createElement } from 'preact';
import { Button } from '@utrecht/button-react/dist/css';
import * as ButtonStories from '@utrecht/storybook-react/dist/src/stories/Button.stories.js';
// import { Separator } from '@utrecht/component-library-react/dist/css-module';

customElements.define(
'story-react',
class StoryReact extends HTMLElement {
constructor() {
super();
const style = this.ownerDocument.createElement('style');
style.textContent = `
.example-story-canvas {
background-color: white;
border-radius: 4px;
border-width: 1px;
border-style: solid;
border-color: rgba(0, 0, 0, 0.1);
box-shadow: rgba(0, 0, 0, 0.1) 0px 1px 3px 0px;
margin-block-end: 40px;
margin-block-start: 25px;
padding-block-end: 30px;
padding-block-start: 30px;
padding-inline-end: 20px;
padding-inline-start: 20px;
position: relative;
}`;
const shadow = this.attachShadow({ mode: 'closed' });
shadow.appendChild(style);
const div = this.ownerDocument.createElement('div');
div.className = 'example-story-canvas';
div.appendChild(this.ownerDocument.createElement('slot'));
shadow.appendChild(div);
}
},
);

customElements.define(
'story-list-react',
class StoryReact extends HTMLElement {
constructor() {
super();
import(this.getAttribute('src')).then((stories) => {
const Component = stories.default.component;
const defaultArgs = stories.default.args;
this.stories = stories;
this.Component = Component;
this.defaultArgs = defaultArgs;
this.render();
});
}
render() {
const { Component, stories, defaultArgs } = this;
// Remove current rendering
while (this.lastChild) {
this.removeChild(this.lastChild);
}

// Render new version
render(
createElement('div', {
children: Object.entries(stories)
.filter(([name]) => name !== 'default')
.map(([name, storyObj]) => [
createElement('h2', { children: name }),
createElement('story-react', {
children: createElement(Component, {
...defaultArgs,
...storyObj.args,
}),
}),
]),
}),
this,
);
}
},
);
3 changes: 2 additions & 1 deletion packages/components-react/body-react/tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"extends": "./tsconfig.json",
"compilerOptions": {
"composite": true
}
},
"include": ["config/**/*.ts", "config/**/*.tsx"]
}
4 changes: 4 additions & 0 deletions packages/storybook-react/log
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

> @utrecht/storybook-react@0.0.0 build:ts /Users/bobby/Sites/github.com/nl-design-system/utrecht-npm/packages/storybook-react
> tsc --project tsconfig.build.json

1 change: 1 addition & 0 deletions packages/storybook-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
},
"scripts": {
"build": "storybook build --output-dir dist/ --config-dir config/ --quiet",
"build:ts": "tsc --project tsconfig.build.json",
"clean": "rimraf dist/",
"lint-build:todo": "tsc --noEmit --project tsconfig.json",
"start": "http-server dist/",
Expand Down
13 changes: 7 additions & 6 deletions packages/storybook-react/src/stories/Button.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import { Meta, StoryObj } from '@storybook/react';
import readme from '@utrecht/button-css/README.md?raw';
// import readme from '@utrecht/button-css/README.md?raw';
import tokensDefinition from '@utrecht/button-css/dist/tokens.mjs';
import { Button, ButtonProps } from '@utrecht/button-react/dist/css';
import { Button, ButtonProps } from '@utrecht/button-react';
import tokens from '@utrecht/design-tokens/dist/list.mjs';
import iconSet from '@utrecht/icon/dist/iconset.mjs';
import React from 'react';
import { designTokenStory } from './util.js';
import type { PropsWithChildren } from 'react';
// import { designTokenStory } from './util.js';
const readme = '';

interface ButtonStoryProps extends ButtonProps {
icon?: string;
}

const ButtonStory = ({ children, icon, ...props }: ButtonStoryProps) => {
const ButtonStory = ({ children, icon, ...props }: PropsWithChildren<ButtonStoryProps>) => {
const IconElement = icon;
return (
<Button icon={IconElement ? <IconElement /> : null} {...props}>
Expand Down Expand Up @@ -356,4 +357,4 @@ export const SubtleFocusVisible: Story = {
},
};

export const DesignTokens = designTokenStory(meta);
// export const DesignTokens = designTokenStory(meta);
9 changes: 9 additions & 0 deletions packages/storybook-react/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "dist/",
"strict": false,
"composite": true
},
"include": ["src/**/stories/Button.stories.tsx", "src/**/util.tsx"]
}
5 changes: 3 additions & 2 deletions packages/storybook-react/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
"jsx": "react-jsx",
"skipLibCheck": true,
"moduleResolution": "nodenext",
"module": "NodeNext"
"module": "NodeNext",
"outDir": "dist"
},
"extends": "../../tsconfig.json",
"include": ["config/**/*.ts", "config/**/*.tsx", "src/**/*.ts", "src/**/*.tsx"],
"include": ["src/**/*.ts", "src/**/*.tsx"],
"exclude": ["**/node_modules/*"]
}
73 changes: 73 additions & 0 deletions packages/web-component-library-stencil/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,55 @@
<utrecht-logo>
<utrecht-link href="#"> <utrecht-logo-image></utrecht-logo-image></utrecht-link>
</utrecht-logo>
<div>
<utrecht-heading-2>Popover button</utrecht-heading-2>
<utrecht-button popovertarget="popover-example-1">Toggle popover button</utrecht-button>
<utrecht-button popovertarget="popover-example-1" popovertargetaction="hide"
>Hide popover button</utrecht-button
>
<utrecht-button popovertarget="popover-example-1" popovertargetaction="show"
>Show popover button</utrecht-button
>
<div popover id="popover-example-1">
<utrecht-heading-3>Popover 1</utrecht-heading-3>
<utrecht-paragraph>Hello, world!</utrecht-paragraph>
</div>
</div>
<div>
<utrecht-heading-2>Popover link button</utrecht-heading-2>
<utrecht-link-button popovertarget="popover-example-2">Toggle popover link button</utrecht-link-button>
<utrecht-link-button popovertarget="popover-example-2" popovertargetaction="hide"
>Hide popover button</utrecht-link-button
>
<utrecht-link-button popovertarget="popover-example-2" popovertargetaction="show"
>Show popover button</utrecht-link-button
>
<div popover id="popover-example-2">
<utrecht-heading-3>Popover 2</utrecht-heading-3>
<utrecht-paragraph>Hello, world!</utrecht-paragraph>
</div>
</div>
<form>
<utrecht-button-group direction="column">
<utrecht-button type="submit" formaction="/" formmethod="delete">DELETE /delete/</utrecht-button>
<utrecht-button type="submit" formaction="/" formmethod="post">POST /post/</utrecht-button>
<utrecht-button type="submit" formaction="/" formmethod="get">GET /get/</utrecht-button>
<utrecht-button type="submit" formaction="/" formmethod="post" formtarget="_new"
>GET /get/ in new window</utrecht-button
></utrecht-button-group
>
<utrecht-button-group direction="column">
<utrecht-link-button type="submit" formaction="/" formmethod="delete"
>DELETE /delete/</utrecht-link-button
>
<utrecht-link-button type="submit" formaction="/" formmethod="post">POST /post/</utrecht-link-button>
<utrecht-link-button type="submit" formaction="/" formmethod="get">GET /get/</utrecht-link-button>
<utrecht-link-button type="submit" formaction="/" formmethod="post" formtarget="_new"
>GET /get/ in new window</utrecht-link-button
></utrecht-button-group
>
</form>

<utrecht-flex-wrap-fallback flextarget="main-nav">
<div class="menu" id="main-nav">
<div><a href="">Home</a></div>
Expand Down Expand Up @@ -97,6 +146,9 @@
label="Password"
>
</utrecht-form-field-textbox>
<utrecht-textarea cols="20"></utrecht-textarea>
<utrecht-textarea cols="20"></utrecht-textarea>
<utrecht-textarea cols="21"></utrecht-textarea>
<utrecht-form-field-textbox
type="password"
name="password"
Expand Down Expand Up @@ -205,6 +257,27 @@
<utrecht-heading-1>Heading 1: The Quick Brown Fox Jumps Over The Lazy Dog</utrecht-heading-1>
<utrecht-pre-heading>Pre-heading: The Quick Brown Fox Jumps Over The Lazy Dog</utrecht-pre-heading>
</utrecht-heading-group>
<utrecht-heading-group>
<utrecht-heading-2>Heading 2: The Quick Brown Fox Jumps Over The Lazy Dog</utrecht-heading-2>
<utrecht-pre-heading>Pre-heading: The Quick Brown Fox Jumps Over The Lazy Dog</utrecht-pre-heading>
</utrecht-heading-group>
<utrecht-heading-group>
<utrecht-heading-3>Heading 3: The Quick Brown Fox Jumps Over The Lazy Dog</utrecht-heading-3>
<utrecht-pre-heading>Pre-heading: The Quick Brown Fox Jumps Over The Lazy Dog</utrecht-pre-heading>
</utrecht-heading-group>
<utrecht-heading-group>
<utrecht-heading-4>Heading 4: The Quick Brown Fox Jumps Over The Lazy Dog</utrecht-heading-4>
<utrecht-pre-heading>Pre-heading: The Quick Brown Fox Jumps Over The Lazy Dog</utrecht-pre-heading>
</utrecht-heading-group>
<utrecht-heading-group>
<utrecht-heading-5>Heading 5: The Quick Brown Fox Jumps Over The Lazy Dog</utrecht-heading-5>
<utrecht-pre-heading>Pre-heading: The Quick Brown Fox Jumps Over The Lazy Dog</utrecht-pre-heading>
</utrecht-heading-group>
<utrecht-heading-group>
<utrecht-heading-6>Heading 6: The Quick Brown Fox Jumps Over The Lazy Dog</utrecht-heading-6>
<utrecht-pre-heading>Pre-heading: The Quick Brown Fox Jumps Over The Lazy Dog</utrecht-pre-heading>
</utrecht-heading-group>
<utrecht-heading-1>Heading 1: The Quick Brown Fox Jumps Over The Lazy Dog</utrecht-heading-1>
<utrecht-heading-2>Heading 2: The Quick Brown Fox Jumps Over The Lazy Dog</utrecht-heading-2>
<utrecht-heading level="2">Heading 2: The Quick Brown Fox Jumps Over The Lazy Dog</utrecht-heading>
<utrecht-heading-3>Heading 3: The Quick Brown Fox Jumps Over The Lazy Dog</utrecht-heading-3>
Expand Down
9 changes: 9 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading