-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add lucide and style button with icon
- Loading branch information
Showing
9 changed files
with
97 additions
and
8 deletions.
There are no files selected for viewing
Binary file not shown.
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
24 changes: 20 additions & 4 deletions
24
packages/chord-chart-studio/src/components/button/Button.jsx
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,19 +1,35 @@ | ||
import styles from './Button.module.css'; | ||
import React from 'react'; | ||
|
||
import { Button as ReactAriaButton } from 'react-aria-components'; | ||
import styles from './Button.module.css'; | ||
|
||
import React from 'react'; | ||
import Icon from '../icon/Icon'; | ||
|
||
const defaultType = 'primary'; | ||
|
||
export default function Button({ children, type = defaultType, onPress }) { | ||
export default function Button({ | ||
children, | ||
type = defaultType, | ||
icon = '', | ||
onPress, | ||
}) { | ||
const className = [ | ||
styles.button, | ||
styles[type] ? styles[type] : styles[defaultType], | ||
]; | ||
|
||
const renderedIcon = icon ? ( | ||
<span className={styles.icon}> | ||
<Icon id={icon} size={20} /> | ||
</span> | ||
) : ( | ||
'' | ||
); | ||
|
||
return ( | ||
<ReactAriaButton onPress={onPress} className={className.join(' ')}> | ||
{children} | ||
{renderedIcon} | ||
<span className={styles.label}>{children}</span> | ||
</ReactAriaButton> | ||
); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import React from 'react'; | ||
import { Plus, Import } from 'lucide-react'; | ||
|
||
export default function Icon({ id, size }) { | ||
let Component; | ||
|
||
switch (id) { | ||
case 'plus': | ||
Component = Plus; | ||
break; | ||
case 'import': | ||
Component = Import; | ||
break; | ||
} | ||
return <Component size={size} />; | ||
} |
24 changes: 24 additions & 0 deletions
24
packages/chord-chart-studio/src/components/icon/Icon.stories.js
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,24 @@ | ||
import Icon from './Icon'; | ||
|
||
export default { | ||
component: Icon, | ||
parameters: { | ||
layout: 'centered', | ||
}, | ||
tags: ['autodocs'], | ||
argTypes: { | ||
id: { | ||
control: 'select', | ||
options: ['plus', 'import'], | ||
}, | ||
}, | ||
args: {}, | ||
}; | ||
|
||
export const Plus = { | ||
args: { id: 'plus' }, | ||
}; | ||
|
||
export const Import = { | ||
args: { id: 'import' }, | ||
}; |
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