Skip to content

Commit e8116c2

Browse files
authored
Merge pull request #92 from components-ai/styled-component
Use a styled component with built-in tag names to render elements
2 parents 38818c4 + 57fde2a commit e8116c2

File tree

19 files changed

+66
-67
lines changed

19 files changed

+66
-67
lines changed

.changeset/mighty-keys-mix.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@compai/css-gui': patch
3+
---
4+
5+
Create a styled component with tag name members for rendering the canvas/element

apps/docs/components/examples/Demo.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useState } from 'react'
22
import Link from 'next/link'
3-
import { Editor, Inputs, RenderElement, codegen } from '@compai/css-gui'
3+
import { Editor, Inputs, styled, codegen } from '@compai/css-gui'
44
import { initialStyles } from '../../data/initial-styles'
55
import { defaultTheme } from '../../data/default-theme'
66

@@ -47,7 +47,7 @@ export function Demo() {
4747
</Editor>
4848
</div>
4949
<div sx={{ flexGrow: 1 }}>
50-
<RenderElement tagName="p" styles={styles}>
50+
<styled.p styles={styles}>
5151
“The parameters comprise sequences which are theoretically infinite
5252
but limits are, of course, set to them in practice. There is an
5353
upward limit to size and certainly a downward one... Within these
@@ -64,7 +64,7 @@ export function Demo() {
6464
</Link>{' '}
6565
by Karl Gerstner
6666
</em>
67-
</RenderElement>
67+
</styled.p>
6868
</div>
6969
</div>
7070
<div className="full-bleed">

apps/docs/components/examples/Fieldset.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useState } from 'react'
22
import {
33
Editor,
4-
RenderElement,
4+
styled,
55
Fieldset as FieldsetInput,
66
Inputs,
77
toCSSObject,
@@ -35,9 +35,9 @@ export const Fieldset = () => {
3535
</FieldsetInput>
3636
</>
3737
</Editor>
38-
<RenderElement tagName="p" styles={styles}>
38+
<styled.p styles={styles}>
3939
Hello, <b>world!</b>
40-
</RenderElement>
40+
</styled.p>
4141
<pre>{JSON.stringify(toCSSObject(styles), null, 2)}</pre>
4242
</>
4343
)

apps/docs/components/examples/FontFamily.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import { useState } from 'react'
2-
import { FontFamilyInput, RenderElement } from '@compai/css-gui'
2+
import { FontFamilyInput, styled } from '@compai/css-gui'
33

44
export const FontFamilyExample = () => {
55
const [fontFamily, setFontFamily] = useState('Abel')
66

77
return (
88
<>
9-
<RenderElement tagName='p' styles={{ fontFamily, fontSize: '24px' }}>
9+
<styled.p styles={{ fontFamily, fontSize: '24px' }}>
1010
Fun with fonts!
11-
</RenderElement>
11+
</styled.p>
1212
<FontFamilyInput value={fontFamily} onChange={setFontFamily} />
1313
</>
1414
)

apps/docs/pages/components/editor.mdx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ on its contents.
1414

1515
```js
1616
import { useState } from 'react'
17-
import { Editor, RenderElement } from '@compai/css-gui'
17+
import { Editor, styled } from '@compai/css-gui'
1818

1919
export const MyEditor = () => {
2020
const [styles, setStyles] = useState({
@@ -26,9 +26,7 @@ export const MyEditor = () => {
2626
return (
2727
<>
2828
<Editor styles={styles} onChange={setStyles} />
29-
<RenderElement tagName="p" styles={styles}>
30-
Hello, world!
31-
</RenderElement>
29+
<styled.p styles={styles}>Hello, world!</styled.p>
3230
</>
3331
)
3432
}
@@ -42,7 +40,7 @@ used. You can compose inputs yourselves in this scenario:
4240
```js
4341
import { useState } from 'react'
4442
import Link from 'next/link'
45-
import { Editor, Inputs, RenderElement, codegen } from '@compai/css-gui'
43+
import { Editor, Inputs, styled, codegen } from '@compai/css-gui'
4644

4745
export function Demo() {
4846
const [styles, setStyles] = useState({})
@@ -67,7 +65,7 @@ export function Demo() {
6765
<Inputs.Height />
6866
</div>
6967
</Editor>
70-
<RenderElement tagName="p" styles={styles}>
68+
<styled.p styles={styles}>
7169
“The parameters comprise sequences which are theoretically infinite but
7270
limits are, of course, set to them in practice. There is an upward limit
7371
to size and certainly a downward one... Within these sequences there are
@@ -82,7 +80,7 @@ export function Demo() {
8280
Designing Programmes
8381
</a> by Karl Gerstner
8482
</em>
85-
</RenderElement>
83+
</styled.p>
8684
<pre>{codegen.css(styles)}</pre>
8785
</>
8886
)

apps/docs/pages/components/fieldset.mdx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ all pseudo-elements and pseudo-selectors so you can also target
1616

1717
```js
1818
import { useState } from 'react'
19-
import { Editor, RenderElement, Fieldset, Inputs } from '@compai/css-gui'
19+
import { Editor, Fieldset, Inputs, styled } from '@compai/css-gui'
2020

2121
const MyEditor = () => {
2222
const [styles, setStyles] = useState({})
@@ -34,9 +34,7 @@ const MyEditor = () => {
3434
</Fieldset>
3535
</>
3636
</Editor>
37-
<RenderElement tagName="p" styles={styles}>
38-
Hello, world!
39-
</RenderElement>
37+
<styled.p styles={styles}>Hello, world!</styled.p>
4038
</>
4139
)
4240
}

apps/docs/pages/examples/border-images.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useState } from 'react'
22
import Link from 'next/link'
3-
import { Editor, Inputs, RenderElement, codegen } from '@compai/css-gui'
3+
import { Editor, Inputs, styled, codegen } from '@compai/css-gui'
44
import { defaultTheme } from '../../data/default-theme'
55

66
const initialStyles = {
@@ -53,7 +53,7 @@ export default function BorderImage() {
5353
</Editor>
5454
</div>
5555
<div sx={{ flexGrow: 1, pr: 4 }}>
56-
<RenderElement tagName="p" styles={styles}>
56+
<styled.p styles={styles}>
5757
“The parameters comprise sequences which are theoretically infinite
5858
but limits are, of course, set to them in practice. There is an
5959
upward limit to size and certainly a downward one... Within these
@@ -70,7 +70,7 @@ export default function BorderImage() {
7070
</Link>{' '}
7171
by Karl Gerstner
7272
</em>
73-
</RenderElement>
73+
</styled.p>
7474
</div>
7575
</div>
7676
<div className="full-bleed">

apps/docs/pages/examples/filters.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { RenderElement, Editor } from '@compai/css-gui'
1+
import { Editor, styled } from '@compai/css-gui'
22
import { useState } from 'react'
33

44
const initialStyles = {
@@ -17,8 +17,7 @@ export default function Filters() {
1717
justifyContent: 'center',
1818
}}
1919
>
20-
<RenderElement
21-
tagName="div"
20+
<styled.div
2221
styles={{
2322
width: '24rem',
2423
height: '24rem',
@@ -37,7 +36,7 @@ export default function Filters() {
3736
}}
3837
>
3938
Fun with filters
40-
</RenderElement>
39+
</styled.div>
4140
</div>
4241
</div>
4342
)

apps/docs/pages/examples/shadows.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { RenderElement, Editor } from '@compai/css-gui'
1+
import { Editor, styled } from '@compai/css-gui'
22
import { useState } from 'react'
33

44
const initialStyles = {
@@ -45,8 +45,7 @@ export default function Shadows() {
4545
justifyContent: 'center',
4646
}}
4747
>
48-
<RenderElement
49-
tagName="div"
48+
<styled.div
5049
styles={{
5150
width: '12rem',
5251
height: '12rem',
@@ -57,7 +56,7 @@ export default function Shadows() {
5756
}}
5857
>
5958
Fun with shadows
60-
</RenderElement>
59+
</styled.div>
6160
</div>
6261
</div>
6362
)

apps/docs/pages/examples/transforms.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { RenderElement, Editor } from '@compai/css-gui'
1+
import { Editor, styled } from '@compai/css-gui'
22
import { useState } from 'react'
33

44
const initialStyles = {
@@ -22,8 +22,7 @@ export default function Transforms() {
2222
justifyContent: 'center',
2323
}}
2424
>
25-
<RenderElement
26-
tagName="div"
25+
<styled.div
2726
styles={{
2827
width: '24rem',
2928
height: '24rem',
@@ -37,7 +36,7 @@ export default function Transforms() {
3736
}}
3837
>
3938
Fun with transforms
40-
</RenderElement>
39+
</styled.div>
4140
</div>
4241
</div>
4342
)

0 commit comments

Comments
 (0)