-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: introduce NEO style Tabs and RadioGroup
- Loading branch information
Showing
14 changed files
with
250 additions
and
112 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { ConfigProvider, Radio, theme } from 'antd'; | ||
import type { RadioGroupProps } from 'antd'; | ||
import { createStyles } from 'antd-style'; | ||
import classNames from 'classnames'; | ||
import React from 'react'; | ||
|
||
interface BAIRadioGroupProps extends RadioGroupProps {} | ||
|
||
const useStyle = createStyles(({ css, token }) => ({ | ||
baiRadioGroup: css` | ||
// border version | ||
.ant-radio-button-wrapper:not(.ant-radio-button-wrapper-checked)::before, | ||
.ant-radio-button-wrapper:hover::before { | ||
background-color: transparent; | ||
} | ||
.ant-radio-button-wrapper-checked:hover::before, | ||
.ant-radio-button-wrapper-checked::before { | ||
background-color: transparent; | ||
/* background-color: ${`rgba(${parseInt(token.colorPrimary.slice(1, 3), 16)}, ${parseInt(token.colorPrimary.slice(3, 5), 16)}, ${parseInt(token.colorPrimary.slice(5, 7), 16)}, 0.30)`}; */ | ||
} | ||
// original design version | ||
/* .ant-radio-button-wrapper-checked::before, | ||
.ant-radio-button-wrapper::before { | ||
background-color: ${token.colorBorder}; | ||
} | ||
.ant-radio-button-wrapper-checked:hover::before, | ||
.ant-radio-button-wrapper:hover::before { | ||
background-color: ${token.colorBorder}; | ||
} | ||
.ant-radio-button-wrapper-checked { | ||
border-color: transparent !important; | ||
} */ | ||
`, | ||
})); | ||
const BAIRadioGroup: React.FC<BAIRadioGroupProps> = ({ options, ...props }) => { | ||
const { styles } = useStyle(); | ||
const { token } = theme.useToken(); | ||
const colorPrimaryWithAlpha = `rgba(${parseInt(token.colorPrimary.slice(1, 3), 16)}, ${parseInt(token.colorPrimary.slice(3, 5), 16)}, ${parseInt(token.colorPrimary.slice(5, 7), 16)}, 0.15)`; | ||
const colorPrimaryWithLessAlpha = `rgba(${parseInt(token.colorPrimary.slice(1, 3), 16)}, ${parseInt(token.colorPrimary.slice(3, 5), 16)}, ${parseInt(token.colorPrimary.slice(5, 7), 16)}, 0.3)`; | ||
return ( | ||
<ConfigProvider | ||
theme={{ | ||
components: { | ||
Radio: { | ||
buttonSolidCheckedBg: colorPrimaryWithAlpha, | ||
buttonSolidCheckedColor: token.colorPrimary, | ||
buttonSolidCheckedHoverBg: colorPrimaryWithLessAlpha, | ||
}, | ||
}, | ||
}} | ||
> | ||
<Radio.Group | ||
className={classNames(styles.baiRadioGroup, props.className)} | ||
options={options} | ||
optionType="button" | ||
buttonStyle="solid" | ||
{...props} | ||
/> | ||
</ConfigProvider> | ||
); | ||
}; | ||
|
||
export default BAIRadioGroup; |
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,32 @@ | ||
import { Tabs, TabsProps } from 'antd'; | ||
import { createStyles } from 'antd-style'; | ||
import classNames from 'classnames'; | ||
import React from 'react'; | ||
|
||
const useStyles = createStyles(({ token, css }) => ({ | ||
baiTabs: css` | ||
.ant-tabs-nav::before { | ||
border-color: ${token.colorPrimary}; | ||
} | ||
.ant-tabs-tab:not(.ant-tabs-tab-active) { | ||
border-bottom-color: ${token.colorPrimary}; | ||
} | ||
.ant-tabs-tab.ant-tabs-tab-active { | ||
border-color: ${token.colorPrimary}; | ||
} | ||
`, | ||
})); | ||
|
||
interface BAITabsProps extends TabsProps {} | ||
const BAITabs: React.FC<BAITabsProps> = ({ className, ...props }) => { | ||
const { styles } = useStyles(); | ||
return ( | ||
<Tabs | ||
className={classNames(styles.baiTabs, className)} | ||
type="card" | ||
{...props} | ||
/> | ||
); | ||
}; | ||
|
||
export default BAITabs; |
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.