Skip to content

Commit

Permalink
feat: import denhaag button
Browse files Browse the repository at this point in the history
  • Loading branch information
Borai committed Jul 3, 2024
1 parent fdf1710 commit 286e6c3
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 25 deletions.
6 changes: 6 additions & 0 deletions components/Modal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,11 @@
"build": "rollup -c ../../rollup.config.mjs",
"clean": "rimraf dist tsconfig.tsbuildinfo",
"watch:components": "chokidar --silent --follow-symlinks \"src/**/*\" -c \"pnpm run build\""
},
"dependencies": {
"@gemeente-denhaag/button": "workspace:*"
},
"peerDependencies": {
"react": "^18.0.0"
}
}
20 changes: 4 additions & 16 deletions components/Modal/src/ModalFooter.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import React from 'react';
import clsx from 'clsx';
import Button, { ButtonProps } from '@gemeente-denhaag/button';

export interface ModalAction {
label: string;
type?: 'secondary';
onClick?: () => void;
}
export interface ModalAction extends ButtonProps {}

export interface ModalFooterProps {
actions?: ModalAction[];
Expand All @@ -16,16 +12,8 @@ export const ModalFooter = ({ actions }: ModalFooterProps) => {

return (
<footer className="denhaag-modal__footer">
{actions.map((action) => (
<button
key={action.label}
className={clsx('denhaag-button', {
'denhaag-button--secondary-action': action.type === 'secondary',
})}
onClick={action.onClick}
>
{action.label}
</button>
{actions.map((action, index) => (
<Button key={`modal-footer-action-${index}`} {...action} />
))}
</footer>
);
Expand Down
8 changes: 4 additions & 4 deletions packages/storybook/src/css/Modal.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ export const Actions: Story = {
args: {
actions: [
{
label: 'Confirm',
children: 'Confirm',
onClick: () => console.log('Confirm'),
},
{
label: 'Cancel',
type: 'secondary',
children: 'Cancel',
variant: 'secondary-action',
onClick: () => console.log('Cancel'),
},
],
Expand Down Expand Up @@ -105,7 +105,7 @@ export const Button = () => {
title="Modal title"
open={open}
onToggle={setOpen}
actions={[{ label: 'Sluiten', onClick: () => setOpen(false) }]}
actions={[{ children: 'Sluiten', onClick: () => setOpen(false) }]}
>
<>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam tincidunt, quam eu ultrices lacinia, lorem
Expand Down
8 changes: 4 additions & 4 deletions packages/storybook/src/react/Modal.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ export const Actions: Story = {
args: {
actions: [
{
label: 'Confirm',
children: 'Confirm',
onClick: () => console.log('Confirm'),
},
{
label: 'Cancel',
type: 'secondary',
children: 'Cancel',
variant: 'secondary-action',
onClick: () => console.log('Cancel'),
},
],
Expand Down Expand Up @@ -105,7 +105,7 @@ export const Button = () => {
title="Modal title"
open={open}
onToggle={setOpen}
actions={[{ label: 'Sluiten', onClick: () => setOpen(false) }]}
actions={[{ children: 'Sluiten', onClick: () => setOpen(false) }]}
>
<>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam tincidunt, quam eu ultrices lacinia, lorem
Expand Down
9 changes: 8 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 286e6c3

Please sign in to comment.