Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

314 B
Raw Blame
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;
};