Skip to content

Commit

Permalink
add example of controlled dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
PixeledCode committed Jun 14, 2024
1 parent 35ad528 commit 762761b
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/opub-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "opub-ui",
"description": "OPub UI Library",
"version": "0.3.30",
"version": "0.3.31",
"private": false,
"license": "MIT",
"author": "CivicDataLab <tech@civicdatalab.in>",
Expand Down
35 changes: 35 additions & 0 deletions packages/opub-ui/src/components/Dialog/Dialog.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React from 'react';
import { Meta, StoryObj } from '@storybook/react';

import { Button } from '../Button';
Expand Down Expand Up @@ -43,6 +44,40 @@ export const Default: Story = {
},
};

export const Controlled: Story = {
render: ({ ...args }) => {
const [open, setOpen] = React.useState(false);
return (
<div>
<Button
onClick={() => {
setOpen(true);
}}
>
Open Dialog
</Button>
<Dialog open={open} onOpenChange={setOpen}>
<Dialog.Content {...args} />
</Dialog>
</div>
);
},
args: {
title: 'Dialog Title',
children: 'Make changes to your profile here. Click save when youre done.',
primaryAction: {
content: 'Add Instagram',
onAction: () => console.log('Add Instagram'),
},
secondaryActions: [
{
content: 'Learn more',
onAction: () => console.log('Learn more'),
},
],
},
};

export const Large: Story = {
...Default,
args: {
Expand Down
3 changes: 2 additions & 1 deletion packages/opub-ui/src/components/TextField/TextField.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';

import { TextFieldProps } from '../../types/input';
import { Input } from '../Input/Input';
import React from 'react';

export type Props = TextFieldProps & {
name: string;
Expand Down

0 comments on commit 762761b

Please sign in to comment.