Skip to content

Commit 35092d6

Browse files
committed
Implement typing
1 parent ab5e889 commit 35092d6

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

apps/next/src/app/page.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
11
'use client'
22

3-
import { Box, css, Text } from '@devup-ui/react'
3+
import { Box, css, styled, Text } from '@devup-ui/react'
44
import { useState } from 'react'
5+
const color = 'yellow'
6+
7+
const StyledFooter = styled.footer<{ type: '1' | '2' }>`
8+
background-color: ${color};
9+
color: ${(props) => (props.type === '1' ? 'red' : 'white')};
10+
`
511

612
export default function HomePage() {
713
const [color, setColor] = useState('yellow')
814
const [enabled, setEnabled] = useState(false)
915

1016
return (
1117
<div>
18+
<StyledFooter type="2">IMPLEMENTATION~</StyledFooter>
1219
<p
1320
style={{
1421
backgroundColor: 'blue',

packages/react/src/utils/styled.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,29 @@ interface StyledCreator {
55
tag: T,
66
): (
77
strings: TemplateStringsArray | DevupPropsWithTheme,
8+
...values: (
9+
| ((props: React.ComponentProps<T>) => unknown)
10+
| string
11+
| number
12+
| boolean
13+
| null
14+
| undefined
15+
)[][]
816
) => (props: React.ComponentProps<T>) => React.ReactElement
917
}
1018

1119
type Styled = StyledCreator & {
12-
[T in keyof React.JSX.IntrinsicElements]: <P extends React.ComponentProps<T>>(
20+
[T in keyof React.JSX.IntrinsicElements]: <P>(
1321
strings: TemplateStringsArray | DevupPropsWithTheme,
14-
) => (props: P) => React.ReactElement
22+
...values: (
23+
| ((props: P & React.ComponentProps<T>) => unknown)
24+
| string
25+
| number
26+
| boolean
27+
| null
28+
| undefined
29+
)[]
30+
) => (props: P & React.ComponentProps<T>) => React.ReactElement
1531
}
1632

1733
export const styled: Styled = new Proxy(Function.prototype, {

0 commit comments

Comments
 (0)