Skip to content

Commit

Permalink
feat: add rem checker, add transition to themes
Browse files Browse the repository at this point in the history
  • Loading branch information
dkireev committed Oct 8, 2020
1 parent 9619e45 commit 1d20c03
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
10 changes: 8 additions & 2 deletions packages/themes/src/sharedTokens/sharedTokens.ts
Expand Up @@ -21,6 +21,8 @@ const borderWidth = 1;

const space = 16;

const transitionDuration = 0.2;

const sharedTokens: Shared = {
base: {
space,
Expand Down Expand Up @@ -69,8 +71,12 @@ const sharedTokens: Shared = {
xlarge: space * 2.5,
},
transitionDuration: {
slow: 0.4,
default: 0.2,
slow: transitionDuration * 2,
default: transitionDuration,
},
transition: {
slow: `${transitionDuration * 2}s ease-in-out`,
default: `${transitionDuration}s ease-in-out`,
},
zIndex: {
carouselControl: 5,
Expand Down
3 changes: 2 additions & 1 deletion packages/themes/src/types/theme.ts
Expand Up @@ -10,7 +10,7 @@ import { MaxWidth } from './maxWidth';
import { Opacity } from './opacity';
import { Radius } from './radius';
import { Space } from './space';
import { TransitionDuration } from './transition';
import { TransitionDuration, Transition } from './transition';
import { ZIndex } from './zIndex';

export type Theme = {
Expand All @@ -32,5 +32,6 @@ export type Theme = {
radius: Radius;
space: Space;
transitionDuration: TransitionDuration;
transition: Transition;
zIndex: ZIndex;
};
5 changes: 5 additions & 0 deletions packages/themes/src/types/transition.ts
Expand Up @@ -2,3 +2,8 @@ export type TransitionDuration = {
slow: number;
default: number;
};

export type Transition = {
slow: string;
default: string;
};
9 changes: 9 additions & 0 deletions packages/utils/src/rem/rem.ts
Expand Up @@ -2,6 +2,15 @@ import polishedRem from 'polished/lib/helpers/rem';
import { sharedTokens } from '@heathmont/moon-themes';

const rem = (value: string | number, baseFontSize: string | number = 16) => {
if (
![10, 14, 18, '10px', '14px', '18px'].includes(value) ||
(typeof value === 'number' && value % 4 !== 0)
) {
// eslint-disable-next-line no-console
console.warn(
`ATTENTION! You've used rem(${value}) which is out of Moon DS range! Please use 4px-step approach instead!`
);
}
return polishedRem(value, baseFontSize || sharedTokens.base.fontSize);
};

Expand Down

0 comments on commit 1d20c03

Please sign in to comment.