Skip to content

Commit

Permalink
add spec and fix sx
Browse files Browse the repository at this point in the history
  • Loading branch information
siriwatknp committed Aug 5, 2024
1 parent b9fcdef commit b54c212
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 3 deletions.
5 changes: 4 additions & 1 deletion packages/pigment-css-react/src/sx.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import type { CSSObjectNoCallback } from './base';
import type { ThemeArgs } from './theme';

export type SxProp = CSSObjectNoCallback | ((themeArgs: ThemeArgs) => CSSObjectNoCallback);
export type SxProp =
| CSSObjectNoCallback
| ((themeArgs: ThemeArgs['theme']) => CSSObjectNoCallback)
| ReadonlyArray<CSSObjectNoCallback | ((themeArgs: ThemeArgs['theme']) => CSSObjectNoCallback)>;

export default function sx(arg: SxProp | Array<SxProp>, componentClass?: string): string;
4 changes: 2 additions & 2 deletions packages/pigment-css-react/tests/Box.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { Box } from '@pigment-css/react/Box';
import Box from '../src/Box';

export function App() {
return (
Expand All @@ -13,7 +13,7 @@ export function App() {
Dialog
</Box>
{/* @ts-expect-error */}
<Box component="dialog" as="button" open>
<Box component="dialog" as="button" href>
Dialog 2
</Box>
</Box>
Expand Down
10 changes: 10 additions & 0 deletions packages/pigment-css-react/tests/Container.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import * as React from 'react';
import Container from '../src/Container';

<Container maxWidth="md" />;

<Container
className=""
style={{ accentColor: 'ActiveBorder', marginTop: '1rem' }}
data-testid="foo"
/>;
6 changes: 6 additions & 0 deletions packages/pigment-css-react/tests/Grid.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import * as React from 'react';
import Grid from '../src/Grid';

<Grid size={{ xs: 2, md: 3, lg: 4 }} />;

<Grid className="" style={{ accentColor: 'ActiveBorder', marginTop: '1rem' }} data-testid="foo" />;
10 changes: 10 additions & 0 deletions packages/pigment-css-react/tests/Hidden.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import * as React from 'react';
import Hidden from '../src/Hidden';

<Hidden xsUp mdDown />;

<Hidden
className=""
style={{ accentColor: 'ActiveBorder', marginTop: '1rem' }}
data-testid="foo"
/>;
5 changes: 5 additions & 0 deletions packages/pigment-css-react/tests/Stack.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import * as React from 'react';
import Stack from '../src/Stack';

<Stack spacing={2} direction={{ md: 'row' }} />;

<Stack className="" style={{ accentColor: 'ActiveBorder', marginTop: '1rem' }} data-testid="foo" />;

<Stack
// @ts-expect-error
display={{
xs: 'flex',
xl: 'inline-flex',
Expand Down
17 changes: 17 additions & 0 deletions packages/pigment-css-react/tests/sx.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { SxProp } from '../src/sx';

const sx1: SxProp = { color: 'red' };

const sx2: SxProp = (theme) => ({
color: theme.palette.primary.main,
});

const sx3: SxProp = [{ color: 'red' }, { backgroundColor: 'blue', color: 'white' }];

const test = true;
const sx4: SxProp = [
test ? { color: 'red' } : { backgroundColor: 'blue', color: 'white' },
(theme) => ({
border: `1px solid ${theme.palette.primary.main}`,
}),
];

0 comments on commit b54c212

Please sign in to comment.