-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #95 from components-ai/positional-space
Positional space
- Loading branch information
Showing
5 changed files
with
115 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@compai/css-gui': patch | ||
--- | ||
|
||
Remove x/y shorthands for spacing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { useState } from 'react' | ||
import { codegen, Editor, styled } from '@compai/css-gui' | ||
|
||
export const SpaceExample = () => { | ||
const [styles, setStyles] = useState({ | ||
margin: { value: 16, unit: 'px' }, | ||
padding: { value: 16, unit: 'px' }, | ||
}) | ||
|
||
return ( | ||
<div> | ||
{/** @ts-ignore */} | ||
<Editor styles={styles} onChange={setStyles} /> | ||
<div sx={{ border: 'thin solid', borderColor: 'border', mt: [3, 4, 5] }}> | ||
<styled.p styles={{ ...styles, border: 'thin solid' }}> | ||
Fun with space! | ||
</styled.p> | ||
</div> | ||
{/** @ts-ignore */} | ||
<pre>{codegen.css(styles)}</pre> | ||
<hr /> | ||
<pre>{JSON.stringify(styles, null, 2)}</pre> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import { SpaceExample } from '../../components/examples/Space' | ||
|
||
## Space | ||
|
||
Space refers to `margin` and `padding` controls. In order to keep things | ||
as simple as possible early on, we recommend that you use the longhand | ||
version. | ||
|
||
```js | ||
import { useState } from 'react' | ||
import { Editor, Inputs, styled, codegen } from '@compai/css-gui' | ||
|
||
export const SpaceExample = () => { | ||
const [styles, setStyles] = useState({ | ||
marginTop: { value: 16, unit: 'px' }, | ||
marginRight: { value: 16, unit: 'px' }, | ||
marginLeft: { value: 16, unit: 'px' }, | ||
marginBottom: { value: 16, unit: 'px' }, | ||
paddingTop: { value: 16, unit: 'px' }, | ||
paddingRight: { value: 16, unit: 'px' }, | ||
paddingLeft: { value: 16, unit: 'px' }, | ||
paddingBottom: { value: 16, unit: 'px' }, | ||
}) | ||
|
||
return ( | ||
<div> | ||
<Editor styles={styles} onChange={setStyles}> | ||
<Inputs.MarginTop /> | ||
<Inputs.MarginRight /> | ||
<Inputs.MarginBottom /> | ||
<Inputs.MarginLeft /> | ||
<Inputs.PaddingTop /> | ||
<Inputs.PaddingRight /> | ||
<Inputs.PaddingBottom /> | ||
<Inputs.PaddingLeft /> | ||
</Editor> | ||
<div sx={{ border: 'thin solid', borderColor: 'border', mt: [3, 4, 5] }}> | ||
<styled.p styles={{ ...styles, border: 'thin solid' }}> | ||
Fun with space! | ||
</styled.p> | ||
</div> | ||
<pre>{codegen.css(styles)}</pre> | ||
<hr /> | ||
<pre>{JSON.stringify(styles, null, 2)}</pre> | ||
</div> | ||
) | ||
} | ||
``` | ||
|
||
<SpaceExample /> | ||
|
||
## Padding/Margin Shorthand | ||
|
||
If desirable, you can also use the spacing shorthand to target all directions | ||
at once. | ||
|
||
```js | ||
import { useState } from 'react' | ||
import { Editor, Inputs, styled, codegen } from '@compai/css-gui' | ||
|
||
export const SpaceExample = () => { | ||
const [styles, setStyles] = useState({ | ||
margin: { value: 16, unit: 'px' }, | ||
padding: { value: 16, unit: 'px' }, | ||
}) | ||
|
||
return ( | ||
<div> | ||
<Editor styles={styles} onChange={setStyles}> | ||
<Inputs.Margin /> | ||
<Inputs.Padding /> | ||
</Editor> | ||
<div sx={{ border: 'thin solid', borderColor: 'border', mt: [3, 4, 5] }}> | ||
<styled.p styles={{ ...styles, border: 'thin solid' }}> | ||
Fun with space! | ||
</styled.p> | ||
</div> | ||
<pre>{codegen.css(styles)}</pre> | ||
<hr /> | ||
<pre>{JSON.stringify(styles, null, 2)}</pre> | ||
</div> | ||
) | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
d91be73
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
css-gui – ./
css-gui-git-main-components-ai.vercel.app
css-gui.vercel.app
css-gui-components-ai.vercel.app