diff --git a/apps/frontend/src/stories/Tag.stories.ts b/apps/frontend/src/stories/Tag.stories.ts new file mode 100644 index 0000000..0c10724 --- /dev/null +++ b/apps/frontend/src/stories/Tag.stories.ts @@ -0,0 +1,50 @@ +import type { Meta, StoryObj } from '@storybook/react'; + +import { Tag } from './Tag'; + +// More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export +const meta = { + title: 'Example/Tag', + component: Tag, + parameters: { + // Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout + layout: 'centered', + }, + // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs + tags: ['autodocs'], + // More on argTypes: https://storybook.js.org/docs/api/argtypes + argTypes: { + backgroundColor: { control: 'color' }, + }, +} satisfies Meta; + +export default meta; +type Story = StoryObj; + +// More on writing stories with args: https://storybook.js.org/docs/writing-stories/args +export const Selected: Story = { + args: { + selected: true, + label: 'This is a selected tag', + }, +}; + +export const Unselected: Story = { + args: { + label: 'This tag is not selected', + }, +}; + +export const Large: Story = { + args: { + size: 'large', + label: 'Simple large tag', + }, +}; + +export const Small: Story = { + args: { + size: 'small', + label: 'Small tag', + }, +}; diff --git a/apps/frontend/src/stories/Tag.tsx b/apps/frontend/src/stories/Tag.tsx new file mode 100644 index 0000000..277a526 --- /dev/null +++ b/apps/frontend/src/stories/Tag.tsx @@ -0,0 +1,47 @@ +import React from 'react'; +import './tag.css'; + +interface TagProps { + /** + * Is this the principal call to action on the page? + */ + selected?: boolean; + /** + * What background color to use + */ + backgroundColor?: string; + /** + * How large should the button be? + */ + size?: 'small' | 'medium' | 'large'; + /** + * Button contents + */ + label: string; + /** + * Optional click handler + */ + onClick?: () => void; +} + +/** + * Primary UI component for user interaction + */ +export const Tag = ({ + selected = false, + size = 'medium', + backgroundColor, + label, + ...props +}: TagProps) => { + const mode = selected ? 'storybook-tag--selected' : 'storybook-tag-unselected'; + return ( +
+ {label} +
+ ); +}; diff --git a/apps/frontend/src/stories/tag.css b/apps/frontend/src/stories/tag.css new file mode 100644 index 0000000..74bff40 --- /dev/null +++ b/apps/frontend/src/stories/tag.css @@ -0,0 +1,32 @@ +.storybook-tag { + font-family: 'Nunito Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif; + font-weight: 700; + border: 0; + border-radius: 3em; + cursor: pointer; + display: inline-block; + line-height: 1; +} +.storybook-tag-unselected { + color: #000048; + background-color: white; + border: 1px solid #000048;; +} +.storybook-tag-unselected:hover, +.storybook-tag--selected { + color: white; + background-color: #000048;; + border: 1px solid white; +} +.storybook-tag--small { + font-size: 12px; + padding: 10px 16px; +} +.storybook-tag--medium { + font-size: 14px; + padding: 11px 20px; +} +.storybook-tag--large { + font-size: 16px; + padding: 12px 24px; +}