Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/breezy-owls-change.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@devup-ui/react": patch
---

Add grid, Support for selector in css
18 changes: 18 additions & 0 deletions libs/extractor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -812,6 +812,24 @@ mod tests {
<Box className={c({
bg:"red"
})}/>;
"#,
ExtractOption {
package: "@devup-ui/core".to_string(),
css_file: None
}
)
.unwrap());

reset_class_map();
assert_debug_snapshot!(extract(
"test.tsx",
r#"import { css } from "@devup-ui/core";
<Box className={css({
_hover: {
bg:"red",
color:"blue"
}
})}/>;
"#,
ExtractOption {
package: "@devup-ui/core".to_string(),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
source: libs/extractor/src/lib.rs
expression: "extract(\"test.tsx\",\nr#\"import { css } from \"@devup-ui/core\";\n<Box className={css({\n _hover: {\n bg:\"red\",\n color:\"blue\"\n }\n})}/>;\n\"#,\nExtractOption\n{ package: \"@devup-ui/core\".to_string(), css_file: None }).unwrap()"
---
ExtractOutput {
styles: [
Static(
ExtractStaticStyle {
property: "color",
value: "blue",
level: 0,
selector: Some(
Postfix(
"hover",
),
),
basic: false,
},
),
Static(
ExtractStaticStyle {
property: "background",
value: "red",
level: 0,
selector: Some(
Postfix(
"hover",
),
),
basic: false,
},
),
],
code: "import \"@devup-ui/core/devup-ui.css\";\nimport { css } from \"@devup-ui/core\";\n<Box className={css(\"d0 d1\")} />;\n",
}
1 change: 1 addition & 0 deletions packages/react/src/__tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ describe('export', () => {
Text: expect.any(Function),
VStack: expect.any(Function),
Image: expect.any(Function),
Grid: expect.any(Function),

css: expect.any(Function),
})
Expand Down
9 changes: 9 additions & 0 deletions packages/react/src/components/Grid.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import type { DevupProps } from '../types/props'
import type { Merge } from '../types/utils'

export function Grid<T extends React.ElementType = 'div'>(
// eslint-disable-next-line @typescript-eslint/no-unused-vars
props: Merge<React.ComponentProps<T>, DevupProps>,
): React.ReactElement {
throw new Error('Cannot run on the runtime')
}
2 changes: 2 additions & 0 deletions packages/react/src/components/__tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Box } from '../Box'
import { Button } from '../Button'
import { Center } from '../Center'
import { Flex } from '../Flex'
import { Grid } from '../Grid'
import { Image } from '../Image'
import { Input } from '../Input'
import { Text } from '../Text'
Expand All @@ -17,5 +18,6 @@ describe('Component', () => {
expect(() => Text({})).toThrowError('Cannot run on the runtime')
expect(() => VStack({})).toThrowError('Cannot run on the runtime')
expect(() => Image({})).toThrowError('Cannot run on the runtime')
expect(() => Grid({})).toThrowError('Cannot run on the runtime')
})
})
1 change: 1 addition & 0 deletions packages/react/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export { Box } from './components/Box'
export { Button } from './components/Button'
export { Center } from './components/Center'
export { Flex } from './components/Flex'
export { Grid } from './components/Grid'
export { Image } from './components/Image'
export { Input } from './components/Input'
export { Text } from './components/Text'
Expand Down
5 changes: 4 additions & 1 deletion packages/react/src/utils/css.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { DevupCommonProps } from '../types/props'
import type { DevupSelectorProps } from '../types/props/selector'

export function css(props: DevupCommonProps): string
export function css(strings: TemplateStringsArray): string

export function css(strings: TemplateStringsArray | DevupCommonProps): string {
export function css(
strings: TemplateStringsArray | (DevupCommonProps & DevupSelectorProps),
): string {
if (Array.isArray(strings)) {
return strings.join('')
}
Expand Down
Loading