forked from EightfoldAI/octuple
-
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.
feat: Adds octuple pills component (EightfoldAI#22)
- Loading branch information
1 parent
a48952a
commit 7138810
Showing
6 changed files
with
514 additions
and
6 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 |
---|---|---|
@@ -1,9 +1,6 @@ | ||
.iconWrapper { | ||
display: inline-block; | ||
.icon-wrapper { | ||
display: flex; | ||
align-items: center; | ||
margin: 0; | ||
padding: 0; | ||
|
||
svg { | ||
vertical-align: middle; | ||
} | ||
} |
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,63 @@ | ||
import React, { FC } from 'react'; | ||
import { PillProps, PillSize, PillType } from './Pills.types'; | ||
import { classNames } from '../../shared/utilities'; | ||
import { Icon, IconName, IconSize } from '../Icon'; | ||
|
||
import styles from './pills.module.scss'; | ||
import { ButtonSize, DefaultButton } from '../Button'; | ||
|
||
export const Pill: FC<PillProps> = ({ | ||
color, | ||
label, | ||
icon, | ||
theme = 'blue', | ||
onClose, | ||
onClick, | ||
closeButtonProps, | ||
pillButtonProps, | ||
type = PillType.default, | ||
size = PillSize.Large, | ||
}) => { | ||
const tagClassName: string = classNames([ | ||
styles.tagPills, | ||
{ [styles.red]: theme === 'red' }, | ||
{ [styles.orange]: theme === 'orange' }, | ||
{ [styles.yellow]: theme === 'yellow' }, | ||
{ [styles.green]: theme === 'green' }, | ||
{ [styles.bluegreen]: theme === 'bluegreen' }, | ||
{ [styles.blue]: theme === 'blue' }, | ||
{ [styles.violet]: theme === 'violet' }, | ||
{ [styles.grey]: theme === 'grey' }, | ||
{ [styles.medium]: size === PillSize.Medium }, | ||
{ [styles.small]: size === PillSize.Small }, | ||
]); | ||
return ( | ||
<div className={tagClassName} style={{ color }}> | ||
{icon && ( | ||
<Icon | ||
path={icon} | ||
size={IconSize.Small} | ||
className={styles.icon} | ||
/> | ||
)} | ||
<span className={styles.label}>{label}</span> | ||
{type === PillType.withButton && ( | ||
<DefaultButton | ||
{...pillButtonProps} | ||
onClick={onClick} | ||
size={ButtonSize.Small} | ||
className={styles.button} | ||
/> | ||
)} | ||
{type === PillType.closable && ( | ||
<DefaultButton | ||
{...closeButtonProps} | ||
icon={IconName.mdiClose} | ||
onClick={onClose} | ||
size={ButtonSize.Small} | ||
className={styles.closeButton} | ||
/> | ||
)} | ||
</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,259 @@ | ||
import React from 'react'; | ||
import { Pill, PillSize, PillType } from './'; | ||
import { OcThemeNames } from '../ConfigProvider'; | ||
import { Icon, IconName, IconSize } from '../Icon'; | ||
|
||
export default { | ||
title: 'Pill', | ||
component: Pill, | ||
}; | ||
|
||
const themes: OcThemeNames[] = [ | ||
'red', | ||
'orange', | ||
'yellow', | ||
'green', | ||
'bluegreen', | ||
'blue', | ||
'violet', | ||
'grey', | ||
]; | ||
|
||
export const Pills = () => ( | ||
<> | ||
<h2>Pills ({PillSize.Large})</h2> | ||
<div style={{ display: 'flex', gap: '30px' }}> | ||
<div | ||
style={{ | ||
display: 'flex', | ||
flexDirection: 'column', | ||
gap: '16px', | ||
}} | ||
> | ||
{themes.map((theme) => ( | ||
<Pill label={theme} theme={theme} key={theme} /> | ||
))} | ||
</div> | ||
|
||
<div | ||
style={{ | ||
display: 'flex', | ||
flexDirection: 'column', | ||
gap: '16px', | ||
}} | ||
> | ||
{themes.map((theme) => ( | ||
<Pill | ||
label={theme} | ||
theme={theme} | ||
key={theme} | ||
type={PillType.closable} | ||
closeButtonProps={{ | ||
ariaLabel: 'Close', | ||
}} | ||
/> | ||
))} | ||
</div> | ||
<div | ||
style={{ | ||
display: 'flex', | ||
flexDirection: 'column', | ||
gap: '16px', | ||
}} | ||
> | ||
{themes.map((theme) => ( | ||
<Pill | ||
label={theme} | ||
theme={theme} | ||
key={theme} | ||
icon={IconName.mdiInformationOutline} | ||
/> | ||
))} | ||
</div> | ||
<div | ||
style={{ | ||
display: 'flex', | ||
flexDirection: 'column', | ||
gap: '16px', | ||
}} | ||
> | ||
{themes.map((theme) => ( | ||
<Pill | ||
label={theme} | ||
theme={theme} | ||
key={theme} | ||
type={PillType.withButton} | ||
pillButtonProps={{ | ||
icon: IconName.mdiThumbUpOutline, | ||
text: '2', | ||
ariaLabel: 'Thumbs up', | ||
}} | ||
/> | ||
))} | ||
</div> | ||
</div> | ||
<br /> | ||
<br /> | ||
<br /> | ||
<h2>Pills ({PillSize.Medium})</h2> | ||
<div style={{ display: 'flex', gap: '30px' }}> | ||
<div | ||
style={{ | ||
display: 'flex', | ||
flexDirection: 'column', | ||
gap: '16px', | ||
}} | ||
> | ||
{themes.map((theme) => ( | ||
<Pill | ||
label={theme} | ||
theme={theme} | ||
key={theme} | ||
size={PillSize.Medium} | ||
/> | ||
))} | ||
</div> | ||
|
||
<div | ||
style={{ | ||
display: 'flex', | ||
flexDirection: 'column', | ||
gap: '16px', | ||
}} | ||
> | ||
{themes.map((theme) => ( | ||
<Pill | ||
label={theme} | ||
theme={theme} | ||
key={theme} | ||
size={PillSize.Medium} | ||
type={PillType.closable} | ||
closeButtonProps={{ | ||
ariaLabel: 'Close', | ||
}} | ||
/> | ||
))} | ||
</div> | ||
<div | ||
style={{ | ||
display: 'flex', | ||
flexDirection: 'column', | ||
gap: '16px', | ||
}} | ||
> | ||
{themes.map((theme) => ( | ||
<Pill | ||
label={theme} | ||
theme={theme} | ||
key={theme} | ||
icon={IconName.mdiInformationOutline} | ||
size={PillSize.Medium} | ||
/> | ||
))} | ||
</div> | ||
<div | ||
style={{ | ||
display: 'flex', | ||
flexDirection: 'column', | ||
gap: '16px', | ||
}} | ||
> | ||
{themes.map((theme) => ( | ||
<Pill | ||
label={theme} | ||
theme={theme} | ||
key={theme} | ||
type={PillType.withButton} | ||
size={PillSize.Medium} | ||
pillButtonProps={{ | ||
icon: IconName.mdiThumbUpOutline, | ||
text: '2', | ||
ariaLabel: 'Thumbs up', | ||
}} | ||
/> | ||
))} | ||
</div> | ||
</div> | ||
<br /> | ||
<br /> | ||
<br /> | ||
<h2>Pills ({PillSize.Small})</h2> | ||
<div style={{ display: 'flex', gap: '30px' }}> | ||
<div | ||
style={{ | ||
display: 'flex', | ||
flexDirection: 'column', | ||
gap: '16px', | ||
}} | ||
> | ||
{themes.map((theme) => ( | ||
<Pill | ||
label={theme} | ||
theme={theme} | ||
key={theme} | ||
size={PillSize.Small} | ||
/> | ||
))} | ||
</div> | ||
<div | ||
style={{ | ||
display: 'flex', | ||
flexDirection: 'column', | ||
gap: '16px', | ||
}} | ||
> | ||
{themes.map((theme) => ( | ||
<Pill | ||
label={theme} | ||
theme={theme} | ||
key={theme} | ||
size={PillSize.Small} | ||
type={PillType.closable} | ||
closeButtonProps={{ | ||
ariaLabel: 'Close', | ||
}} | ||
/> | ||
))} | ||
</div> | ||
<div | ||
style={{ | ||
display: 'flex', | ||
flexDirection: 'column', | ||
gap: '16px', | ||
}} | ||
> | ||
{themes.map((theme) => ( | ||
<Pill | ||
label={theme} | ||
theme={theme} | ||
key={theme} | ||
icon={IconName.mdiInformationOutline} | ||
size={PillSize.Small} | ||
/> | ||
))} | ||
</div> | ||
<div | ||
style={{ | ||
display: 'flex', | ||
flexDirection: 'column', | ||
gap: '16px', | ||
}} | ||
> | ||
{themes.map((theme) => ( | ||
<Pill | ||
label={theme} | ||
theme={theme} | ||
key={theme} | ||
type={PillType.withButton} | ||
size={PillSize.Small} | ||
pillButtonProps={{ | ||
icon: IconName.mdiThumbUpOutline, | ||
text: '2', | ||
ariaLabel: 'Thumbs up', | ||
}} | ||
/> | ||
))} | ||
</div> | ||
</div> | ||
</> | ||
); |
Oops, something went wrong.