Skip to content

Commit

Permalink
fix(typography-warning): [typography] warning when typography is not …
Browse files Browse the repository at this point in the history
…existed
  • Loading branch information
233mawile authored and 233mawile-rc committed Jul 13, 2023
1 parent d0dc554 commit 35291e5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion packages/juno-core/src/foundation/styles/typography.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { css } from '../styled-components';
import { RcThemeProps } from '../theme/theme.type';
import { RcTypographyKeys } from '../theme/typography.type';
import { logInDev } from '../utils';

/**
* get typography key value with token
Expand All @@ -17,7 +18,16 @@ function typographyProp(name: RcTypographyKeys, key: string) {
return ({ theme }: RcThemeProps) => {
const themeOfTypography = theme.typography[name];
if (typeof themeOfTypography !== 'object') {
throw new Error(`Unexpected typography name: ${name}`);
if (process.env.NODE_ENV !== 'production') {
throw new Error(`Unexpected typography name: ${name}`);
} else {
logInDev({
message: `Unexpected typography name: ${name}`,
component: 'typographyProp',
level: 'warn',
});
return undefined;
}
}
return themeOfTypography[key];
};
Expand Down
2 changes: 1 addition & 1 deletion sync-github.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"latestCommitSHA": "e8ab96f9423498e6138559bebf947058973754aa"
"latestCommitSHA": "67e2f0e9b0ddeb1fe1f09327d3b32011acfa5051"
}

0 comments on commit 35291e5

Please sign in to comment.