Skip to content

Commit

Permalink
feat: Add WIP button
Browse files Browse the repository at this point in the history
  • Loading branch information
Joel Anton committed Jun 6, 2024
1 parent ea9fe84 commit 81c21d8
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 0 deletions.
55 changes: 55 additions & 0 deletions libs/novui/src/components/button/Button.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import React from 'react';
import { StoryFn, Meta } from '@storybook/react';
import { Button } from './Button';
import { Flex } from '../../../styled-system/jsx';
import { Icon10K, IconInfo } from '../../icons';

export default {
title: 'Components/Button',
component: Button,
argTypes: {},
} as Meta<typeof Button>;

const Template: StoryFn<typeof Button> = ({ ...args }) => <Button {...args}>Click Me</Button>;

export const Default = Template.bind({});
Default.args = {};

export const Loading = Template.bind({});
Loading.args = {
loading: true,
};

export const icon = () => (
<Flex>
<Button size="lg" Icon={Icon10K}>
Large
</Button>
<Button Icon={IconInfo}>Medium</Button>
</Flex>
);

export const filled = () => (
<Flex>
<Button size="lg">Large</Button>
<Button>Medium</Button>
</Flex>
);

export const outline = () => (
<Flex>
<Button size="lg" variant="outline">
Large
</Button>
<Button variant="outline">Medium</Button>
</Flex>
);

export const disabled = () => (
<Flex>
<Button disabled>Filled</Button>
<Button variant="outline" disabled>
Outline
</Button>
</Flex>
);
25 changes: 25 additions & 0 deletions libs/novui/src/components/button/Button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { FC } from 'react';
import { CorePropsWithChildren } from '../../types';
import { Button as ExternalButton, ButtonProps } from '@mantine/core';
import { IconType } from '../../icons';
import { css } from '../../../styled-system/css';

export interface IButtonProps
extends CorePropsWithChildren,
React.ButtonHTMLAttributes<HTMLButtonElement>,
Pick<ButtonProps, 'size' | 'variant'> {
Icon?: IconType;
}

export const Button: FC<IButtonProps> = ({ children, Icon, size = 'md', variant = 'filled', ...buttonProps }) => {
return (
<ExternalButton
size={size}
leftSection={Icon ? <Icon title="button-icon" size="16" className={css({ color: 'legacy.white' })} /> : undefined}
variant={variant}
{...buttonProps}
>
{children}
</ExternalButton>
);
};
1 change: 1 addition & 0 deletions libs/novui/src/components/button/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './Button';

0 comments on commit 81c21d8

Please sign in to comment.