generated from adobe/aem-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
68eb203
commit 8165dbc
Showing
3 changed files
with
129 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<typeof Tag>; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof meta>; | ||
|
||
// 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', | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
<div | ||
className={['storybook-tag', `storybook-tag--${size}`, mode].join(' ')} | ||
style={{ backgroundColor }} | ||
{...props} | ||
> | ||
{label} | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |