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 #462

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
6c96b8f
test(@tacc/core-components): TUP-700 (WIP)
wesleyboar Feb 22, 2024
78de3a3
Merge branch 'main' into feat/TUP-700-core-components-node-pkg
wesleyboar Feb 22, 2024
dca6c45
Merge branch 'main' into feat/TUP-700-core-components-node-pkg
wesleyboar Feb 23, 2024
0964f57
fix: tup-700 do not commit dist
wesleyboar Feb 23, 2024
193abdf
docs(README): tup-700 add `build core-components`
wesleyboar Feb 23, 2024
a6575b3
feat: tup-700 peer dependencies
wesleyboar Feb 23, 2024
8df57f3
feat: tup-700 build (no tested on a client yet)
wesleyboar Feb 23, 2024
f9c5944
feat: tup-700 1st attempt to split files/css build
wesleyboar Feb 23, 2024
8e485fc
fix: tup-700 add main file to dist
wesleyboar Feb 24, 2024
fb9808d
build: tup-700 do not build tests
wesleyboar Feb 26, 2024
b4be800
fix: tup-700 add types & fix resulting errors
wesleyboar Feb 26, 2024
53786ca
fix: tup-700 tag types in package.json
wesleyboar Feb 26, 2024
ea64e9a
style: tup-700 move rollup opts input glob inline
wesleyboar Feb 26, 2024
9754110
style: npx nx format:write
wesleyboar Feb 26, 2024
2d5ab1c
style: tup-700 peerDependencies
wesleyboar Feb 26, 2024
6336f2c
feat: tup-700 add CSS as sideEffects
wesleyboar Feb 26, 2024
233f165
feat: tup-700 ensure build before publish
wesleyboar Feb 26, 2024
e195480
fix: tup-700 do 2d5ab1c, 6336f2c, 233f165 correct
wesleyboar Feb 26, 2024
d037d2a
Merge branch 'main' into feat/TUP-700-core-components-node-pkg
wesleyboar Feb 26, 2024
ce1406b
chore: tup-700 resolve vite.config.ts comment code
wesleyboar Feb 26, 2024
0c48e90
Merge branch 'main' into feat/TUP-700-core-components-node-pkg
wesleyboar May 8, 2024
119e8d8
fix: tup-700 scripts inaccurate
wesleyboar May 8, 2024
aa97cc3
docs: tup-700 README
wesleyboar May 8, 2024
77c4621
feat: tup-700 core-components deps via workspace
wesleyboar May 8, 2024
deecf7f
fix: tup-700 core-components deps via workspace
wesleyboar May 8, 2024
eda6d44
Merge branch 'main' into feat/TUP-700-core-components-node-pkg
wesleyboar May 9, 2024
d617768
npx nx format:write
wesleyboar May 9, 2024
7a82aeb
Merge branch 'feat/TUP-700-core-components-node-pkg' of github.com:TA…
wesleyboar May 9, 2024
dee299e
fix: core-components/package-lock.json should not exist
wesleyboar May 9, 2024
105e4ae
chore: rename Navbar → NavbarWrapper
wesleyboar May 9, 2024
0c32d66
Merge branch 'feat/TUP-700-core-components-node-pkg' into feat/TUP-70…
wesleyboar May 9, 2024
7dbd076
chore: rename FieldWrapperFormik → FormikFieldWrapper
wesleyboar May 9, 2024
51e58ab
npx nx format:write
wesleyboar May 9, 2024
8039548
chore: move withBuilder to core-components
wesleyboar May 9, 2024
de94a2f
feat: move core-wrappers to core-components
wesleyboar May 10, 2024
bae1b57
lint: rename some index.js to index.ts
wesleyboar May 10, 2024
100392d
lint: import via rel. path not lib name
wesleyboar May 10, 2024
7ee6b49
deps: add core-wrappers deps to peerDeps
wesleyboar May 10, 2024
5abf5a5
docs: do not reference lib names
wesleyboar May 10, 2024
ac39b15
docs: do reference (other) lib names
wesleyboar May 10, 2024
b0cfa8c
docs(README): remove duplicate step
wesleyboar May 13, 2024
650e728
Merge branch 'feat/TUP-700-core-components-node-pkg' into feat/TUP-70…
wesleyboar May 13, 2024
8bf0550
feat: TUP-700 @tacc/core-components - Storybook (#435)
wesleyboar May 16, 2024
ee5e73b
Merge branch 'epic/TUP-700-core-components-node-pkg' into feat/TUP-70…
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