Skip to content

Commit

Permalink
Merge pull request #103 from components-ai/directional-borders
Browse files Browse the repository at this point in the history
Add directional borders
  • Loading branch information
johno authored May 3, 2022
2 parents f3d9527 + cf6302f commit 8adde2e
Show file tree
Hide file tree
Showing 4 changed files with 233 additions and 28 deletions.
5 changes: 5 additions & 0 deletions .changeset/honest-carpets-check.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@compai/css-gui': patch
---

Add directional borders
5 changes: 4 additions & 1 deletion apps/docs/components/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,16 @@ export const Sidebar = () => {
<NavItem href="/examples/shadows">Shadows</NavItem>
<NavItem href="/examples/filters">Filters</NavItem>
<NavItem href="/examples/transforms">Transforms</NavItem>
<NavItem href="/examples/borders">Borders</NavItem>
<NavItem href="/examples/border-images">Border Images</NavItem>
<NavItem href="/examples/backgrounds">Backgrounds</NavItem>
<NavItem href="/examples/space">Space</NavItem>
<NavItem href="/examples/text-decoration">Text Decoration</NavItem>
<NavSectionTitle>TODO</NavSectionTitle>
<NavItem href="/unsupported">Unsupported Properties</NavItem>
<NavItem href="https://github.com/components-ai/css.gui/issues">Issues</NavItem>
<NavItem href="https://github.com/components-ai/css.gui/issues">
Issues
</NavItem>
<NavSectionTitle>Reference</NavSectionTitle>
<NavItem href="/colophon">Colophon</NavItem>
<NavSectionTitle>Community</NavSectionTitle>
Expand Down
91 changes: 91 additions & 0 deletions apps/docs/pages/examples/borders.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import { useState } from 'react'
import Link from 'next/link'
import { Editor, Inputs, styled, codegen } from '@compai/css-gui'
import { defaultTheme } from '../../data/default-theme'

const initialStyles = {
padding: {
value: 64,
unit: 'px',
},
}

export default function BorderImage() {
const [styles, setStyles] = useState<any>(initialStyles)

return (
<>
<div
className="full-bleed"
sx={{
display: 'flex',
py: [2, 3, 4],
borderTopWidth: 'thin',
}}
>
<div sx={{ px: [2, 3, 4] }}>
<Editor styles={styles} onChange={setStyles} theme={defaultTheme}>
<div sx={{ display: 'grid', gap: '.5rem', width: '240px' }}>
<h3>Color</h3>
<Inputs.BorderLeftColor />
<Inputs.BorderRightColor />
<Inputs.BorderTopColor />
<Inputs.BorderBottomColor />
<h3>Style</h3>
<Inputs.BorderLeftStyle />
<Inputs.BorderRightStyle />
<Inputs.BorderTopStyle />
<Inputs.BorderBottomStyle />
<h3>Width</h3>
<Inputs.BorderLeftWidth />
<Inputs.BorderRightWidth />
<Inputs.BorderTopWidth />
<Inputs.BorderBottomWidth />
<h3>Radius</h3>
<Inputs.BorderTopLeftRadius />
<Inputs.BorderTopRightRadius />
<Inputs.BorderBottomLeftRadius />
<Inputs.BorderBottomRightRadius />
<h3>Spacing</h3>
<Inputs.Padding />
<Inputs.Margin />
</div>
</Editor>
</div>
<div sx={{ flexGrow: 1, pr: 4 }}>
<styled.p styles={styles}>
“The parameters comprise sequences which are theoretically infinite
but limits are, of course, set to them in practice. There is an
upward limit to size and certainly a downward one... Within these
sequences there are reasonable bounds; extremes set by technical and
functional experience”
<br /> <br />
<em>
In{' '}
<Link
href="https://www.lars-mueller-publishers.com/designing-programmes-0"
passHref={true}
>
<a style={{ color: styles.color }}>Designing Programmes</a>
</Link>{' '}
by Karl Gerstner
</em>
</styled.p>
</div>
</div>
<div className="full-bleed">
<pre
sx={{
p: [2, 3, 4],
borderTop: 'thin solid',
borderColor: 'border',
width: '100%',
fontSize: 3,
}}
>
{codegen.css(styles)}
</pre>
</div>
</>
)
}
160 changes: 133 additions & 27 deletions packages/gui/src/data/properties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,33 +214,6 @@ export const properties: Record<string, PropertyData> = {
stringify: stringifyImageSource,
label: 'Background Image',
},
// TODO: 4-positional arguments separated by spaces
borderImageOutset: {
type: 'length',
number: true,
},
// TODO: 2-positional arguments separated by spaces
borderImageRepeat: {
type: 'keyword',
keywords: ['stretch', 'repeat', 'round', 'space'],
},
borderImageSlice: {
type: 'length',
number: true,
percentage: true,
range: { number: [-1, 2000] },
},
// TODO this actually can only accept *one* image value, not an array
borderImageSource: {
type: ImageSourcePicker,
stringify: stringifyImageSource,
label: 'Border Image',
},
// TODO this can accept multiple values
borderImageWidth: {
type: 'length',
keywords: ['thin', 'medium', 'thick'],
},
backgroundOrigin: {
type: 'keyword',
keywords: ['border-box', 'padding-box', 'content-box'],
Expand Down Expand Up @@ -303,6 +276,139 @@ export const properties: Record<string, PropertyData> = {
percentage: true,
keywords: ['max-content', 'min-content', 'auto'],
},
// TODO: 4-positional arguments separated by spaces
borderImageOutset: {
type: 'length',
number: true,
},
// TODO: 2-positional arguments separated by spaces
borderImageRepeat: {
type: 'keyword',
keywords: ['stretch', 'repeat', 'round', 'space'],
},
borderImageSlice: {
type: 'length',
number: true,
percentage: true,
range: { number: [-1, 2000] },
},
// TODO this actually can only accept *one* image value, not an array
borderImageSource: {
type: ImageSourcePicker,
stringify: stringifyImageSource,
label: 'Border Image',
},
// TODO this can accept multiple values
borderImageWidth: {
type: 'length',
keywords: ['thin', 'medium', 'thick'],
},
borderBottomColor: {
type: 'color',
keywords: ['currentcolor', 'transparent'],
},
// TODO this can accept two values
borderBottomLeftRadius: {
type: 'length',
},
borderBottomRightRadius: {
type: 'length',
},
borderBottomStyle: {
type: 'keyword',
keywords: [
'none',
'hidden',
'dotted',
'dashed',
'solid',
'double',
'groove',
'ridge',
'inset',
'outset',
],
},
borderBottomWidth: {
type: 'length',
keywords: ['thin', 'medium', 'thick'],
},
borderLeftColor: {
type: 'color',
keywords: ['currentcolor', 'transparent'],
},
borderLeftStyle: {
type: 'keyword',
keywords: [
'none',
'hidden',
'dotted',
'dashed',
'solid',
'double',
'groove',
'ridge',
'inset',
'outset',
],
},
borderLeftWidth: {
type: 'length',
keywords: ['thin', 'medium', 'thick'],
},
borderRightColor: {
type: 'color',
keywords: ['currentcolor', 'transparent'],
},
borderRightStyle: {
type: 'keyword',
keywords: [
'none',
'hidden',
'dotted',
'dashed',
'solid',
'double',
'groove',
'ridge',
'inset',
'outset',
],
},
borderRightWidth: {
type: 'length',
keywords: ['thin', 'medium', 'thick'],
},
borderTopColor: {
type: 'color',
keywords: ['currentcolor', 'transparent'],
},
// TODO this can accept two values
borderTopLeftRadius: {
type: 'length',
},
borderTopRightRadius: {
type: 'length',
},
borderTopStyle: {
type: 'keyword',
keywords: [
'none',
'hidden',
'dotted',
'dashed',
'solid',
'double',
'groove',
'ridge',
'inset',
'outset',
],
},
borderTopWidth: {
type: 'length',
keywords: ['thin', 'medium', 'thick'],
},
borderColor: {
type: 'color',
keywords: ['currentcolor', 'transparent'],
Expand Down

1 comment on commit 8adde2e

@vercel
Copy link

@vercel vercel bot commented on 8adde2e May 3, 2022

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-components-ai.vercel.app
css-gui-git-main-components-ai.vercel.app
css-gui.vercel.app

Please sign in to comment.