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

fix: storybook #125

Merged
merged 6 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ O projeto é um monorepo, que foi criado utilizando o [Turborepo](https://turbo.

Projeto onde são desenvolvidas as documentações dos components do Visu. Utilizando principalmente o [Storybook](https://storybook.js.org/). Os componentes documentados são baseados no último build feito na biblioteca, então é necessários que haja pelo menos um build antes de documentar os componentes.

_**Importante:** Antes de criar/modificar uma story de qualquer componente **SEMPRE** construa o Visu e execute o comando `npm run install` para atualizar as dependências do Storybook (especialmente o Visu)_

### Package

Projeto onde são desenvolvidos os componentes e o design system da biblioteca Visu. O projeto utiliza principalmente [Vite](https://vitejs.dev), [React](https://react.dev/) e [Tailwindcss](https://tailwindcss.com/).
Expand Down
4 changes: 2 additions & 2 deletions docs/.storybook/manager.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { addons } from '@storybook/addons'
import theme from './theme.js'
import { themes } from '@storybook/theming';

addons.setConfig({
theme,
theme: themes.dark,

sidebar: {
showRoots: false,
Expand Down
4 changes: 2 additions & 2 deletions docs/.storybook/preview.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import theme from './theme.js'
import { themes } from '@storybook/theming';

import '@droz-js/visu/styles'

Expand All @@ -13,7 +13,7 @@ export const parameters = {
},
},
docs: {
theme,
theme: themes.dark,
},
backgrounds: {
default: 'Light',
Expand Down
10 changes: 0 additions & 10 deletions docs/.storybook/theme.js

This file was deleted.

29 changes: 29 additions & 0 deletions docs/src/index.stories.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { Meta } from '@storybook/blocks';

<Meta title="Início" />

![Visu](./visu.svg)

<br/><br/><br/>

## Welcome!
Visu is a component library and design system developed for Coaktion products.
Use the browser sidebar to chose between Visu components and test them using the Storybook playground

## Important
Before create/modify a component story *ALWAYS* build Visu and run _npm install_ to update Storybook dependencies (specially Visu)

## Installing
Install the library in a React project with the command _npm i @droz-js/visu_

## Configuration
Visu is built using Tailwind CSS as a basis for styling components, making it work in different environments. Based on this, there are 2 ways to install Visu to your project

- ### Project *WITH* Tailwindcss
To use in projects **WITH** Tailwindcss it is necessary to import the styling of _@droz-js/visu/dist/theme-plugin_ as a **plugin** and _@droz-js/visu/dist/visu.es.js_ needs to be added to **content** in your _tailwind.config.js_ file.

- ### Project *WITHOUT* Tailwindcss
To use in projects **WITHOUT** Tailwindcss, you need to import the styling from _@droz-js/visu/styles_ into your global styles file.

## Using
Once the library is configured, simply import a component and add it to the project.
30 changes: 24 additions & 6 deletions docs/src/stories/Accordion/Root.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ export const Single: AccordionRootStory = {
render: (args: AccordionRootProps) => {
return (
<Accordion.Root {...args}>
<Accordion.Item value="default1">
<Accordion.Item
value="default1"
style={{ width: '20rem', marginBlock: '0.5rem' }}
>
<Accordion.Header>
<span>Accordion</span>
<Accordion.Trigger />
Expand All @@ -66,7 +69,10 @@ export const Single: AccordionRootStory = {
</span>
</Accordion.Content>
</Accordion.Item>
<Accordion.Item value="default2">
<Accordion.Item
value="default2"
style={{ width: '20rem', marginBlock: '0.5rem' }}
>
<Accordion.Header>
<span>Accordion</span>
<Accordion.Trigger />
Expand All @@ -80,7 +86,10 @@ export const Single: AccordionRootStory = {
</span>
</Accordion.Content>
</Accordion.Item>
<Accordion.Item value="default3">
<Accordion.Item
value="default3"
style={{ width: '20rem', marginBlock: '0.5rem' }}
>
<Accordion.Header>
<span>Accordion</span>
<Accordion.Trigger />
Expand All @@ -106,7 +115,10 @@ export const Multiple: AccordionRootStory = {
render: (args: AccordionRootProps) => {
return (
<Accordion.Root {...args}>
<Accordion.Item value="default1">
<Accordion.Item
value="default1"
style={{ width: '20rem', marginBlock: '0.5rem' }}
>
<Accordion.Header>
<span>Accordion</span>
<Accordion.Trigger />
Expand All @@ -120,7 +132,10 @@ export const Multiple: AccordionRootStory = {
</span>
</Accordion.Content>
</Accordion.Item>
<Accordion.Item value="default2">
<Accordion.Item
value="default2"
style={{ width: '20rem', marginBlock: '0.5rem' }}
>
<Accordion.Header>
<span>Accordion</span>
<Accordion.Trigger />
Expand All @@ -134,7 +149,10 @@ export const Multiple: AccordionRootStory = {
</span>
</Accordion.Content>
</Accordion.Item>
<Accordion.Item value="default3">
<Accordion.Item
value="default3"
style={{ width: '20rem', marginBlock: '0.5rem' }}
>
<Accordion.Header>
<span>Accordion</span>
<Accordion.Trigger />
Expand Down
2 changes: 1 addition & 1 deletion docs/src/stories/Dialog/Body.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const meta: Meta<DialogBodyProps> = {
(Story) => (
<Dialog.Root>
<Dialog.Trigger asChild>
<Button.Root>Dialog</Button.Root>
<Button>Dialog</Button>
</Dialog.Trigger>
<Dialog.Content>
<Story />
Expand Down
6 changes: 3 additions & 3 deletions docs/src/stories/Dialog/Close.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const meta: Meta<DialogCloseProps> = {
(Story) => (
<Dialog.Root>
<Dialog.Trigger asChild>
<Button.Root>Dialog</Button.Root>
<Button>Dialog</Button>
</Dialog.Trigger>
<Dialog.Content>
<Dialog.Footer>
Expand Down Expand Up @@ -78,9 +78,9 @@ export const BotaoComoFilho: DialogCloseStory = {
args: {
asChild: true,
children: (
<Button.Root variant="secondary" ghost>
<Button variant="secondary" ghost>
Fechar
</Button.Root>
</Button>
),
},
render: (args) => {
Expand Down
2 changes: 1 addition & 1 deletion docs/src/stories/Dialog/Content.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const meta: Meta<DialogContentProps> = {
(Story) => (
<Dialog.Root>
<Dialog.Trigger asChild>
<Button.Root>Dialog</Button.Root>
<Button>Dialog</Button>
</Dialog.Trigger>
<Story />
</Dialog.Root>
Expand Down
6 changes: 3 additions & 3 deletions docs/src/stories/Dialog/Footer.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const meta: Meta<DialogFooterProps> = {
(Story) => (
<Dialog.Root>
<Dialog.Trigger asChild>
<Button.Root>Dialog</Button.Root>
<Button>Dialog</Button>
</Dialog.Trigger>
<Dialog.Content>
<Dialog.Body />
Expand Down Expand Up @@ -73,9 +73,9 @@ export const ComBotoesFinal: DialogFooterStory = {
args: {
align: 'right',
children: [
<Button.Root key="confirmar">Confirmar</Button.Root>,
<Button key="confirmar">Confirmar</Button>,
<Dialog.Close key="cancelar" asChild>
<Button.Root ghost>Cancelar</Button.Root>
<Button ghost>Cancelar</Button>
</Dialog.Close>,
],
},
Expand Down
2 changes: 1 addition & 1 deletion docs/src/stories/Dialog/Header.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const meta: Meta<DialogHeaderProps> = {
(Story) => (
<Dialog.Root>
<Dialog.Trigger asChild>
<Button.Root>Dialog</Button.Root>
<Button>Dialog</Button>
</Dialog.Trigger>
<Dialog.Content>
<Story />
Expand Down
8 changes: 4 additions & 4 deletions docs/src/stories/Dialog/Root.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export const Default: DialogRootStory = {
args: {
children: [
<Dialog.Trigger key={''}>
<Button.Root>Dialog</Button.Root>
<Button>Dialog</Button>
</Dialog.Trigger>,

<Dialog.Content key={''}></Dialog.Content>,
Expand All @@ -101,7 +101,7 @@ export const Full: DialogRootStory = {
args: {
children: [
<Dialog.Trigger key={''}>
<Button.Root>Dialog</Button.Root>
<Button>Dialog</Button>
</Dialog.Trigger>,

<Dialog.Content key={''}>
Expand Down Expand Up @@ -160,9 +160,9 @@ export const Full: DialogRootStory = {
</Dialog.Body>

<Dialog.Footer>
<Button.Root>Confirmar</Button.Root>
<Button>Confirmar</Button>
<Dialog.Close asChild>
<Button.Root ghost>Cancelar</Button.Root>
<Button ghost>Cancelar</Button>
</Dialog.Close>
</Dialog.Footer>
</Dialog.Content>,
Expand Down
2 changes: 1 addition & 1 deletion docs/src/stories/Dialog/Trigger.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ type DialogTriggerStory = StoryObj<DialogTriggerProps>

export const Comum: DialogTriggerStory = {
args: {
children: <Button.Root>Dialog Trigger</Button.Root>,
children: <Button>Dialog Trigger</Button>,
},
render: (args) => {
return <Dialog.Trigger {...args}></Dialog.Trigger>
Expand Down
4 changes: 1 addition & 3 deletions docs/src/stories/FloatCard/Content.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ export const Comum: FloatCardContentStory = {
</FloatCard.Trigger>
<FloatCard.Content {...args}>
<div className="flex flex-col">
<Avatar.Root>
<Avatar.Fallback fallback="FC" />
</Avatar.Root>
<Avatar fallback="FC" />
<span>
O FloatCard é utilizado para estruturas mais complexas do que um
Tooltip.
Expand Down
4 changes: 1 addition & 3 deletions docs/src/stories/FloatCard/Root.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ export const Comum: FloatCardRootStory = {
</FloatCard.Trigger>
<FloatCard.Content>
<div className="flex flex-col">
<Avatar.Root>
<Avatar.Fallback fallback="FC" />
</Avatar.Root>
<Avatar fallback="FC" />
<span>
O FloatCard é utilizado para estruturas mais complexas do que um
Tooltip.
Expand Down
12 changes: 3 additions & 9 deletions docs/src/stories/FloatCard/Trigger.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ export const Comum: FloatCardRootStory = {
</FloatCard.Trigger>
<FloatCard.Content>
<div className="flex flex-col">
<Avatar.Root>
<Avatar.Fallback fallback="FC" />
</Avatar.Root>
<Avatar fallback="FC" />
<span>
O FloatCard é utilizado para estruturas mais complexas do que um
Tooltip.
Expand All @@ -61,16 +59,12 @@ export const ComComponente: FloatCardRootStory = {
<FloatCard.Root>
<FloatCard.Trigger {...args}>
<div>
<Avatar.Root>
<Avatar.Fallback fallback="FC" />
</Avatar.Root>
<Avatar fallback="FC" />
</div>
</FloatCard.Trigger>
<FloatCard.Content>
<div className="flex flex-col">
<Avatar.Root>
<Avatar.Fallback fallback="FC" />
</Avatar.Root>
<Avatar fallback="FC" />
<span>
O FloatCard é utilizado para estruturas mais complexas do que um
Tooltip.
Expand Down
4 changes: 2 additions & 2 deletions docs/src/stories/Toast/Provider.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export const Comum: ToastStory = {
const { toast } = useToast()

return (
<Button.Root
<Button
onClick={() =>
toast.success({
desc: 'Descrição do toast',
Expand All @@ -76,7 +76,7 @@ export const Comum: ToastStory = {
{...args}
>
Abrir toast
</Button.Root>
</Button>
)
},
}
12 changes: 3 additions & 9 deletions docs/src/stories/Toast/Root.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ export const Alert: ToastStory = {
render: (args) => {
const { toast } = useToast()

return (
<Button.Root onClick={() => toast.alert(args)}>Abrir toast</Button.Root>
)
return <Button onClick={() => toast.alert(args)}>Abrir toast</Button>
},
}

Expand All @@ -61,9 +59,7 @@ export const Error: ToastStory = {
render: (args) => {
const { toast } = useToast()

return (
<Button.Root onClick={() => toast.error(args)}>Abrir toast</Button.Root>
)
return <Button onClick={() => toast.error(args)}>Abrir toast</Button>
},
}

Expand All @@ -72,8 +68,6 @@ export const Success: ToastStory = {
render: (args) => {
const { toast } = useToast()

return (
<Button.Root onClick={() => toast.success(args)}>Abrir toast</Button.Root>
)
return <Button onClick={() => toast.success(args)}>Abrir toast</Button>
},
}
Loading
Loading