diff --git a/.changeset/stale-bees-grab.md b/.changeset/stale-bees-grab.md new file mode 100644 index 00000000..70f82e97 --- /dev/null +++ b/.changeset/stale-bees-grab.md @@ -0,0 +1,5 @@ +--- +'@compai/css-gui': patch +--- + +Remove x/y shorthands for spacing diff --git a/apps/docs/components/Sidebar.tsx b/apps/docs/components/Sidebar.tsx index bce00ba4..df4346fe 100644 --- a/apps/docs/components/Sidebar.tsx +++ b/apps/docs/components/Sidebar.tsx @@ -37,6 +37,7 @@ export const Sidebar = () => { Filters Transforms Border Images + Space Community GitHub Twitter diff --git a/apps/docs/components/examples/Space.tsx b/apps/docs/components/examples/Space.tsx new file mode 100644 index 00000000..bdfc85a8 --- /dev/null +++ b/apps/docs/components/examples/Space.tsx @@ -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 ( +
+ {/** @ts-ignore */} + +
+ + Fun with space! + +
+ {/** @ts-ignore */} +
{codegen.css(styles)}
+
+
{JSON.stringify(styles, null, 2)}
+
+ ) +} diff --git a/apps/docs/pages/examples/space.mdx b/apps/docs/pages/examples/space.mdx new file mode 100644 index 00000000..78c06174 --- /dev/null +++ b/apps/docs/pages/examples/space.mdx @@ -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 ( +
+ + + + + + + + + + +
+ + Fun with space! + +
+
{codegen.css(styles)}
+
+
{JSON.stringify(styles, null, 2)}
+
+ ) +} +``` + + + +## 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 ( +
+ + + + +
+ + Fun with space! + +
+
{codegen.css(styles)}
+
+
{JSON.stringify(styles, null, 2)}
+
+ ) +} +``` diff --git a/packages/gui/src/data/properties.ts b/packages/gui/src/data/properties.ts index 79e8bb7f..ea2ddc92 100644 --- a/packages/gui/src/data/properties.ts +++ b/packages/gui/src/data/properties.ts @@ -884,14 +884,6 @@ export const properties: Record = { type: 'length', percentage: true, }, - marginX: { - type: 'length', - percentage: true, - }, - marginY: { - type: 'length', - percentage: true, - }, marginTop: { type: 'length', percentage: true, @@ -1182,14 +1174,6 @@ export const properties: Record = { type: 'length', percentage: true, }, - paddingX: { - type: 'length', - percentage: true, - }, - paddingY: { - type: 'length', - percentage: true, - }, paddingTop: { type: 'length', percentage: true,