Skip to content

Commit d3e257c

Browse files
authoredNov 29, 2021
fix: updates css func object types (#948)
* fix: updates css func object types * chore: adds test * chore: adds changeset
1 parent aece9b2 commit d3e257c

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed
 

‎.changeset/chilly-rats-design.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@compiled/react': patch
3+
---
4+
5+
Fixes `css` function types to allow nested styles

‎packages/react/src/css/__tests__/index.test.tsx

+7
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@ describe('css prop', () => {
2929
expect(getByText('hello world')).toHaveCompiledCss('font-size', '13px');
3030
});
3131

32+
it('should create hover styles', () => {
33+
const styles = css({ ':hover': { color: 'red' } });
34+
const { getByText } = render(<div css={styles}>hello world</div>);
35+
36+
expect(getByText('hello world')).toHaveCompiledCss('color', 'red', { target: ':hover' });
37+
});
38+
3239
it('should create css from tagged template expression variable', () => {
3340
const style = css`
3441
font-size: 13px;

‎packages/react/src/css/index.tsx

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
/* eslint-disable import/export */
22

3-
import type { BasicTemplateInterpolations, CSSProps, FunctionInterpolation } from '../types';
3+
import type {
4+
AnyKeyCssProps,
5+
BasicTemplateInterpolations,
6+
CSSProps,
7+
FunctionInterpolation,
8+
} from '../types';
49
import { createSetupError } from '../utils/error';
510

611
/**
@@ -33,7 +38,7 @@ export default function css<T = void>(
3338
*
3439
* @param css
3540
*/
36-
export default function css(_css: CSSProps): CSSProps;
41+
export default function css(_css: AnyKeyCssProps<void> | CSSProps): CSSProps;
3742

3843
export default function css<T = void>(
3944
_css: TemplateStringsArray | CSSProps,

0 commit comments

Comments
 (0)
Please sign in to comment.