diff --git a/stories/Actions.stories.tsx b/stories/Actions.stories.tsx index 11d8144..c9b249c 100644 --- a/stories/Actions.stories.tsx +++ b/stories/Actions.stories.tsx @@ -2,7 +2,7 @@ import React from 'react'; import { Button } from './Button'; import { Actions, ActionsProps } from './Actions'; -import { Icon } from './Icon'; +import { Icon, IconType } from './Icon'; export default { title: 'Components/Actions', @@ -23,16 +23,16 @@ Simple.args = { primary: ( <> ), secondary: ( ), }; @@ -42,10 +42,10 @@ PrimaryOnly.args = { primary: ( <> ), @@ -55,7 +55,7 @@ export const SecondaryOnly = Template.bind({}); SecondaryOnly.args = { secondary: ( ), }; diff --git a/stories/Button.stories.tsx b/stories/Button.stories.tsx index 2a74a17..a30b8d3 100644 --- a/stories/Button.stories.tsx +++ b/stories/Button.stories.tsx @@ -2,7 +2,7 @@ import React from 'react'; import { Button, ButtonProps } from './Button'; import { Theme } from './constants'; -import { Icon } from './Icon'; +import { Icon, IconType } from './Icon'; export default { title: 'Components/Button', @@ -32,10 +32,10 @@ Secondary.args = { theme: Theme.Secondary, }; -export const Accent = Template.bind({}); -Accent.args = { +export const PrimaryAccent = Template.bind({}); +PrimaryAccent.args = { children: 'Button', - theme: Theme.Accent, + theme: Theme.PrimaryAccent, }; export const Inverse = Template.bind({}); @@ -49,7 +49,7 @@ export const WithIcon = Template.bind({}); WithIcon.args = { children: ( <> - +
Test with lots of text
), @@ -59,7 +59,7 @@ WithIcon.args = { export const Twitter = Template.bind({}); Twitter.args = { children: ( - + ), theme: Theme.Twitter, }; @@ -67,7 +67,7 @@ Twitter.args = { export const Facebook = Template.bind({}); Facebook.args = { children: ( - + ), theme: Theme.Secondary, }; diff --git a/stories/Card.stories.tsx b/stories/Card.stories.tsx index 1b44009..fb54bbf 100644 --- a/stories/Card.stories.tsx +++ b/stories/Card.stories.tsx @@ -5,7 +5,7 @@ import { Button } from './Button'; import { Card, CardProps } from './Card'; import { Checkbox } from './Checkbox'; import { Layout } from './constants'; -import { Icon } from './Icon'; +import { Icon, IconType } from './Icon'; import { Input } from './Input'; export default { @@ -39,13 +39,13 @@ Vertical.args = { primary={( <> )} secondary={( )} /> @@ -59,10 +59,10 @@ Horizontal.args = { children: ( <> ), diff --git a/stories/Checkbox.tsx b/stories/Checkbox.tsx index 1ef5060..e51867a 100644 --- a/stories/Checkbox.tsx +++ b/stories/Checkbox.tsx @@ -1,6 +1,7 @@ import classNames from 'classnames'; import React, { useEffect, useState } from 'react'; import styles from './Checkbox.scss'; +import { noop } from './utils/noop'; import { Checked } from './constants'; export interface CheckboxProps { @@ -26,7 +27,7 @@ export function Checkbox({ checked = false, className, disabled = false, - onChange, + onChange = noop, }: CheckboxProps): JSX.Element { const [internallyChecked, setInternallyChecked] = useState(Checked.Unchecked); @@ -44,7 +45,7 @@ export function Checkbox({ const isChecked = [Checked.Unchecked, Checked.Indeterminate].includes(internallyChecked); setInternallyChecked(isChecked ? Checked.Checked : Checked.Unchecked); - if (onChange) onChange(isChecked); + onChange(isChecked); } return ( diff --git a/stories/Favorite.scss b/stories/Favorite.scss index 3cba4c8..3b9e445 100644 --- a/stories/Favorite.scss +++ b/stories/Favorite.scss @@ -49,7 +49,6 @@ &.checked > .fanfare { animation: fanfare steps(27); - animation-duration: 1s; } } diff --git a/stories/Favorite.stories.tsx b/stories/Favorite.stories.tsx index a142dae..4250f66 100644 --- a/stories/Favorite.stories.tsx +++ b/stories/Favorite.stories.tsx @@ -9,7 +9,13 @@ export default { const Template = (args: FavoriteProps) => ; -export const Simple = Template.bind({}); -Simple.args = { +export const Unchecked = Template.bind({}); +Unchecked.args = { tooltip: 'This is an example', -} +}; + +export const Checked = Template.bind({}); +Checked.args = { + checked: true, + tooltip: 'This is an example', +}; diff --git a/stories/Favorite.tsx b/stories/Favorite.tsx index 5e8c58c..9dc2570 100644 --- a/stories/Favorite.tsx +++ b/stories/Favorite.tsx @@ -1,9 +1,10 @@ import React, { useEffect, useState } from 'react'; -import { Icon } from './Icon'; +import classNames from 'classnames'; +import { Icon, IconType } from './Icon'; import { Tooltip, getTooltipIdentifier } from './Tooltip'; import styles from './Favorite.scss'; -import classNames from 'classnames'; +import { noop } from './utils/noop'; import { Alignment } from './constants'; export interface FavoriteProps { @@ -16,9 +17,10 @@ export interface FavoriteProps { export function Favorite({ checked, className, - onChange, + onChange = noop, tooltip, }: FavoriteProps): JSX.Element { + const [hasBeenClicked, setHasBeenClicked] = useState(false); const [tooltipId] = useState(() => getTooltipIdentifier()) const [internallyChecked, setInternallyChecked] = useState(); @@ -40,7 +42,8 @@ export function Favorite({ const updatedChecked = !internallyChecked; setInternallyChecked(updatedChecked); - if (onChange) onChange(updatedChecked); + onChange(updatedChecked); + setHasBeenClicked(true); }} > {tooltip && ( @@ -52,13 +55,18 @@ export function Favorite({ )} +
-
); } diff --git a/stories/Grid.stories.tsx b/stories/Grid.stories.tsx index 8407f26..ddb47d8 100644 --- a/stories/Grid.stories.tsx +++ b/stories/Grid.stories.tsx @@ -24,10 +24,10 @@ Vertical.args = { children: ( <> ), @@ -39,10 +39,10 @@ Horizontal.args = { children: ( <> ), diff --git a/stories/Input.tsx b/stories/Input.tsx index 3c71c75..dadb6a1 100644 --- a/stories/Input.tsx +++ b/stories/Input.tsx @@ -1,6 +1,7 @@ import classNames from 'classnames'; import React, { useEffect, useState } from 'react'; import { Keys, UpdateOn } from './constants'; +import { noop } from './utils/noop'; import styles from './Input.scss'; export interface InputProps { @@ -11,7 +12,7 @@ export interface InputProps { /** * Invoked when the checkbox checked value is modified internally. */ - onChange: (value: string) => void; + onChange?: (value: string) => void; submitKeys?: Keys[]; updateOn?: UpdateOn; @@ -21,7 +22,7 @@ export function Input({ className, value, placeholder, - onChange, + onChange = noop, submitKeys = [Keys.Enter], updateOn = UpdateOn.Blur, }: InputProps): JSX.Element { diff --git a/stories/Tooltip.stories.tsx b/stories/Tooltip.stories.tsx index 7ff961b..1d77c2c 100644 --- a/stories/Tooltip.stories.tsx +++ b/stories/Tooltip.stories.tsx @@ -12,7 +12,7 @@ export default { const Template = (args: TooltipProps) => ( <>