-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: move ui into libs, set up storybook * chore: pkgs for storybook * feat: set up tailwind! * chore: move locales into libs * fix: dont need no p in hurr * chore: add locales to path aliases * refactor: make component storybook-ready * refactor: use tailwind * refactor: something more production-esque * fix: import error
- Loading branch information
1 parent
d260e31
commit 8c7f706
Showing
36 changed files
with
4,640 additions
and
345 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"tailwindCSS.emmetCompletions": true, | ||
"editor.inlineSuggest.enabled": true, | ||
"css.validate": false, | ||
"scss.validate": false, | ||
"stylelint.enable": true, | ||
"files.associations": { | ||
"*.css": "tailwindcss", | ||
"*.scss": "tailwindcss" | ||
}, | ||
"editor.quickSuggestions": { | ||
"strings": true | ||
}, | ||
"css.customData": [".vscode/css_custom_data.json"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
const { join } = require('path'); | ||
|
||
// Note: If you use library-specific PostCSS/Tailwind configuration then you should remove the `postcssConfig` build | ||
// option from your application's configuration (i.e. project.json). | ||
// | ||
// See: https://nx.dev/guides/using-tailwind-css-in-react#step-4:-applying-configuration-to-libraries | ||
|
||
module.exports = { | ||
plugins: { | ||
tailwindcss: { | ||
config: join(__dirname, 'tailwind.config.js'), | ||
}, | ||
autoprefixer: {}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
@tailwind base; | ||
@tailwind components; | ||
@tailwind utilities; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
const { createGlobPatternsForDependencies } = require('@nx/react/tailwind'); | ||
const { join } = require('path'); | ||
|
||
/** @type {import('tailwindcss').Config} */ | ||
module.exports = { | ||
content: [ | ||
join( | ||
__dirname, | ||
'{src,pages,components,app}/**/*!(*.stories|*.spec).{ts,tsx,html}' | ||
), | ||
...createGlobPatternsForDependencies(__dirname), | ||
], | ||
theme: { | ||
extend: {}, | ||
}, | ||
plugins: [], | ||
}; |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import type { StorybookConfig } from '@storybook/react-vite'; | ||
|
||
import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin'; | ||
import { mergeConfig } from 'vite'; | ||
|
||
const config: StorybookConfig = { | ||
stories: ['../src/lib/**/*.stories.@(js|jsx|ts|tsx|mdx)'], | ||
addons: ['@storybook/addon-essentials', '@storybook/addon-interactions'], | ||
framework: { | ||
name: '@storybook/react-vite', | ||
options: {}, | ||
}, | ||
|
||
viteFinal: async (config) => | ||
mergeConfig(config, { | ||
plugins: [nxViteTsPaths()], | ||
}), | ||
}; | ||
|
||
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 |
Empty file.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
{ | ||
"name": "ui", | ||
"$schema": "../node_modules/nx/schemas/project-schema.json", | ||
"sourceRoot": "libs/ui/src", | ||
"projectType": "library", | ||
"tags": [], | ||
"targets": { | ||
"lint": { | ||
"executor": "@nx/eslint:lint", | ||
"outputs": ["{options.outputFile}"] | ||
}, | ||
"test": { | ||
"executor": "@nx/jest:jest", | ||
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"], | ||
"options": { | ||
"jestConfig": "ui/jest.config.ts" | ||
} | ||
}, | ||
"storybook": { | ||
"executor": "@nx/storybook:storybook", | ||
"options": { | ||
"port": 4400, | ||
"configDir": "libs/ui/.storybook" | ||
}, | ||
"configurations": { | ||
"ci": { | ||
"quiet": true | ||
} | ||
} | ||
}, | ||
"build-storybook": { | ||
"executor": "@nx/storybook:build", | ||
"outputs": ["{options.outputDir}"], | ||
"options": { | ||
"outputDir": "dist/storybook/ui", | ||
"configDir": "libs/ui/.storybook" | ||
}, | ||
"configurations": { | ||
"ci": { | ||
"quiet": true | ||
} | ||
} | ||
}, | ||
"test-storybook": { | ||
"executor": "nx:run-commands", | ||
"options": { | ||
"command": "test-storybook -c libs/ui/.storybook --url=http://localhost:4400" | ||
} | ||
}, | ||
"static-storybook": { | ||
"executor": "@nx/web:file-server", | ||
"options": { | ||
"buildTarget": "ui:build-storybook", | ||
"staticFilePath": "dist/storybook/ui" | ||
}, | ||
"configurations": { | ||
"ci": { | ||
"buildTarget": "ui:build-storybook:ci" | ||
} | ||
} | ||
} | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
ui/src/lib/SubmitButton.spec.tsx → libs/ui/src/lib/SubmitButton.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import type { Meta, StoryObj, StoryFn } from '@storybook/react'; | ||
import { SubmitButton, SubmitButtonProps, styles } from './SubmitButton'; | ||
|
||
export default { | ||
component: SubmitButton, | ||
title: 'SubmitButton', | ||
} as Meta<SubmitButtonProps & { level: keyof typeof SubmitButton }>; | ||
|
||
const Template: StoryFn<SubmitButtonProps> = (args) => ( | ||
<SubmitButton {...args} /> | ||
); | ||
|
||
export const Primary = Template.bind({}); | ||
Primary.args = { | ||
children: 'Primary', | ||
className: styles.primary, | ||
}; | ||
export const Success = Template.bind({}); | ||
Success.args = { | ||
children: 'Success', | ||
className: styles.success, | ||
}; | ||
export const Error = Template.bind({}); | ||
Error.args = { | ||
children: 'Error', | ||
className: styles.error, | ||
}; | ||
export const Warning = Template.bind({}); | ||
Warning.args = { | ||
children: 'Warning', | ||
className: styles.warning, | ||
}; | ||
export const Info = Template.bind({}); | ||
Info.args = { | ||
children: 'Info', | ||
className: styles.info, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { ButtonHTMLAttributes, PropsWithChildren } from 'react'; | ||
import styled from 'styled-components'; | ||
|
||
export const styles = { | ||
primary: 'border-indigo-500 bg-indigo-500 hover:bg-indigo-600', | ||
success: 'border-green-500 bg-green-500 hover:bg-green-600', | ||
error: 'border-red-500 bg-red-500 hover:bg-red-600', | ||
warning: 'border-yellow-500 bg-yellow-500 hover:bg-yellow-600', | ||
info: 'border-teal-500 bg-teal-500 hover:bg-teal-600', | ||
}; | ||
export type SubmitButtonProps = PropsWithChildren< | ||
ButtonHTMLAttributes<HTMLButtonElement> | ||
>; | ||
|
||
const StyledFormField = styled.div``; | ||
|
||
export function SubmitButton({ children, ...props }: SubmitButtonProps) { | ||
const className = props.className || ''; | ||
|
||
return ( | ||
<StyledFormField> | ||
<button | ||
{...props} | ||
type={'button'} | ||
className={'border text-white rounded-md px-4 py-2 m-2 transition duration-500 ease select-none focus:outline-none focus:shadow-outline'.concat( | ||
className | ||
)} | ||
name="start" | ||
id="start" | ||
> | ||
Tell Me! | ||
</button> | ||
</StyledFormField> | ||
); | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
import { TextField } from './TextField'; | ||
|
||
import { within } from '@storybook/testing-library'; | ||
import { expect } from '@storybook/jest'; | ||
|
||
const meta: Meta<typeof TextField> = { | ||
component: TextField, | ||
title: 'TextField', | ||
}; | ||
export default meta; | ||
type Story = StoryObj<typeof TextField>; | ||
|
||
export const Primary = { | ||
args: {}, | ||
}; | ||
|
||
export const Heading: Story = { | ||
args: {}, | ||
play: async ({ canvasElement }) => { | ||
const canvas = within(canvasElement); | ||
expect(canvas.getByText(/Welcome to TextField!/gi)).toBeTruthy(); | ||
}, | ||
}; |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.