mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 12:55:00 +00:00
refactor(component): new Radio component (#6910)
# New `RadioGroup` component to replace `RadioButton`  ### 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:
19
packages/frontend/component/src/utils/with-unit.ts
Normal file
19
packages/frontend/component/src/utils/with-unit.ts
Normal 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;
|
||||
};
|
||||
Reference in New Issue
Block a user