Skip to content

Commit

Permalink
fix(ui): init commit
Browse files Browse the repository at this point in the history
  • Loading branch information
waldronmatt committed Oct 10, 2023
1 parent dcf2fd5 commit 070c562
Show file tree
Hide file tree
Showing 11 changed files with 242 additions and 0 deletions.
11 changes: 11 additions & 0 deletions docs/ui/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = {
root: true,
extends: ['custom/storybook.cjs'],
ignorePatterns: ['dist/**'],
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
project: ['tsconfig.eslint.json'],
tsconfigRootDir: __dirname,
},
};
26 changes: 26 additions & 0 deletions docs/ui/.storybook/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { dirname, join, resolve } from 'path';

function getAbsolutePath(value) {
return dirname(require.resolve(join(value, 'package.json')));
}

const config = {
stories: ['../stories/*.mdx', '../stories/*.stories.tsx', '../stories/**/*.stories.tsx'],
addons: [
getAbsolutePath('@storybook/addon-links'),
getAbsolutePath('@storybook/addon-essentials'),
getAbsolutePath('@storybook/addon-docs'),
],
framework: {
name: getAbsolutePath('@storybook/react-vite'),
options: {},
},

core: {},

docs: {
autodocs: true,
},
};

export default config;
5 changes: 5 additions & 0 deletions docs/ui/.storybook/preview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// reset/normalize styles
import 'the-new-css-reset/css/reset.css';
import 'sanitize.css';
// global css variable tokens
import '@waldronmatt/demo-ui/lib/styles/global.css';
21 changes: 21 additions & 0 deletions docs/ui/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Matthew Waldron

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
7 changes: 7 additions & 0 deletions docs/ui/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Demo UI Storybook

Demo UI Storybook repo.

## License

MIT
39 changes: 39 additions & 0 deletions docs/ui/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"name": "demo-ui-storybook",
"version": "1.0.0",
"private": true,
"type": "module",
"scripts": {
"dev": "storybook dev -p 6006",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"build": "storybook build --docs",
"clean": "rimraf storybook-static",
"preview": "serve storybook-static"
},
"dependencies": {
"@waldronmatt/demo-ui": "workspace:^",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"sanitize.css": "^13.0.0",
"the-new-css-reset": "^1.11.0"
},
"devDependencies": {
"@storybook/addon-actions": "^7.4.0",
"@storybook/addon-docs": "^7.4.0",
"@storybook/addon-essentials": "^7.4.0",
"@storybook/addon-links": "^7.4.0",
"@storybook/react": "^7.4.0",
"@storybook/react-vite": "^7.4.0",
"@storybook/types": "^7.4.6",
"@types/react": "^18.2.15",
"@types/react-dom": "^18.2.7",
"@vitejs/plugin-react": "^1.3.2",
"eslint-config-custom": "workspace:^",
"rimraf": "^3.0.2",
"serve": "^13.0.4",
"storybook": "^7.4.0",
"tsconfig-config": "workspace:^",
"typescript": "^5.2.2",
"vite": "^4.4.5"
}
}
28 changes: 28 additions & 0 deletions docs/ui/stories/Intro.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Demo UI Components

Welcome to the Demo UI Component Library.

## Installation

Install dependencies:

`pnpm add @waldronmatt/demo-ui`

## Getting Started

Used named imports to enable `js` and `css` treeshaking:

```
import '@waldronmatt/demo-ui/styles/global.css';
import { Button } from '@waldronmatt/demo-ui';
function App() {
return (
<>
<Button>Hello</Button>
</>
);
}
export default App;
```
45 changes: 45 additions & 0 deletions docs/ui/stories/button.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import type { Meta, StoryFn } from '@storybook/react';
// we use `lib/` paths so we can get source files and have storybook
// auto refresh (hmr) whenever we update our component source files
import { Button } from '@waldronmatt/demo-ui/lib/components/Button/index.js';
import type { ButtonProps } from '@waldronmatt/demo-ui/lib/components/Button/index.js';

const defaultProps = {
children: 'Hello World',
};

const meta: Meta<typeof Button> = {
title: 'Components/Button',
component: Button,
argTypes: {
variant: {
options: ['md', 'sm', 'lg'],
control: { type: 'radio' },
},
},
};

export default meta;

const Template: StoryFn<typeof Button> = (args: ButtonProps) => {
return <Button {...args}></Button>;
};

export const Default = Template.bind({});
export const Small = Template.bind({});
export const Large = Template.bind({});

Default.args = {
...defaultProps,
variant: 'md',
};

Small.args = {
...defaultProps,
variant: 'sm',
};

Large.args = {
...defaultProps,
variant: 'lg',
};
46 changes: 46 additions & 0 deletions docs/ui/stories/link.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import type { Meta, StoryFn } from '@storybook/react';
// we use `lib/` paths so we can get source files and have storybook
// auto refresh (hmr) whenever we update our component source files
import { Link } from '@waldronmatt/demo-ui/lib/components/Link/index.js';
import type { LinkProps } from '@waldronmatt/demo-ui/lib/components/Link/index.js';

const defaultProps = {
children: 'Hello World',
href: '/',
};

const meta: Meta<typeof Link> = {
title: 'Components/Link',
component: Link,
argTypes: {
variant: {
options: ['md', 'sm', 'lg'],
control: { type: 'radio' },
},
},
};

export default meta;

const Template: StoryFn<typeof Link> = (args: LinkProps) => {
return <Link {...args}></Link>;
};

export const Default = Template.bind({});
export const Small = Template.bind({});
export const Large = Template.bind({});

Default.args = {
...defaultProps,
variant: 'md',
};

Small.args = {
...defaultProps,
variant: 'sm',
};

Large.args = {
...defaultProps,
variant: 'lg',
};
8 changes: 8 additions & 0 deletions docs/ui/tsconfig.eslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "./tsconfig.json",
"include": [".*.cjs", "*.cjs", "stories/*"],
"compilerOptions": {
"allowJs": true
}
}
6 changes: 6 additions & 0 deletions docs/ui/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "tsconfig-config/vite.json",
"include": ["stories"],
"exclude": ["node_modules", "dist"]
}

0 comments on commit 070c562

Please sign in to comment.