Skip to content
This repository has been archived by the owner on Oct 20, 2022. It is now read-only.

Commit

Permalink
fix: disallow extrabold for secondary, tertiary, caption (#579)
Browse files Browse the repository at this point in the history
* fix: disallow extrabold for secondary, tertiary, caption

* fix: typings for typogaphy's weights
  • Loading branch information
JacobBlomgren authored Mar 11, 2019
1 parent 0e24228 commit 1208079
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
7 changes: 4 additions & 3 deletions src/styles/typography.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,20 @@ export default function createTypography() {
...ifSmallDevice(14, 16),
fontWeight: WEIGHTS[weight] || WEIGHTS.regular,
});
const coerceExtraboldToBold = weight => (weight === 'extrabold' ? WEIGHTS.bold : WEIGHTS[weight]);
const secondary = ({ weight = 'regular' } = {}) => ({
...ifSmallDevice(12, 14),
fontWeight: WEIGHTS[weight] || WEIGHTS.regular,
fontWeight: coerceExtraboldToBold(weight) || WEIGHTS.regular,
});
const tertiary = ({ weight = 'regular' } = {}) => ({
...ifSmallDevice(10, 12),
fontWeight: WEIGHTS[weight] || WEIGHTS.regular,
fontWeight: coerceExtraboldToBold(weight) || WEIGHTS.regular,
});

const caption = ({ weight = 'regular', uppercase = false } = {}) => ({
// @todo discuss lower value with designers
...ifSmallDevice(10, 10),
fontWeight: WEIGHTS[weight] || WEIGHTS.regular,
fontWeight: coerceExtraboldToBold(weight) || WEIGHTS.regular,
...(uppercase ? { textTransform: 'uppercase' } : {}),
});

Expand Down
9 changes: 5 additions & 4 deletions types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@ declare module 'nordnet-ui-kit' {
letterSpacing: string;
};
type Weight = 'regular' | 'bold' | 'extrabold';
type WeightNoExtrabold = 'regular' | 'bold';
// prettier-ignore
type TypographyScheme = {
caption: (options: { weight: Weight, uppercase: boolean }) => TypographyCSS & { textTransform: string};
hero: (options: { weight: Weight }) => TypographyCSS;
caption: (options: { weight: WeightNoExtrabold, uppercase: boolean }) => TypographyCSS & { textTransform: string};
hero: () => TypographyCSS;
title1: (options: { weight: Weight }) => TypographyCSS;
title2: (options: { weight: Weight }) => TypographyCSS;
title3: (options: { weight: Weight }) => TypographyCSS;
primary: (options: { weight: Weight }) => TypographyCSS;
secondary: (options: { weight: Weight }) => TypographyCSS;
tertiary: (options: { weight: Weight }) => TypographyCSS;
secondary: (options: { weight: WeightNoExtrabold }) => TypographyCSS;
tertiary: (options: { weight: WeightNoExtrabold }) => TypographyCSS;
};

export type Theme = {
Expand Down

1 comment on commit 1208079

@vercel
Copy link

@vercel vercel bot commented on 1208079 Mar 11, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully aliased the URL https://nordnet-ui-kit-ccw5kabdv.now.sh to the following alias.

Please sign in to comment.