-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Guilherme Gazzo <guilherme@gazzo.xyz>
- Loading branch information
Showing
29 changed files
with
342 additions
and
70 deletions.
There are no files selected for viewing
Binary file added
BIN
+17.5 KB
packages/fuselage/.loki/reference/chrome_iphone7_Misc_Options_Option_Default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+625 Bytes
packages/fuselage/.loki/reference/chrome_iphone7_Misc_Options_Option_Skeleton.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+15.3 KB
...ages/fuselage/.loki/reference/chrome_iphone7_Misc_Options_Option_asUserItem.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+39.8 KB
...ages/fuselage/.loki/reference/chrome_iphone7_Misc_Options_Option_withAvatar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+18.5 KB
packages/fuselage/.loki/reference/chrome_iphone7_Misc_Options_Option_withIcon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+18.3 KB
packages/fuselage/.loki/reference/chrome_iphone7_Misc_Options_Option_withMenu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+18.8 KB
...es/fuselage/.loki/reference/chrome_iphone7_Misc_Options_Option_withPresence.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+18.4 KB
...es/fuselage/.loki/reference/chrome_iphone7_Misc_Options_Options_CheckOption.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+18.2 KB
packages/fuselage/.loki/reference/chrome_iphone7_Misc_Options_Options_Default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+18.2 KB
packages/fuselage/.loki/reference/chrome_iphone7_Misc_Options_Options_Option.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+4.69 KB
packages/fuselage/.loki/reference/chrome_laptop_Misc_Options_Option_Default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+362 Bytes
packages/fuselage/.loki/reference/chrome_laptop_Misc_Options_Option_Skeleton.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+5.47 KB
packages/fuselage/.loki/reference/chrome_laptop_Misc_Options_Option_asUserItem.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+13.7 KB
packages/fuselage/.loki/reference/chrome_laptop_Misc_Options_Option_withAvatar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+6.98 KB
packages/fuselage/.loki/reference/chrome_laptop_Misc_Options_Option_withIcon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+6.82 KB
packages/fuselage/.loki/reference/chrome_laptop_Misc_Options_Option_withMenu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+5.52 KB
...ges/fuselage/.loki/reference/chrome_laptop_Misc_Options_Option_withPresence.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+8.14 KB
...ges/fuselage/.loki/reference/chrome_laptop_Misc_Options_Options_CheckOption.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+7.58 KB
packages/fuselage/.loki/reference/chrome_laptop_Misc_Options_Options_Default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+7.58 KB
packages/fuselage/.loki/reference/chrome_laptop_Misc_Options_Options_Option.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
154 changes: 154 additions & 0 deletions
154
packages/fuselage/src/components/Options/Option/Option.stories.mdx
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,154 @@ | ||
import { Meta, Canvas, ArgsTable, Story } from '@storybook/addon-docs/blocks'; | ||
import LinkTo from '@storybook/addon-links/react'; | ||
|
||
import { Option } from '.'; | ||
import { Box, Avatar, Menu, StatusBullet } from '../..'; | ||
import { exampleAvatar, menuOptions } from '../../../../.storybook/helpers.js'; | ||
|
||
<Meta title='Misc/Options/Option' parameters={{ jest: ['Option/spec'] }} /> | ||
|
||
# Option | ||
|
||
The generic <LinkTo kind='Misc/Options/Option' story='Default'>`Option`</LinkTo> item of options. Can be freely used or inside the <LinkTo kind='Misc/Options/Options' story='Default'>`Options`</LinkTo> as well. | ||
|
||
<Canvas> | ||
<Story name='Default'> | ||
<Box position='relative' maxWidth={250}> | ||
<Option> | ||
<Option.Content>Lorem Ipsum Lorem</Option.Content> | ||
</Option> | ||
<Option> | ||
<Option.Content>Lorem Ipsum Lorem Lorem Ipsum Lorem Lorem Ipsum Lorem Lorem Ipsum Lorem</Option.Content> | ||
</Option> | ||
<Option> | ||
<Option.Content>Lorem Ipsum Lorem <Option.Description>Lorem Lorem Ipsum Lorem Lorem Ipsum Lorem</Option.Description></Option.Content> | ||
</Option> | ||
</Box> | ||
</Story> | ||
</Canvas> | ||
|
||
|
||
## With avatar | ||
|
||
<Canvas> | ||
<Story name='withAvatar'> | ||
<Box position='relative' maxWidth={250}> | ||
<Option> | ||
<Option.Avatar> | ||
<Avatar url={exampleAvatar} size='x28' /> | ||
</Option.Avatar> | ||
<Option.Content>Lorem Ipsum Lorem</Option.Content> | ||
</Option> | ||
<Option> | ||
<Option.Avatar> | ||
<Avatar url={exampleAvatar} size='x28' /> | ||
</Option.Avatar> | ||
<Option.Content>Lorem Ipsum Lorem Lorem Ipsum Lorem Lorem Ipsum Lorem Lorem Ipsum Lorem</Option.Content> | ||
</Option> | ||
<Option> | ||
<Option.Avatar> | ||
<Avatar url={exampleAvatar} size='x28' /> | ||
</Option.Avatar> | ||
<Option.Content>Lorem Ipsum Lorem <Option.Description>Lorem Lorem Ipsum Lorem Lorem Ipsum Lorem</Option.Description></Option.Content> | ||
</Option> | ||
</Box> | ||
</Story> | ||
</Canvas> | ||
|
||
## With presence | ||
|
||
<Canvas> | ||
<Story name='withPresence'> | ||
<Box position='relative' maxWidth={250}> | ||
<Option> | ||
<Option.Column><StatusBullet /></Option.Column> | ||
<Option.Content>Lorem Ipsum Lorem</Option.Content> | ||
</Option> | ||
<Option> | ||
<Option.Avatar> | ||
<Avatar url={exampleAvatar} size='x28' /> | ||
</Option.Avatar> | ||
<Option.Column><StatusBullet /></Option.Column> | ||
<Option.Content>Lorem Ipsum Lorem Lorem Ipsum Lorem Lorem Ipsum Lorem Lorem Ipsum Lorem</Option.Content> | ||
</Option> | ||
</Box> | ||
</Story> | ||
</Canvas> | ||
|
||
## With menu | ||
|
||
<Canvas> | ||
<Story name='withMenu'> | ||
<Box position='relative' maxWidth={250}> | ||
<Option> | ||
<Option.Content>Lorem Ipsum Lorem</Option.Content> | ||
<Option.Menu><Menu options={menuOptions} /></Option.Menu> | ||
</Option> | ||
<Option> | ||
<Option.Avatar> | ||
<Avatar url={exampleAvatar} size='x28' /> | ||
</Option.Avatar> | ||
<Option.Column><StatusBullet /></Option.Column> | ||
<Option.Content>Lorem Ipsum Lorem Lorem Ipsum Lorem Lorem Ipsum Lorem Lorem Ipsum Lorem</Option.Content> | ||
<Option.Menu><Menu options={menuOptions} /></Option.Menu> | ||
</Option> | ||
</Box> | ||
</Story> | ||
</Canvas> | ||
|
||
## With Icon | ||
|
||
<Canvas> | ||
<Story name='withIcon'> | ||
<Box position='relative' maxWidth={250}> | ||
<Option> | ||
<Option.Icon name='bell'/> | ||
<Option.Content>Lorem Ipsum Lorem</Option.Content> | ||
<Option.Menu><Menu options={menuOptions} /></Option.Menu> | ||
</Option> | ||
<Option> | ||
<Option.Avatar> | ||
<Avatar url={exampleAvatar} size='x28' /> | ||
</Option.Avatar> | ||
<Option.Icon name='bell'/> | ||
<Option.Column><StatusBullet /></Option.Column> | ||
<Option.Content>Lorem Ipsum Lorem Lorem Ipsum Lorem Lorem Ipsum Lorem Lorem Ipsum Lorem</Option.Content> | ||
<Option.Menu><Menu options={menuOptions} /></Option.Menu> | ||
</Option> | ||
</Box> | ||
</Story> | ||
</Canvas> | ||
|
||
## As UserItem | ||
|
||
<Canvas> | ||
<Story name='asUserItem'> | ||
<Box maxWidth={330}> | ||
<Option> | ||
<Option.Avatar> | ||
<Avatar url={exampleAvatar} size='x28' /> | ||
</Option.Avatar> | ||
|
||
<Option.Column><StatusBullet status='online' /></Option.Column> | ||
<Option.Content> | ||
<Box withTruncatedText fontScale='p1'>carla.culhane <Box is='span' color='neutral-500'>(carla hune)</Box></Box> | ||
</Option.Content> | ||
<Option.Menu><Menu options={menuOptions} /></Option.Menu> | ||
</Option> | ||
</Box> | ||
</Story> | ||
</Canvas> | ||
|
||
## As Skeleton | ||
|
||
<Canvas> | ||
<Story name='Skeleton'> | ||
<Box position='relative' maxWidth={330}> | ||
<Option.Skeleton /> | ||
</Box> | ||
</Story> | ||
</Canvas> | ||
|
||
<ArgsTable of={Option} /> | ||
|
||
|
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,87 @@ | ||
import React from 'react'; | ||
|
||
import { Icon } from '../../Icon'; | ||
import { Skeleton } from '../../Skeleton'; | ||
|
||
const OptionColumn = (props) => ( | ||
<div className='rcx-option__column' {...props} /> | ||
); | ||
const OptionContent = (props) => ( | ||
<div className='rcx-option__content' {...props} /> | ||
); | ||
const OptionAvatar = (props) => ( | ||
<div className='rcx-option__avatar' {...props} /> | ||
); | ||
const OptionDescription = (props) => ( | ||
<div className='rcx-option__description' {...props} /> | ||
); | ||
const OptionIcon = ({ name }) => ( | ||
<OptionColumn> | ||
<Icon size='x16' name={name} /> | ||
</OptionColumn> | ||
); | ||
|
||
const OptionSkeleton = (props) => { | ||
return ( | ||
<Option {...props}> | ||
<Option.Avatar> | ||
<Skeleton variant='rect' width={28} height={28} /> | ||
</Option.Avatar> | ||
<Option.Content> | ||
<Skeleton width='100%' /> | ||
</Option.Content> | ||
</Option> | ||
); | ||
}; | ||
|
||
export const OptionMenu = (props) => ( | ||
<div className='rcx-box--animated rcx-option__menu-wraper' {...props} /> | ||
); | ||
|
||
export const Option = React.memo( | ||
({ | ||
is: Tag = 'li', | ||
id, | ||
presence, | ||
children, | ||
label, | ||
focus, | ||
selected, | ||
className, | ||
ref, | ||
icon, | ||
avatar, | ||
...options | ||
}) => ( | ||
<Tag | ||
key={id} | ||
id={id} | ||
ref={ref} | ||
aria-selected={selected} | ||
{...options} | ||
className={[ | ||
'rcx-option', | ||
className, | ||
focus && 'rcx-option--focus', | ||
selected && 'rcx-option--selected', | ||
] | ||
.filter(Boolean) | ||
.join(' ')} | ||
> | ||
<div className='rcx-option__wrapper'> | ||
{avatar && <Option.Avatar>{avatar}</Option.Avatar>} | ||
{icon && <Option.Icon name={icon} />} | ||
{label && <Option.Content>{label}</Option.Content>} | ||
{label !== children && children} | ||
</div> | ||
</Tag> | ||
) | ||
); | ||
|
||
Option.Description = OptionDescription; | ||
Option.Skeleton = OptionSkeleton; | ||
Option.Avatar = OptionAvatar; | ||
Option.Menu = OptionMenu; | ||
Option.Icon = OptionIcon; | ||
Option.Column = OptionColumn; | ||
Option.Content = OptionContent; |
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,10 @@ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
|
||
import { Option } from '.'; | ||
|
||
it('Option renders without crashing', () => { | ||
const div = document.createElement('div'); | ||
ReactDOM.render(<Option />, div); | ||
ReactDOM.unmountComponentAtNode(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
Oops, something went wrong.