mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 04:48:53 +00:00
# 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
20 lines
314 B
TypeScript
20 lines
314 B
TypeScript
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;
|
|
};
|