-
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
Showing
12 changed files
with
303 additions
and
1,405 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
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
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 |
---|---|---|
@@ -1,188 +1,52 @@ | ||
import React, { Fragment } from 'react'; | ||
import { boolean, text, withKnobs } from '@storybook/addon-knobs'; | ||
import { action } from '@storybook/addon-actions'; | ||
|
||
import React from 'react'; | ||
import { Alert, MessageTypes } from 'src/Alert'; | ||
|
||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; | ||
import { faGoogle } from '@fortawesome/free-brands-svg-icons'; | ||
import mdx from './Alert.mdx'; | ||
|
||
import 'bootstrap/dist/css/bootstrap.min.css'; | ||
import '../../scss/global.scss'; | ||
|
||
export default { | ||
title: 'Components/Alert', | ||
component: Alert, | ||
decorators: [withKnobs], | ||
parameters: { | ||
docs: { | ||
page: mdx, | ||
controls: { exclude: [] }, | ||
}, | ||
args: { | ||
id: '1', | ||
title: 'Example title', | ||
message: 'Example message', | ||
type: MessageTypes.SUCCESS, | ||
onDismiss: () => alert('alert dismissed'), | ||
}, | ||
argTypes: { | ||
message: { control: 'text' }, | ||
title: { control: 'text' }, | ||
type: { | ||
options: Object.values(MessageTypes), | ||
mapping: MessageTypes, | ||
control: { type: 'select' }, | ||
}, | ||
}, | ||
}; | ||
|
||
export const Success = () => ( | ||
<Alert | ||
id="1" | ||
message={text('Message', 'Success message')} | ||
removeBorderLeft={boolean('removeBorderLeft', false)} | ||
title={text('Title', 'Success title')} | ||
type={MessageTypes.SUCCESS} | ||
/> | ||
); | ||
|
||
export const Info = () => ( | ||
<Alert | ||
id="2" | ||
message={text('Message', 'Info message')} | ||
removeBorderLeft={boolean('removeBorderLeft', false)} | ||
title={text('Title', 'Info title')} | ||
type={MessageTypes.INFO} | ||
/> | ||
); | ||
|
||
export const Feature = () => ( | ||
<Alert | ||
id="3" | ||
message={text('Message', 'Some context around new feature if needed.')} | ||
removeBorderLeft={boolean('removeBorderLeft', false)} | ||
title={text('Title', 'New feature alert!')} | ||
type={MessageTypes.FEATURE} | ||
/> | ||
); | ||
|
||
export const Error = () => ( | ||
<Alert | ||
id="4" | ||
message={text('Message', 'Error message')} | ||
removeBorderLeft={boolean('removeBorderLeft', false)} | ||
title={text('Title', 'Error title')} | ||
type={MessageTypes.ERROR} | ||
/> | ||
); | ||
|
||
export const Warning = () => ( | ||
<Alert | ||
id="5" | ||
message={text('Message', 'Warning message')} | ||
removeBorderLeft={boolean('removeBorderLeft', false)} | ||
title={text('Title', 'Warning title')} | ||
type={MessageTypes.WARNING} | ||
/> | ||
); | ||
|
||
const onDismiss = (id) => { | ||
action('alert dismissed')(id); | ||
export const Primary = { | ||
args: {}, | ||
}; | ||
|
||
export const WithDismiss = () => ( | ||
<Alert | ||
id="6" | ||
message={text('Message', 'Default message')} | ||
removeBorderLeft={boolean('removeBorderLeft', false)} | ||
title={text('Title', 'Default title')} | ||
type={MessageTypes.SUCCESS} | ||
onDismiss={onDismiss} | ||
/> | ||
); | ||
|
||
const googleButtonStyle = { | ||
backgroundColor: '#4285F4', | ||
border: '1px solid #4285F4', | ||
borderRadius: '4px', | ||
fontSize: '0.875rem', | ||
fontWeight: 'bold', | ||
lineHeight: '1.25rem', | ||
margin: '16px 0', | ||
padding: '8px 16px', | ||
color: '#FFFFFF', | ||
whiteSpace: 'nowrap', | ||
export const CallToActionObject = { | ||
args: { | ||
type: MessageTypes.INFO, | ||
action: { | ||
url: 'http://userinterviews.com', | ||
content: 'Primary action', | ||
}, | ||
actionTarget: '_blank', | ||
}, | ||
}; | ||
|
||
const GoogleCalendarButton = () => ( | ||
<button style={googleButtonStyle} type="button"> | ||
<FontAwesomeIcon icon={faGoogle} style={{ height: '16px', marginRight: '8px' }} /> | ||
Connect Google Calendar | ||
</button> | ||
); | ||
|
||
export const WithCallToAction = () => ( | ||
<> | ||
<p>Default CTA rendered by component</p> | ||
<Alert | ||
action={{ content: 'Primary action', url: 'https://www.userinterviews.com/' }} | ||
id="8" | ||
message="Success message" | ||
removeBorderLeft={boolean('removeBorderLeft', false)} | ||
title="Success title" | ||
type={MessageTypes.SUCCESS} | ||
onDismiss={onDismiss} | ||
/> | ||
<Alert | ||
action={{ content: 'Primary action', url: 'https://www.userinterviews.com/' }} | ||
id="9" | ||
message="Info message" | ||
removeBorderLeft={boolean('removeBorderLeft', false)} | ||
title="Info title" | ||
type={MessageTypes.INFO} | ||
onDismiss={onDismiss} | ||
/> | ||
<Alert | ||
action={{ content: 'Primary action', url: 'https://www.userinterviews.com/' }} | ||
id="11" | ||
message="Error message" | ||
removeBorderLeft={boolean('removeBorderLeft', false)} | ||
title="Error title" | ||
type={MessageTypes.ERROR} | ||
onDismiss={onDismiss} | ||
/> | ||
<Alert | ||
action={{ content: 'Primary action', url: 'https://www.userinterviews.com/' }} | ||
id="12" | ||
message="Warning message" | ||
removeBorderLeft={boolean('removeBorderLeft', false)} | ||
title="Warning title" | ||
type={MessageTypes.WARNING} | ||
onDismiss={onDismiss} | ||
/> | ||
<Alert | ||
action={{ content: 'Primary action', url: 'https://www.userinterviews.com/' }} | ||
id="13" | ||
message="Some context around new feature if needed" | ||
removeBorderLeft={boolean('removeBorderLeft', false)} | ||
title="New feature alert!" | ||
type={MessageTypes.FEATURE} | ||
onDismiss={onDismiss} | ||
/> | ||
|
||
<p>Custom CTA via <code>message</code> prop</p> | ||
<Alert | ||
id="7" | ||
message={( | ||
<Fragment> | ||
<div>When you confirm a session we’ll automatically | ||
add an event and reminders to your Google Calendar. | ||
</div> | ||
<GoogleCalendarButton /> | ||
</Fragment> | ||
)} | ||
removeBorderLeft={boolean('removeBorderLeft', false)} | ||
title={text('Title', 'Connect to Google Calendar to create reminders automatically')} | ||
type={MessageTypes.ANNOUNCEMENT} | ||
onDismiss={onDismiss} | ||
/> | ||
|
||
<p>Custom CTA via <code>action</code> prop</p> | ||
<Alert | ||
action={<GoogleCalendarButton />} | ||
id="8" | ||
message={text('Message', `When you confirm a session we’ll automatically | ||
add an event and reminders to your Google Calendar.`)} | ||
removeBorderLeft={boolean('removeBorderLeft', false)} | ||
title={text('Title', 'Connect to Google Calendar to create reminders automatically')} | ||
type={MessageTypes.ANNOUNCEMENT} | ||
onDismiss={onDismiss} | ||
/> | ||
</> | ||
); | ||
export const CallToActionNode = { | ||
args: { | ||
type: MessageTypes.ERROR, | ||
action: ( | ||
<button type="button" onClick={() => alert('custom node onClick called')}> | ||
Custom action | ||
</button> | ||
), | ||
}, | ||
}; |
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 |
---|---|---|
@@ -1,113 +1,28 @@ | ||
import React from 'react'; | ||
|
||
import Avatar from 'src/Avatar'; | ||
import mdx from './Avatar.mdx'; | ||
|
||
export default { | ||
title: 'Components/Avatar', | ||
component: Avatar, | ||
parameters: { | ||
docs: { | ||
page: mdx, | ||
controls: { | ||
exclude: ['name'], | ||
}, | ||
}, | ||
args: { | ||
initials: 'KS', | ||
}, | ||
argTypes: { | ||
colorId: { control: 'number' }, | ||
}, | ||
}; | ||
|
||
export const Small = () => ( | ||
<div> | ||
<Avatar | ||
initials="RR" | ||
/> | ||
<Avatar | ||
colorId={1} | ||
initials="RR" | ||
/> | ||
<Avatar | ||
colorId={2} | ||
initials="RR" | ||
/> | ||
<Avatar | ||
colorId={3} | ||
initials="RR" | ||
/> | ||
<Avatar | ||
colorId={4} | ||
initials="RR" | ||
/> | ||
<Avatar | ||
colorId={5} | ||
initials="RR" | ||
/> | ||
<Avatar | ||
colorId={6} | ||
initials="RR" | ||
/> | ||
</div> | ||
); | ||
|
||
export const Large = () => ( | ||
<div> | ||
<Avatar | ||
initials="RR" | ||
large | ||
/> | ||
<Avatar | ||
colorId={1} | ||
initials="RR" | ||
large | ||
/> | ||
<Avatar | ||
colorId={2} | ||
initials="RR" | ||
large | ||
/> | ||
<Avatar | ||
colorId={3} | ||
initials="RR" | ||
large | ||
/> | ||
<Avatar | ||
colorId={4} | ||
initials="RR" | ||
large | ||
/> | ||
<Avatar | ||
colorId={5} | ||
initials="RR" | ||
large | ||
/> | ||
<Avatar | ||
colorId={6} | ||
initials="RR" | ||
large | ||
/> | ||
</div> | ||
); | ||
|
||
export const WithAlert = () => ( | ||
<div> | ||
<Avatar | ||
initials="RR" | ||
large | ||
showAlert | ||
/> | ||
<Avatar | ||
initials="RR" | ||
showAlert | ||
/> | ||
</div> | ||
); | ||
export const Primary = { | ||
args: {}, | ||
}; | ||
|
||
export const WithImage = () => ( | ||
<div> | ||
<Avatar | ||
image="https://avatars.dicebear.com/api/avataaars/1234.svg" | ||
initials="RR" | ||
large | ||
/> | ||
<Avatar | ||
image="https://avatars.dicebear.com/api/avataaars/1234.svg" | ||
initials="RR" | ||
/> | ||
</div> | ||
); | ||
export const WithImage = { | ||
args: { | ||
image: 'https://placehold.it/160/160', | ||
large: true, | ||
}, | ||
}; |
Oops, something went wrong.