Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

update stories

Jonathan Summers-Muir18d2cc274710
diff --git a/package-lock.json b/package-lock.json
index f17479dc837..d27e2ca9c96 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -42788,6 +42788,59 @@
"strip-bom": "^3.0.0"
}
},
+ "node_modules/tsconfig-paths-webpack-plugin": {
+ "version": "4.0.1",
+ "resolved": "https://registry.npmjs.org/tsconfig-paths-webpack-plugin/-/tsconfig-paths-webpack-plugin-4.0.1.tgz",
+ "integrity": "sha512-m5//KzLoKmqu2MVix+dgLKq70MnFi8YL8sdzQZ6DblmCdfuq/y3OqvJd5vMndg2KEVCOeNz8Es4WVZhYInteLw==",
+ "dev": true,
+ "dependencies": {
+ "chalk": "^4.1.0",
+ "enhanced-resolve": "^5.7.0",
+ "tsconfig-paths": "^4.1.2"
+ },
+ "engines": {
+ "node": ">=10.13.0"
+ }
+ },
+ "node_modules/tsconfig-paths-webpack-plugin/node_modules/chalk": {
+ "version": "4.1.2",
+ "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
+ "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
+ "dev": true,
+ "dependencies": {
+ "ansi-styles": "^4.1.0",
+ "supports-color": "^7.1.0"
+ },
+ "engines": {
+ "node": ">=10"
+ },
+ "funding": {
+ "url": "https://github.com/chalk/chalk?sponsor=1"
+ }
+ },
+ "node_modules/tsconfig-paths-webpack-plugin/node_modules/strip-bom": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz",
+ "integrity": "sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==",
+ "dev": true,
+ "engines": {
+ "node": ">=4"
+ }
+ },
+ "node_modules/tsconfig-paths-webpack-plugin/node_modules/tsconfig-paths": {
+ "version": "4.2.0",
+ "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-4.2.0.tgz",
+ "integrity": "sha512-NoZ4roiN7LnbKn9QqE1amc9DJfzvZXxF4xDavcOWt1BPkdx+m+0gJuPM+S0vCe7zTJMYUP0R8pO2XMr+Y8oLIg==",
+ "dev": true,
+ "dependencies": {
+ "json5": "^2.2.2",
+ "minimist": "^1.2.6",
+ "strip-bom": "^3.0.0"
+ },
+ "engines": {
+ "node": ">=6"
+ }
+ },
"node_modules/tsconfig-paths/node_modules/json5": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/json5/-/json5-1.0.2.tgz",
@@ -45580,6 +45633,7 @@
"storybook": "^7.0.5",
"storybook-dark-mode": "^3.0.0",
"style-dictionary": "^3.7.1",
+ "tsconfig-paths-webpack-plugin": "^4.0.1",
"typescript": "4.3.4"
}
},
@@ -79845,6 +79899,46 @@
}
}
},
+ "tsconfig-paths-webpack-plugin": {
+ "version": "4.0.1",
+ "resolved": "https://registry.npmjs.org/tsconfig-paths-webpack-plugin/-/tsconfig-paths-webpack-plugin-4.0.1.tgz",
+ "integrity": "sha512-m5//KzLoKmqu2MVix+dgLKq70MnFi8YL8sdzQZ6DblmCdfuq/y3OqvJd5vMndg2KEVCOeNz8Es4WVZhYInteLw==",
+ "dev": true,
+ "requires": {
+ "chalk": "^4.1.0",
+ "enhanced-resolve": "^5.7.0",
+ "tsconfig-paths": "^4.1.2"
+ },
+ "dependencies": {
+ "chalk": {
+ "version": "4.1.2",
+ "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
+ "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
+ "dev": true,
+ "requires": {
+ "ansi-styles": "^4.1.0",
+ "supports-color": "^7.1.0"
+ }
+ },
+ "strip-bom": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz",
+ "integrity": "sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==",
+ "dev": true
+ },
+ "tsconfig-paths": {
+ "version": "4.2.0",
+ "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-4.2.0.tgz",
+ "integrity": "sha512-NoZ4roiN7LnbKn9QqE1amc9DJfzvZXxF4xDavcOWt1BPkdx+m+0gJuPM+S0vCe7zTJMYUP0R8pO2XMr+Y8oLIg==",
+ "dev": true,
+ "requires": {
+ "json5": "^2.2.2",
+ "minimist": "^1.2.6",
+ "strip-bom": "^3.0.0"
+ }
+ }
+ }
+ },
"tslib": {
"version": "2.5.0",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.0.tgz",
@@ -80044,7 +80138,7 @@
"@types/react-dom": "^17.0.11",
"@types/react-syntax-highlighter": "^15.5.6",
"autoprefixer": "^10.4.14",
- "class-variance-authority": "*",
+ "class-variance-authority": "^0.6.0",
"clsx": "^1.2.1",
"cmdk-supabase": "^0.2.2",
"color": "^4.2.3",
@@ -80073,6 +80167,7 @@
"tailwind-merge": "^1.10.0",
"tailwindcss": "^3.0.15",
"tailwindcss-radix": "^1.6.0",
+ "tsconfig-paths-webpack-plugin": "*",
"typescript": "4.3.4"
},
"dependencies": {
diff --git a/packages/ui/.storybook/main.js b/packages/ui/.storybook/main.ts
similarity index 51%
rename from packages/ui/.storybook/main.js
rename to packages/ui/.storybook/main.ts
index 6eec6659784..9af87dbdec2 100644
--- a/packages/ui/.storybook/main.js
+++ b/packages/ui/.storybook/main.ts
@@ -1,4 +1,7 @@
-module.exports = {
+const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin')
+import type { StorybookConfig } from '@storybook/your-framework'
+
+const config: StorybookConfig = {
// // stories: [
// // '../src/components/**/*.stories.mdx',
// // '../src/components/**/*.stories.@(js|jsx|ts|tsx)',
@@ -6,14 +9,14 @@ module.exports = {
// // TODO: Temporally Import one by one story and fix build issue.
// // After all stories are cleaned, revert to wildcard import.
stories: [
- '../src/components/Accordion/Accordion.stories.tsx',
- '../src/components/Alert/Alert.stories.tsx',
- '../src/components/Avatar/Avatar.stories.tsx',
+ // '../src/components/Accordion/Accordion.stories.tsx',
+ // '../src/components/Alert/Alert.stories.tsx',
+ // '../src/components/Avatar/Avatar.stories.tsx',
'../src/components/Button/Button.stories.tsx',
- '../src/components/Checkbox/Checkbox.stories.tsx',
- '../src/components/Collapsible/Collapsible.stories.tsx',
- '../src/components/ContextMenu/ContextMenu.stories.tsx',
- '../src/components/Dropdown/Dropdown.stories.tsx',
+ // '../src/components/Checkbox/Checkbox.stories.tsx',
+ // '../src/components/Collapsible/Collapsible.stories.tsx',
+ // '../src/components/ContextMenu/ContextMenu.stories.tsx',
+ // '../src/components/Dropdown/Dropdown.stories.tsx',
],
addons: [
// '@storybook/addon-links',
@@ -39,4 +42,13 @@ module.exports = {
name: '@storybook/react-webpack5',
options: {},
},
+ webpackFinal: async (config, { configType }) => {
+ /**
+ * resolve import paths from tsconfig
+ * based on https://stackoverflow.com/a/71677949/4807782
+ */
+ config.resolve.plugins = [new TsconfigPathsPlugin()] // ;<-- this line
+ return config
+ },
}
+export default config
diff --git a/packages/ui/.storybook/preview.css b/packages/ui/.storybook/preview.css
index 5682f9ab6be..7c9bdb31cb7 100644
--- a/packages/ui/.storybook/preview.css
+++ b/packages/ui/.storybook/preview.css
@@ -4,7 +4,7 @@
@import './../build/css/themes/dark.css';
@import './../build/css/themes/light.css';
-@import './../build/css/themes/darker-dark.css';
+/* @import './../build/css/themes/darker-dark.css'; */
.dark,
.light,
diff --git a/packages/ui/build/css/themes/dark.css b/packages/ui/build/css/themes/dark.css
index fedf2507642..a4d60d733a8 100644
--- a/packages/ui/build/css/themes/dark.css
+++ b/packages/ui/build/css/themes/dark.css
@@ -1,6 +1,6 @@
/**
* Do not edit directly
- * Generated on Tue, 09 May 2023 15:35:29 GMT
+ * Generated on Sat, 20 May 2023 09:00:49 GMT
*/
.dark {
diff --git a/packages/ui/build/css/themes/light.css b/packages/ui/build/css/themes/light.css
index 340a6635965..0f4e33acc9f 100644
--- a/packages/ui/build/css/themes/light.css
+++ b/packages/ui/build/css/themes/light.css
@@ -1,6 +1,6 @@
/**
* Do not edit directly
- * Generated on Tue, 09 May 2023 15:35:29 GMT
+ * Generated on Sat, 20 May 2023 09:00:49 GMT
*/
.light {
@@ -22,7 +22,7 @@
--theme-variables-warning: 26.9deg 93.8% 56.1%;
--theme-variables-background-body-alt: 0deg 0% 100%; /* og color is colors.Gray.Dark.1 */
--theme-variables-background-body: 210deg 16.7% 97.6%; /* og color is colors.Slate.Light.2 */
- --theme-variables-background: 210deg 33.3% 98.8%; /* og color is colors.Slate.Light.1 */
+ --theme-variables-background: 0deg 0% 98.4%; /* og color is colors.Slate.Light.1 */
--theme-variables-brand: 153.1deg 60.2% 52.7%;
--text-color-disabled-default: 195deg 7.1% 5.5%;
--text-color-danger-default: var(--theme-variables-danger);
@@ -48,11 +48,11 @@
--text-color-body-lightest: 195deg 1% 65.6%;
--text-color-body-lighter: 195deg 1% 51.8%;
--text-color-body-light: 195deg 1.9% 34.3%;
- --border-color-selection: 210deg 0.4% 46.1%;
+ --border-color-selection: 91.8deg 0% 45.9%;
--border-color-body-alt: 91.8deg 0% 96%;
--border-color-body: 210deg 6.1% 93.7%;
- --border-color-default: 210deg 7.5% 94.9%; /* Default border color */
- --background-color-control: 210deg 33.3% 99.2%;
- --background-color-selection: 210deg 7.5% 94.9%;
- --border-color-control: 210deg 4.1% 91.2%;
+ --border-color-default: 91.8deg 0% 94.5%; /* Default border color */
+ --background-color-control: 91.8deg 0% 98.9%;
+ --background-color-selection: 91.8deg 0% 94.5%;
+ --border-color-control: 91.8deg 0% 90.8%;
}
diff --git a/packages/ui/package.json b/packages/ui/package.json
index d3e425d8f3d..ccdeeeefa95 100644
--- a/packages/ui/package.json
+++ b/packages/ui/package.json
@@ -76,6 +76,7 @@
"storybook": "^7.0.5",
"storybook-dark-mode": "^3.0.0",
"style-dictionary": "^3.7.1",
+ "tsconfig-paths-webpack-plugin": "^4.0.1",
"typescript": "4.3.4"
}
}
diff --git a/packages/ui/src/components/Button/Button.stories-old.tsx b/packages/ui/src/components/Button/Button.stories-old.tsx
new file mode 100644
index 00000000000..57c0e956cc7
--- /dev/null
+++ b/packages/ui/src/components/Button/Button.stories-old.tsx
@@ -0,0 +1,234 @@
+import { Button } from './'
+import { IconPackage } from './../Icon/icons/IconPackage'
+import { IconChevronRight } from './../Icon/icons/IconChevronRight'
+
+export default {
+ title: 'General/Button',
+ component: Button,
+}
+
+export const Neutral = (args: any) => <Button {...args}>Button text</Button>
+export const Success = (args: any) => <Button {...args}>Button text</Button>
+export const withStyles = (args: any) => <Button {...args}>Button text</Button>
+export const withIcon = (args: any) => <Button {...args}>Button text</Button>
+export const withIconRight = (args: any) => <Button {...args}>Button text</Button>
+export const withBlock = (args: any) => <Button {...args}>Button text</Button>
+export const withOnlyIcon = (args: any) => <Button {...args} />
+export const withOnlyLoading = (args: any) => <Button {...args} />
+export const withLoadingCentered = (args: any) => (
+ <Button {...args}>Loading icon is centered</Button>
+)
+
+export const allButtons = (args: any) => (
+ <>
+ <div className="flex flex-col space-y-4">
+ <div className="flex space-x-4">
+ <Button {...args} size="tiny">
+ Button text
+ </Button>
+ <Button {...args} size="tiny" type="default">
+ Button text
+ </Button>
+ <Button {...args} size="tiny" type="secondary">
+ Button text
+ </Button>
+ <Button {...args} size="tiny" type="alternative">
+ Button text
+ </Button>
+ <Button {...args} size="tiny" type="link">
+ Button text
+ </Button>
+ <Button {...args} size="tiny" type="text">
+ Button text
+ </Button>
+ <Button {...args} size="tiny" type="dashed">
+ Button text
+ </Button>
+ <Button {...args} size="tiny" type="outline">
+ Button text
+ </Button>
+ <Button {...args} size="tiny" type="danger">
+ Button text
+ </Button>
+ <Button {...args} size="tiny" type="warning">
+ Button text
+ </Button>
+ </div>
+
+ <div className="flex space-x-4">
+ <Button {...args} size="small">
+ Button text
+ </Button>
+ <Button {...args} size="small" type="default">
+ Button text
+ </Button>
+ <Button {...args} size="small" type="secondary">
+ Button text
+ </Button>
+ <Button {...args} size="small" type="alternative">
+ Button text
+ </Button>
+ <Button {...args} size="small" type="link">
+ Button text
+ </Button>
+ <Button {...args} size="small" type="text">
+ Button text
+ </Button>
+ <Button {...args} size="small" type="dashed">
+ Button text
+ </Button>
+ <Button {...args} size="small" type="outline">
+ Button text
+ </Button>
+ <Button {...args} size="small" type="danger">
+ Button text
+ </Button>
+ <Button {...args} size="small" type="warning">
+ Button text
+ </Button>
+ </div>
+ <div className="flex space-x-4">
+ <Button {...args} size="medium">
+ Button text
+ </Button>
+ <Button {...args} size="medium" type="default">
+ Button text
+ </Button>
+ <Button {...args} size="medium" type="secondary">
+ Button text
+ </Button>
+ <Button {...args} size="medium" type="alternative">
+ Button text
+ </Button>
+ <Button {...args} size="medium" type="link">
+ Button text
+ </Button>
+ <Button {...args} size="medium" type="text">
+ Button text
+ </Button>
+ <Button {...args} size="medium" type="dashed">
+ Button text
+ </Button>
+ <Button {...args} size="medium" type="outline">
+ Button text
+ </Button>
+ <Button {...args} size="medium" type="danger">
+ Button text
+ </Button>
+ <Button {...args} size="medium" type="warning">
+ Button text
+ </Button>
+ </div>
+ <div className="flex space-x-4">
+ <Button {...args} size="large">
+ Button text
+ </Button>
+ <Button {...args} size="large" type="default">
+ Button text
+ </Button>
+ <Button {...args} size="large" type="secondary">
+ Button text
+ </Button>
+ <Button {...args} size="large" type="alternative">
+ Button text
+ </Button>
+ <Button {...args} size="large" type="link">
+ Button text
+ </Button>
+ <Button {...args} size="large" type="text">
+ Button text
+ </Button>
+ <Button {...args} size="large" type="dashed">
+ Button text
+ </Button>
+ <Button {...args} size="large" type="outline">
+ Button text
+ </Button>
+ <Button {...args} size="large" type="danger">
+ Button text
+ </Button>
+ <Button {...args} size="large" type="warning">
+ Button text
+ </Button>
+ </div>
+ <div className="flex space-x-4">
+ <Button {...args} size="xlarge">
+ Button text
+ </Button>
+ <Button {...args} size="xlarge" type="default">
+ Button text
+ </Button>
+ <Button {...args} size="xlarge" type="secondary">
+ Button text
+ </Button>
+ <Button {...args} size="xlarge" type="alternative">
+ Button text
+ </Button>
+ <Button {...args} size="xlarge" type="link">
+ Button text
+ </Button>
+ <Button {...args} size="xlarge" type="text">
+ Button text
+ </Button>
+ <Button {...args} size="xlarge" type="dashed">
+ Button text
+ </Button>
+ <Button {...args} size="xlarge" type="outline">
+ Button text
+ </Button>
+ <Button {...args} size="xlarge" type="danger">
+ Button text
+ </Button>
+ <Button {...args} size="xlarge" type="warning">
+ Button text
+ </Button>
+ </div>
+ </div>
+ </>
+)
+
+export const withCustomTag = (args: any) => <Button {...args}>Button text</Button>
+
+const icon = <IconPackage />
+
+withIcon.args = {
+ type: 'primary',
+ icon: icon,
+}
+
+withIconRight.args = {
+ type: 'primary',
+ iconRight: <IconChevronRight strokeWidth={2} />,
+}
+
+withStyles.args = {
+ type: 'primary',
+ style: { backgroundColor: 'red', color: 'yellow' },
+}
+
+withBlock.args = {
+ type: 'primary',
+ block: true,
+}
+
+withOnlyIcon.args = {
+ icon: icon,
+}
+
+withOnlyLoading.args = {
+ loading: true,
+}
+
+withLoadingCentered.args = {
+ loading: true,
+ loadingCentered: true,
+}
+
+allButtons.args = {
+ loading: false,
+ danger: false,
+}
+
+withCustomTag.args = {
+ as: 'span',
+}
diff --git a/packages/ui/src/components/Button/Button.stories.tsx b/packages/ui/src/components/Button/Button.stories.tsx
index e73cac1cc86..ce468ee7a01 100644
--- a/packages/ui/src/components/Button/Button.stories.tsx
+++ b/packages/ui/src/components/Button/Button.stories.tsx
@@ -1,235 +1,180 @@
-import { Button } from './'
-import { IconPackage } from './../Icon/icons/IconPackage'
-import { IconChevronRight } from './../Icon/icons/IconChevronRight'
+// Button.stories.ts|tsx
-export default {
+import type { Meta, StoryObj } from '@storybook/react'
+
+import { Button, ButtonProps } from './Button'
+import { Fragment } from 'react'
+import { IconAirplay } from '../Icon/icons/IconAirplay'
+
+const meta: Meta<typeof Button> = {
+ /* 👇 The title prop is optional.
+ * See https://storybook.js.org/docs/react/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
title: 'General/Button',
component: Button,
}
-export const Neutral = (args: any) => <Button {...args}>Button text</Button>
-export const Success = (args: any) => <Button {...args}>Button text</Button>
-
-export const withStyles = (args: any) => <Button {...args}>Button text</Button>
-export const withIcon = (args: any) => <Button {...args}>Button text</Button>
-export const withIconRight = (args: any) => <Button {...args}>Button text</Button>
-export const withBlock = (args: any) => <Button {...args}>Button text</Button>
-export const withOnlyIcon = (args: any) => <Button {...args} />
-export const withOnlyLoading = (args: any) => <Button {...args} />
-export const withLoadingCentered = (args: any) => (
- <Button {...args}>Loading icon is centered</Button>
-)
-
-export const allButtons = (args: any) => (
- <>
- <div className="flex flex-col space-y-4">
- <div className="flex space-x-4">
- <Button {...args} size="tiny">
- Button text
- </Button>
- <Button {...args} size="tiny" type="default">
- Button text
- </Button>
- <Button {...args} size="tiny" type="secondary">
- Button text
- </Button>
- <Button {...args} size="tiny" type="alternative">
- Button text
- </Button>
- <Button {...args} size="tiny" type="link">
- Button text
- </Button>
- <Button {...args} size="tiny" type="text">
- Button text
- </Button>
- <Button {...args} size="tiny" type="dashed">
- Button text
- </Button>
- <Button {...args} size="tiny" type="outline">
- Button text
- </Button>
- <Button {...args} size="tiny" type="danger">
- Button text
- </Button>
- <Button {...args} size="tiny" type="warning">
- Button text
- </Button>
- </div>
-
- <div className="flex space-x-4">
- <Button {...args} size="small">
- Button text
- </Button>
- <Button {...args} size="small" type="default">
- Button text
- </Button>
- <Button {...args} size="small" type="secondary">
- Button text
- </Button>
- <Button {...args} size="small" type="alternative">
- Button text
- </Button>
- <Button {...args} size="small" type="link">
- Button text
- </Button>
- <Button {...args} size="small" type="text">
- Button text
- </Button>
- <Button {...args} size="small" type="dashed">
- Button text
- </Button>
- <Button {...args} size="small" type="outline">
- Button text
- </Button>
- <Button {...args} size="small" type="danger">
- Button text
- </Button>
- <Button {...args} size="small" type="warning">
- Button text
- </Button>
- </div>
- <div className="flex space-x-4">
- <Button {...args} size="medium">
- Button text
- </Button>
- <Button {...args} size="medium" type="default">
- Button text
- </Button>
- <Button {...args} size="medium" type="secondary">
- Button text
- </Button>
- <Button {...args} size="medium" type="alternative">
- Button text
- </Button>
- <Button {...args} size="medium" type="link">
- Button text
- </Button>
- <Button {...args} size="medium" type="text">
- Button text
- </Button>
- <Button {...args} size="medium" type="dashed">
- Button text
- </Button>
- <Button {...args} size="medium" type="outline">
- Button text
- </Button>
- <Button {...args} size="medium" type="danger">
- Button text
- </Button>
- <Button {...args} size="medium" type="warning">
- Button text
- </Button>
- </div>
- <div className="flex space-x-4">
- <Button {...args} size="large">
- Button text
- </Button>
- <Button {...args} size="large" type="default">
- Button text
- </Button>
- <Button {...args} size="large" type="secondary">
- Button text
- </Button>
- <Button {...args} size="large" type="alternative">
- Button text
- </Button>
- <Button {...args} size="large" type="link">
- Button text
- </Button>
- <Button {...args} size="large" type="text">
- Button text
- </Button>
- <Button {...args} size="large" type="dashed">
- Button text
- </Button>
- <Button {...args} size="large" type="outline">
- Button text
- </Button>
- <Button {...args} size="large" type="danger">
- Button text
- </Button>
- <Button {...args} size="large" type="warning">
- Button text
- </Button>
- </div>
- <div className="flex space-x-4">
- <Button {...args} size="xlarge">
- Button text
- </Button>
- <Button {...args} size="xlarge" type="default">
- Button text
- </Button>
- <Button {...args} size="xlarge" type="secondary">
- Button text
- </Button>
- <Button {...args} size="xlarge" type="alternative">
- Button text
- </Button>
- <Button {...args} size="xlarge" type="link">
- Button text
- </Button>
- <Button {...args} size="xlarge" type="text">
- Button text
- </Button>
- <Button {...args} size="xlarge" type="dashed">
- Button text
- </Button>
- <Button {...args} size="xlarge" type="outline">
- Button text
- </Button>
- <Button {...args} size="xlarge" type="danger">
- Button text
- </Button>
- <Button {...args} size="xlarge" type="warning">
- Button text
- </Button>
- </div>
- </div>
- </>
-)
-
-export const withCustomTag = (args: any) => <Button {...args}>Button text</Button>
-
-const icon = <IconPackage />
-
-withIcon.args = {
- type: 'primary',
- icon: icon,
-}
-
-withIconRight.args = {
- type: 'primary',
- iconRight: <IconChevronRight strokeWidth={2} />,
-}
-
-withStyles.args = {
- type: 'primary',
- style: { backgroundColor: 'red', color: 'yellow' },
-}
-
-withBlock.args = {
- type: 'primary',
- block: true,
-}
-
-withOnlyIcon.args = {
- icon: icon,
-}
-
-withOnlyLoading.args = {
- loading: true,
-}
-
-withLoadingCentered.args = {
- loading: true,
- loadingCentered: true,
-}
-
-allButtons.args = {
- loading: false,
- danger: false,
-}
-
-withCustomTag.args = {
- as: 'span',
+export default meta
+
+// export default {
+// title: 'General/Button',
+// component: Button,
+// }
+
+type Story = StoryObj<typeof Button>
+
+/*
+ *👇 Render functions are a framework specific feature to allow you control on how the component renders.
+ * See https://storybook.js.org/docs/react/api/csf
+ * to learn how to use render functions.
+ */
+
+export const Primary = {
+ args: {
+ children: 'Hello world',
+ type: 'primary',
+ },
+ render: ({ children, type }: ButtonProps) => <Button type={type}>{children}</Button>,
+}
+export const Default = {
+ args: {
+ children: 'Hello world',
+ type: 'default',
+ },
+ render: ({ children, type }: ButtonProps) => <Button type={type}>{children}</Button>,
+}
+
+export const Alternative = {
+ args: {
+ children: 'Hello world',
+ type: 'alternative',
+ },
+ render: ({ children, type }: ButtonProps) => <Button type={type}>{children}</Button>,
+}
+
+export const Outline = {
+ args: {
+ children: 'Hello world',
+ type: 'outline',
+ },
+ render: ({ children, type }: ButtonProps) => <Button type={type}>{children}</Button>,
+}
+
+export const Secondary = {
+ args: {
+ children: 'Hello world',
+ type: 'secondary',
+ },
+ render: ({ children, type }: ButtonProps) => <Button type={type}>{children}</Button>,
+}
+
+export const Dashed = {
+ args: {
+ children: 'Hello world',
+ type: 'dashed',
+ },
+ render: ({ children, type }: ButtonProps) => <Button type={type}>{children}</Button>,
+}
+
+export const Link = {
+ args: {
+ children: 'Hello world',
+ type: 'link',
+ },
+ render: ({ children, type }: ButtonProps) => <Button type={type}>{children}</Button>,
+}
+
+export const Text = {
+ args: {
+ children: 'Hello world',
+ type: 'text',
+ },
+ render: ({ children, type }: ButtonProps) => <Button type={type}>{children}</Button>,
+}
+
+export const Danger = {
+ args: {
+ children: 'Hello world',
+ type: 'danger',
+ },
+ render: ({ children, type }: ButtonProps) => <Button type={type}>{children}</Button>,
+}
+
+export const Block = {
+ args: {
+ children: 'Hello world',
+ type: 'primary',
+ block: true,
+ },
+ render: ({ children, type, block }: ButtonProps) => (
+ <Button block type={type}>
+ {children}
+ </Button>
+ ),
+}
+
+export const Disabled = {
+ args: {
+ children: 'Hello world',
+ type: 'primary',
+ disabled: true,
+ },
+ render: ({ children, type, disabled }: ButtonProps) => (
+ <Button disabled type={type}>
+ {children}
+ </Button>
+ ),
+}
+
+export const Sizes = {
+ args: {
+ children: 'Change the size below',
+ type: 'primary',
+ size: 'large',
+ },
+ render: ({ children, type, size }: ButtonProps) => (
+ <Button size={size} type={type}>
+ {children}
+ </Button>
+ ),
+}
+
+export const LeftIcon = {
+ args: {
+ children: 'Change the size below',
+ type: 'primary',
+ iconLeft: <IconAirplay />,
+ },
+ render: ({ children, type, iconLeft }: ButtonProps) => (
+ <Button iconLeft={iconLeft} type={type}>
+ {children}
+ </Button>
+ ),
+}
+
+export const RightIcon = {
+ args: {
+ children: 'Change the size below',
+ type: 'primary',
+ iconRight: <IconAirplay />,
+ },
+ render: ({ children, type, iconRight }: ButtonProps) => (
+ <Button iconRight={iconRight} type={type}>
+ {children}
+ </Button>
+ ),
+}
+
+export const Loading = {
+ args: {
+ children: 'Change the size below',
+ type: 'primary',
+ loading: true,
+ },
+ render: ({ children, type, loading }: ButtonProps) => (
+ <Button loading={loading} type={type}>
+ {children}
+ </Button>
+ ),
}
diff --git a/packages/ui/src/components/Button/Button.tsx b/packages/ui/src/components/Button/Button.tsx
index ba48a5d2463..a70c9b393c1 100644
--- a/packages/ui/src/components/Button/Button.tsx
+++ b/packages/ui/src/components/Button/Button.tsx
@@ -103,7 +103,7 @@ const buttonVariantsNew = cva(
shadow-sm`,
},
block: {
- default: 'w-full flex items-center justify-center',
+ true: 'w-full flex items-center justify-center',
},
size: {
...sizes,
@@ -149,10 +149,10 @@ export interface ButtonProps
}
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
- ({ asChild = false, ...props }, ref) => {
+ ({ asChild = false, size = 'small', type = 'primary', ...props }, ref) => {
const Comp = asChild ? Slot : 'button'
- const { className, type, disabled, size, loading, icon, iconLeft, iconRight } = props
+ const { className, disabled, loading, icon, iconLeft, iconRight } = props
const showIcon = loading || icon
@@ -189,8 +189,4 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
Button.displayName = 'Button'
-function Test() {
- return <Button as={'input'}></Button>
-}
-
export { Button, buttonVariantsNew }