diff --git a/.storybook/preview.scss b/.storybook/preview.scss index cabd21d..5d59a5e 100644 --- a/.storybook/preview.scss +++ b/.storybook/preview.scss @@ -1,52 +1,4 @@ -/* stylelint-disable no-invalid-position-at-import-rule */ -/* stylelint-disable selector-class-pattern */ -@use "../packages/kubrick/scss/base"; -@import '../wordpress/wp-includes/css/dashicons.min.css'; -@import '../wordpress/wp-admin/css/common.min.css'; -@import '../wordpress/wp-admin/css/edit.min.css'; -@import '../wordpress/wp-includes/css/buttons.min.css'; -@import "../wordpress/wp-admin/css/forms.min.css"; - -// Default. -.admin-color-modern { - @import "../wordpress/wp-admin/css/colors/modern/colors"; -} - -.admin-color-blue { - @import "../wordpress/wp-admin/css/colors/blue/colors"; -} - -.admin-color-coffee { - @import "../wordpress/wp-admin/css/colors/coffee/colors"; -} - -.admin-color-ectoplasm { - @import "../wordpress/wp-admin/css/colors/ectoplasm/colors"; -} - -.admin-color-light { - @import "../wordpress/wp-admin/css/colors/light/colors"; -} - -.admin-color-midnight { - @import "../wordpress/wp-admin/css/colors/midnight/colors"; -} - -.admin-color-ocean { - @import "../wordpress/wp-admin/css/colors/ocean/colors"; -} - -.admin-color-sunrise { - @import "../wordpress/wp-admin/css/colors/sunrise/colors"; -} - -.__wp-core-body__ { - min-width: 600px; - font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif; - line-height: 1.4em; - color: #3c434a; - background: var(--kubrick-body-background-color); -} +@use "../packages/kubrick/scss/preview"; // TODO: Remove this once there's a more reliable way to not affect the Storybook styles. .docblock-argstable-body { diff --git a/packages/kubrick/scss/preview.scss b/packages/kubrick/scss/preview.scss new file mode 100644 index 0000000..0e05338 --- /dev/null +++ b/packages/kubrick/scss/preview.scss @@ -0,0 +1,49 @@ +/* stylelint-disable no-invalid-position-at-import-rule */ +/* stylelint-disable selector-class-pattern */ +@use './base'; +@use '../../../wordpress/wp-includes/css/dashicons.css'; +@use '../../../wordpress/wp-includes/css/buttons.css'; +@use '../../../wordpress/wp-admin/css/common.css'; +@use '../../../wordpress/wp-admin/css/edit.css'; +@use "../../../wordpress/wp-admin/css/forms.css"; + +// Default. +.admin-color-modern { + @import "../../../wordpress/wp-admin/css/colors/modern/colors"; +} + +.admin-color-blue { + @import "../../../wordpress/wp-admin/css/colors/blue/colors"; +} + +.admin-color-coffee { + @import "../../../wordpress/wp-admin/css/colors/coffee/colors"; +} + +.admin-color-ectoplasm { + @import "../../../wordpress/wp-admin/css/colors/ectoplasm/colors"; +} + +.admin-color-light { + @import "../../../wordpress/wp-admin/css/colors/light/colors"; +} + +.admin-color-midnight { + @import "../../../wordpress/wp-admin/css/colors/midnight/colors"; +} + +.admin-color-ocean { + @import "../../../wordpress/wp-admin/css/colors/ocean/colors"; +} + +.admin-color-sunrise { + @import "../../../wordpress/wp-admin/css/colors/sunrise/colors"; +} + +.__wp-core-body__ { + min-width: 600px; + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif; + line-height: 1.4em; + color: #3c434a; + background: var(--kubrick-body-background-color); +} diff --git a/packages/kubrick/src/Button/Button.stories.tsx b/packages/kubrick/src/Button/Button.stories.tsx index c4e61ab..59c9b65 100644 --- a/packages/kubrick/src/Button/Button.stories.tsx +++ b/packages/kubrick/src/Button/Button.stories.tsx @@ -104,6 +104,14 @@ export const Disabled: Story = { }, }; +export const Loading: Story = { + args: { + children: 'Loading...', + isDisabled: true, + prefix: , + }, +}; + export const WithPrefix: Story = { args: { children: 'Upload', @@ -118,12 +126,4 @@ export const WithSuffix: Story = { }, }; -export const WithSpinner: Story = { - args: { - children: 'Loading...', - isDisabled: true, - prefix: , - }, -}; - export default meta; diff --git a/packages/kubrick/src/Providers/PreviewProvider.tsx b/packages/kubrick/src/Providers/PreviewProvider.tsx new file mode 100644 index 0000000..d2a8068 --- /dev/null +++ b/packages/kubrick/src/Providers/PreviewProvider.tsx @@ -0,0 +1,20 @@ +import '../../scss/preview.scss'; +import { useClasses } from '../useClasses'; + +interface PreviewProviderProps { + children: React.ReactNode; + className?: string; +} + +export const PreviewProvider = ({ + children, + className, +}: PreviewProviderProps) => { + const { clsx } = useClasses('PreviewProvider'); + + return ( +
+
{children}
+
+ ); +}; diff --git a/packages/kubrick/src/Providers/index.ts b/packages/kubrick/src/Providers/index.ts new file mode 100644 index 0000000..3964c12 --- /dev/null +++ b/packages/kubrick/src/Providers/index.ts @@ -0,0 +1 @@ +export * from './PreviewProvider'; diff --git a/packages/kubrick/src/index.ts b/packages/kubrick/src/index.ts index f062ae3..f443a8a 100644 --- a/packages/kubrick/src/index.ts +++ b/packages/kubrick/src/index.ts @@ -10,6 +10,7 @@ export * from './IconLinkButton'; export * from './Link'; export * from './LinkButton'; export * from './Notice'; +export * from './Providers'; export * from './RadioGroup'; export * from './SearchField'; export * from './Select'; diff --git a/site/src/content/docs/components/box.mdx b/site/src/content/docs/components/box.mdx index 413f73f..6f21650 100644 --- a/site/src/content/docs/components/box.mdx +++ b/site/src/content/docs/components/box.mdx @@ -69,10 +69,10 @@ You can also add a footer section to the box by adding the `footer` prop. Though component="Box" prefix="kubrick-Box-" items={[ - [ 'root', 'The root element of the box.' ], - [ 'header', 'The header section containing the title and toggle button.' ], - [ 'title', 'The element that wraps the title of the box.' ], - [ 'content', 'The content section of the box.' ], - [ 'footer', 'The footer section of the box.' ], + ["root", "The root element of the box."], + ["header", "The header section containing the title and toggle button."], + ["title", "The element that wraps the title of the box."], + ["content", "The content section of the box."], + ["footer", "The footer section of the box."], ]} /> diff --git a/site/src/content/docs/components/button.mdx b/site/src/content/docs/components/button.mdx index 99f93cb..a2dfa40 100644 --- a/site/src/content/docs/components/button.mdx +++ b/site/src/content/docs/components/button.mdx @@ -4,38 +4,50 @@ description: Learn how to use the Button component in your WordPress admin appli --- import { Aside } from '@astrojs/starlight/components'; +import Lead from "../../templates/Lead.astro"; +import Table from "../../templates/Table.astro"; -The `Button` component represents the HTML `button` element to trigger an action or event with mouse, touch, or keyboard. It comes in different styles and sizes that you can choose from. You can also add icons or other type of content before or after the button label. + +The `Button` component is similar to the HTML `button` element, but with some additional features and flexibilities. You can use this component to allow users to trigger actions or events through clicks, touch, or keyboard input. + ## Usage -Import the `Button` component from the package: +To use the component, import `Button` from the package: ```jsx import { Button } from '@syntatis/kubrick'; ``` -To use it in your application, you can add it the same as you would with a native HTML `button` element: +You can then add it to your app just like a regular HTML `button` element: ```jsx ``` -Similar to the native HTML `button` element, the `Button` component will be rendered as the `button` type by default. You can change the type with the `type` prop, for example, to render it as a `submit` button: +### Type + +By default, the `Button` component behaves like a standard HTML `button`. You can change the button type using the `type` prop, for example, to make it a `submit` button: ```jsx ``` -You can also make the button disabled by passing the `isDisabled` prop. This is useful when the button should not be clickable, for example, when the form is not valid or when the user does not have the right permission to perform the action. +### Disabled + +To disable the button, use the `isDisabled` prop. This is helpful when the button shouldn't be clickable, such as when a form is incomplete or the user lacks permission to perform an action. ```jsx ``` + + ### Variants -The `Button` component comes with different variants that you can choose from. The default variant is `primary`, but you can change it to `link`, `link-danger`, and `secondary` to match the button appearance with its function. +The `Button` component comes with different style variants, and can be customized using the `variant` prop. The default variant of the component is `primary`, but you can switch to `link`, `link-danger`, or `secondary` to suit the button's role. ```jsx @@ -43,7 +55,7 @@ The `Button` component comes with different variants that you can choose from. T ### Sizes -Aside of the variants, the `Button` component also comes with different sizes that you can choose from. You can change it to `small`, `large`, and `hero` to match the appareance with its significance or with the surrounding sizes. +You can also choose from different button sizes. You can change it using the `size` prop to `small`, `large`, or `hero` following on the context or importance of the button. ```jsx @@ -53,28 +65,22 @@ Aside of the variants, the `Button` component also comes with different sizes th The `Button` components comes with `prefix` and `suffix` props to to allow you to add content before or after the button label. You can add any type of content, but typically you would use these props to add icons. -Kubrick UI does not come with its own icon library. You can use any icon library you prefer, though we recommend using the [`@wordpress/icons`](https://developer.wordpress.org/block-editor/reference-guides/packages/packages-icons/) or [Dashicons](https://developer.wordpress.org/resource/dashicons/) to make your WordPress admin application remains consistent with the WordPress admin interface. - ```jsx -import { Icon } from '@wordpress/icons'; +import { Icon, edit } from '@wordpress/icons'; - -``` - -#### Using Dashicons - -The Dashicons icons are integrated into the WordPress admin interface. You can use them in your WordPress admin application by adding the Dashicons class to the `span` element, for example: -```jsx - ``` -