Skip to content

Commit

Permalink
feat: add warning head (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
MadCcc committed Apr 18, 2022
1 parent d30bff5 commit 9f37eaa
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ export function token2key(token: any, slat: string): string {
return hash(`${slat}_${flattenToken(token)}`);
}

export function warning(message: string) {
devWarning(false, `[Ant Design Css-in-js] ${message}`);
}

export const styleValidate = (
key: string,
value: string | number | boolean | null | undefined,
Expand All @@ -39,8 +43,7 @@ export const styleValidate = (
(value.charAt(0) !== value.charAt(value.length - 1) ||
(value.charAt(0) !== '"' && value.charAt(0) !== "'")))
) {
devWarning(
false,
warning(
`You seem to be using a value for 'content' without quotes, try replacing it with \`content: '"${value}"'\``,
);
}
Expand All @@ -63,8 +66,7 @@ export const styleValidate = (
case 'borderTopRightRadius':
case 'borderBottomLeftRadius':
case 'borderBottomRightRadius':
devWarning(
false,
warning(
`You seem to be using non-logical property '${key}' which is not compatible with RTL mode. Please use logical properties and values instead. For more information: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Logical_Properties.`,
);
return;
Expand All @@ -76,8 +78,7 @@ export const styleValidate = (
if (typeof value === 'string') {
const valueArr = value.split(' ').map((item) => item.trim());
if (valueArr.length === 4 && valueArr[1] !== valueArr[3]) {
devWarning(
false,
warning(
`You seem to be using '${key}' property with different left ${key} and right ${key}, which is not compatible with RTL mode. Please use logical properties and values instead. For more information: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Logical_Properties.`,
);
}
Expand All @@ -86,8 +87,7 @@ export const styleValidate = (
case 'clear':
case 'textAlign':
if (value === 'left' || value === 'right') {
devWarning(
false,
warning(
`You seem to be using non-logical value '${value}' of ${key}, which is not compatible with RTL mode. Please use logical properties and values instead. For more information: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Logical_Properties.`,
);
}
Expand Down Expand Up @@ -116,8 +116,7 @@ export const styleValidate = (
}, false);

if (invalid) {
devWarning(
false,
warning(
`You seem to be using non-logical value '${value}' of ${key}, which is not compatible with RTL mode. Please use logical properties and values instead. For more information: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Logical_Properties.`,
);
}
Expand Down

0 comments on commit 9f37eaa

Please sign in to comment.