refactor(component): new Radio component (#6910)

# New `RadioGroup` component to replace `RadioButton`

![CleanShot 2024-06-25 at 17.18.02.gif](https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/LakojjjzZNf6ogjOVwKE/77241b07-a2dd-4d27-a322-3056f483f75a.gif)

### what's new
- [x] Change the API
- [x] More customizable options
- [x] Indicator animation
- [x] Dynamic width support(responsive)
- [x] Storybook
- [x] JSDoc
This commit is contained in:
CatsJuice
2024-06-27 06:04:19 +00:00
parent f15d1911ee
commit 827c952e9f
12 changed files with 551 additions and 15 deletions

View File

@@ -0,0 +1,19 @@
type AllowedUnits = 'px' | 'ms';
/**
* get value with unit
*/
export const withUnit = (
value: string | number,
unit: AllowedUnits
): string => {
if (typeof value === 'number') {
return `${value}${unit}`;
}
if (/^\d+(\.\d+)?$/.test(value)) {
return `${value}${unit}`;
}
return value;
};