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

feat: TUP-700 @tacc/core-components - storybook (replaced by #462) #435

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
41c6cfd
feat: tup-700 storybook
wesleyboar Feb 26, 2024
4820882
deps: tup-700 uninstall `@swc-…`
wesleyboar Feb 26, 2024
4c834b7
feat: tup-700 Button stories, working Controls
wesleyboar Feb 26, 2024
9d1a4df
fix: tup-700 ignore stories during build
wesleyboar Feb 26, 2024
a6b19de
fix: nx serve/build/test core-components
wesleyboar Feb 27, 2024
ba5f295
feat: tup-700 button story
wesleyboar Feb 27, 2024
c474e5f
style: npx nx format:write
wesleyboar Feb 28, 2024
f3bdb30
Merge branch 'feat/TUP-700-core-components-node-pkg' into feat/TUP-70…
wesleyboar May 8, 2024
a3c0117
Merge branch 'feat/TUP-700-core-components-node-pkg' into feat/TUP-70…
wesleyboar May 8, 2024
c92aec1
Merge branch 'feat/TUP-700-core-components-node-pkg' into feat/TUP-70…
wesleyboar May 8, 2024
d6bd44c
docs(tup-ui): tup-700 README "Contributing"
wesleyboar May 8, 2024
977f3d0
fix: tup-700 npm ci core-components workspace ★
wesleyboar May 8, 2024
e83f3b7
Merge branch 'feat/TUP-700-core-components-node-pkg--wrappers' into f…
wesleyboar May 9, 2024
239338c
Merge branch 'feat/TUP-700-core-components-node-pkg--wrappers' into f…
wesleyboar May 9, 2024
63307c3
Merge branch 'feat/TUP-700-core-components-node-pkg--wrappers' into f…
wesleyboar May 9, 2024
faa8d23
Merge branch 'feat/TUP-700-core-components-node-pkg--wrappers' into f…
wesleyboar May 10, 2024
c82c00b
npx nx format:write
wesleyboar May 10, 2024
1f3197d
Merge branch 'feat/TUP-700-core-components-node-pkg--wrappers' into f…
wesleyboar May 10, 2024
e142d04
Merge branch 'feat/TUP-700-core-components-node-pkg--wrappers' into f…
wesleyboar May 10, 2024
ab245f8
docs: do not reference lib names
wesleyboar May 10, 2024
c24ca96
Merge branch 'feat/TUP-700-core-components-node-pkg--wrappers' into f…
wesleyboar May 10, 2024
cf2e929
docs: do reference (other) lib names
wesleyboar May 10, 2024
ef151e5
Merge branch 'feat/TUP-700-core-components-node-pkg--wrappers' into f…
wesleyboar May 10, 2024
6234e49
Merge branch 'feat/TUP-700-core-components-node-pkg--wrappers' into f…
wesleyboar May 13, 2024
2d84cdf
docs(README): add `make start` step
wesleyboar May 13, 2024
f562b89
feat: make storybook optional
wesleyboar May 13, 2024
46c9d2c
feat: make storybook optional (not peer)
wesleyboar May 13, 2024
c445495
docs(README): fix serve/start command
wesleyboar May 13, 2024
3db236e
fix: make storybook optional (not peer)
wesleyboar May 13, 2024
5fced48
chore: (redundantly) include optional dependences
wesleyboar May 13, 2024
d486557
fix: limit install overhead for core-components
wesleyboar May 13, 2024
ab27f19
fix: add missing dependencies for core-components
wesleyboar May 13, 2024
3a1bcd7
fix: add missing `build-storybook` npm command
wesleyboar May 14, 2024
3443beb
fix: a TypeScript lint error
wesleyboar May 14, 2024
43f8c99
fix: do not pass size to `<Button type="link">`
wesleyboar May 14, 2024
904200a
feat: load global css via typescript not html
wesleyboar May 16, 2024
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
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ To bring containers down after development, run `npx nx down tup-cms`.

Other useful commands:

- `npx nx serve core-components` to run a demo of the library for the core components.
- `npx nx build core-components` to create a distributable library for the core components.

## Contributing
Expand All @@ -32,6 +33,8 @@ To contribute, first read [How to Contirbute](./docs/contributing.md).

---

<!-- NX -->

<p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-logo.png" width="450"></p>

🔎 **Smart, Fast and Extensible Build System**
Expand Down
20 changes: 20 additions & 0 deletions libs/core-components/.storybook/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import type { StorybookConfig } from '@storybook/react-vite';

const config: StorybookConfig = {
stories: ['../src/lib/**/*.stories.@(js|jsx|ts|tsx|mdx)'],
addons: ['@storybook/addon-essentials'],
framework: {
name: '@storybook/react-vite',
options: {
builder: {
viteConfigPath: 'libs/core-components/vite.config.ts',
},
},
},
};

export default config;

// To customize your Vite configuration you can use the viteFinal field.
// Check https://storybook.js.org/docs/react/builders/vite#configuration
// and https://nx.dev/recipes/storybook/custom-builder-configs
4 changes: 4 additions & 0 deletions libs/core-components/.storybook/preview.global.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/* https://tacc-main.atlassian.net/wiki/x/hRlv */
@import url('https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css') layer(foundation);
@import url('@tacc/core-styles/dist/core-styles.base.css') layer(base);
@import url('@tacc/core-styles/dist/core-styles.portal.css') layer(base);
1 change: 1 addition & 0 deletions libs/core-components/.storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import './preview.global.css';
17 changes: 16 additions & 1 deletion libs/core-components/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,13 @@ Set up a new local CMS instance.
2. Install Dependencies:

```sh
npm install
npm install --include=optional --workspace=libs/core-components
```

3. Start demo:

```sh
npx nx serve core-components
```

## Developing
Expand All @@ -57,6 +63,15 @@ The components are [React components](https://react.dev/learn) that should be [w
| `npm test` | execute unit tests | [Vitest](https://vitest.dev/) |
| `npm run build` | build components | [Vite](https://vitejs.dev/) |

## Contributing

### to the Demo

| task | reference |
| ------------------ | ------------------------------------------------- |
| add/edit component | https://storybook.js.org/docs/writing-stories |
| change interaction | https://storybook.js.org/docs/essentials/controls |

## Testing

### Unit Tests
Expand Down
23 changes: 18 additions & 5 deletions libs/core-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,19 @@
"dist"
],
"scripts": {
"// start": "nx serve",
"start": "nx serve",
"build": "nx build",
"build:storbook": "nx build-storybook",
"test": "nx test",
"prepublishOnly": "npm run build"
},
"homepage": "https://github.com/TACC/tup-ui/libs/core-components",
"repository": "git@github.com:TACC/tup-ui.git",
"peerDependencies": {
"@tacc/core-styles": "^2.23.1",
"@nx/vite": "^17.2.8",
"@tacc/core-styles": "^2.25.1",
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^14.0.0",
"@vitejs/plugin-react-swc": "^3.5.0",
"formik": "^2.2.9",
"react": "18.2.0",
"react-dom": "18.2.0",
Expand All @@ -29,9 +31,20 @@
"react-step-wizard": "^5.3.11",
"react-table": "^7.8.0",
"reactstrap": "^9.1.5",
"uuid": "^8.3.2"
"uuid": "^8.3.2",
"vite-plugin-dts": "^2.3.0",
"vite-tsconfig-paths": "^4.2.0"
},
"sideEffects": [
"libs/core-componets/**/*.css"
]
],
"optionalDependencies": {
"@nx/storybook": "^17.2.8",
"@storybook/addon-essentials": "^7.6.19",
"@storybook/core-server": "^7.6.19",
"@storybook/react-vite": "^7.6.19"
},
"devDependencies": {
"vite-plugin-lib-inject-css": "^2.1.1"
}
}
37 changes: 37 additions & 0 deletions libs/core-components/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,43 @@
"passWithNoTests": true,
"reportsDirectory": "../../coverage/libs/core-components"
}
},
"serve": {
"executor": "@nx/storybook:storybook",
"options": {
"port": 4400,
"configDir": "libs/core-components/.storybook"
},
"configurations": {
"ci": {
"quiet": true
}
}
},
"storybook": {
"executor": "@nx/storybook:storybook",
"options": {
"port": 4400,
"configDir": "libs/core-components/.storybook"
},
"configurations": {
"ci": {
"quiet": true
}
}
},
"build-storybook": {
"executor": "@nx/storybook:build",
"outputs": ["{options.outputDir}"],
"options": {
"outputDir": "dist/storybook/core-components",
"configDir": "libs/core-components/.storybook"
},
"configurations": {
"ci": {
"quiet": true
}
}
}
}
}
3 changes: 3 additions & 0 deletions libs/core-components/src/lib/Button/Button.stories.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.button + .button {
margin-left: 1em;
}
44 changes: 44 additions & 0 deletions libs/core-components/src/lib/Button/Button.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import type { Meta, StoryObj } from '@storybook/react';

import Button, { SIZE_MAP } from './Button';

import styles from './Button.stories.module.css';

const meta: Meta<typeof Button> = {
component: Button,
argTypes: {
size: {
options: Object.keys(SIZE_MAP),
control: { type: 'inline-radio' },
},
},
};
export default meta;

type Story = StoryObj<typeof Button>;

export const Types: Story = {
render: (args) => {
const { size, ...argsSansSize } = args;

return (
<>
<Button type="primary" {...args}>
Primary
</Button>
<Button type="secondary" {...args}>
Secondary
</Button>
<Button type="tertiary" {...args}>
Tertiary
</Button>
<Button type="link" {...argsSansSize}>
as Link
</Button>
</>
);
},
args: {
className: styles['button'] + ' ',
},
};
3 changes: 3 additions & 0 deletions libs/core-components/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
},
{
"path": "./tsconfig.spec.json"
},
{
"path": "./tsconfig.storybook.json"
}
],
"extends": "../../tsconfig.base.json"
Expand Down
6 changes: 5 additions & 1 deletion libs/core-components/tsconfig.lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@
"**/*.spec.js",
"**/*.test.js",
"**/*.spec.jsx",
"**/*.test.jsx"
"**/*.test.jsx",
"**/*.stories.ts",
"**/*.stories.js",
"**/*.stories.jsx",
"**/*.stories.tsx"
],
"include": ["**/*.js", "**/*.jsx", "**/*.ts", "**/*.tsx"]
}
33 changes: 33 additions & 0 deletions libs/core-components/tsconfig.storybook.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"emitDecoratorMetadata": true,
"outDir": ""
},
"files": [
"../../node_modules/@nx/react/typings/styled-jsx.d.ts",
"../../node_modules/@nx/react/typings/cssmodule.d.ts",
"../../node_modules/@nx/react/typings/image.d.ts"
],
"exclude": [
"src/**/*.spec.ts",
"src/**/*.test.ts",
"src/**/*.spec.js",
"src/**/*.test.js",
"src/**/*.spec.tsx",
"src/**/*.test.tsx",
"src/**/*.spec.jsx",
"src/**/*.test.js"
],
"include": [
"src/**/*.ts",
"src/**/*.tsx",
"src/**/*.stories.ts",
"src/**/*.stories.js",
"src/**/*.stories.jsx",
"src/**/*.stories.tsx",
"src/**/*.stories.mdx",
".storybook/*.js",
".storybook/*.ts"
]
}
4 changes: 3 additions & 1 deletion libs/core-components/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ export default defineConfig({
input: Object.fromEntries(
// https://rollupjs.org/configuration-options/#input
glob
.sync(resolve(__dirname, 'src/**/!(*.test).{ts,tsx,js,jsx}'))
.sync(resolve(__dirname, 'src/**/!(*.test).{ts,tsx,js,jsx}'), {
ignore: resolve(__dirname, 'src/**/*.stories.tsx'),
})
.map((file) => [
// This removes `...src/` as well as the file extension from each
// file, so e.g. ...src/nested/foo.js becomes nested/foo
Expand Down
21 changes: 20 additions & 1 deletion nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@
"@nx/vite:test": {
"inputs": ["default", "^production", "{workspaceRoot}/jest.preset.js"],
"cache": true
},
"build-storybook": {
"cache": true,
"inputs": [
"default",
"^production",
"{projectRoot}/.storybook/**/*",
"{projectRoot}/tsconfig.storybook.json"
]
}
},
"namedInputs": {
Expand All @@ -45,7 +54,17 @@
"!{projectRoot}/**/?(*.)+(spec|test).[jt]s?(x)?(.snap)",
"!{projectRoot}/tsconfig.spec.json",
"!{projectRoot}/jest.config.[jt]s",
"!{projectRoot}/.eslintrc.json"
"!{projectRoot}/.eslintrc.json",
"!{projectRoot}/**/*.stories.@(js|jsx|ts|tsx|mdx)",
"!{projectRoot}/.storybook/**/*",
"!{projectRoot}/tsconfig.storybook.json"
]
},
"tasksRunnerOptions": {
"default": {
"options": {
"cacheableOperations": ["build-storybook"]
}
}
}
}
Loading
Loading