Skip to content

Commit

Permalink
Clarify the code samples
Browse files Browse the repository at this point in the history
  • Loading branch information
connor-baer committed Jun 19, 2023
1 parent 55e6bbf commit fa9b751
Showing 1 changed file with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,41 @@ This rule aims to automate the migration to CSS custom properties. CSS custom pr

Examples of **incorrect** code for this rule:

```ts
```tsx
const styles = (theme) => css`
padding: ${theme.spacings.kilo};
`;

const Box = styled.div`
padding: ${(theme) => theme.spacings.kilo};
`;

function Component() {
const theme = useTheme();
return <div style={{ padding: theme.spacings.kilo }} />;
}
```

Examples of **correct** code for this rule:

```ts
```tsx
const styles = () => css`
padding: var(--cui-spacings-kilo);
`;

// CSS custom properties aren't supported inside media queries
const unsupportedTokens = (theme) => css`
const Box = styled.div`
padding: var(--cui-spacings-kilo);
`;

function Component() {
return <div style={{ padding: 'var(--cui-spacings-kilo)' }} />;
}

// CSS custom properties aren't supported inside media queries,
// so the rule doesn't flag or replace `theme.mq.*` tokens.
const mediaQueries = (theme) => css`
${theme.mq.kilo} {
padding: var(--cui-spacings-kilo);
display: flex;
}
`;
```
Expand Down

0 comments on commit fa9b751

Please sign in to comment.