Skip to content

Commit

Permalink
some docs
Browse files Browse the repository at this point in the history
  • Loading branch information
robinweser committed Jul 5, 2024
1 parent d618977 commit d5771ee
Show file tree
Hide file tree
Showing 2 changed files with 129 additions and 4 deletions.
127 changes: 126 additions & 1 deletion packages/brandeur-primitives/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,137 @@ const App = (

### createSystem

#### Arguments

Accepts an object including all of brandeur's [createHooks]() [configuration]().<br />
Additionally, also accepts the following properties:

| Argument | Type | Default | Description |
| ------------ | -------- | ------- | ---------------------------- |
| baselineGrid | _number_ | 1 | Multiplier for spacing props |

#### Returns

An object containing the [styleSheet]() from [createHooks]() and an generic [El](#el) component.

#### El

#### styleSheet
##### Props

| Props | Type | Default | Description |
| ----- | --------------------- | ------- | ----------------------------------------------------------------- |
| as | [React.ElementType]() | `div` | |
| style | [Style]() | | Brandeur styles that are automatically converted to inline styles |

> **Note**: All other props are passed down to the rendered component.
##### Example

```tsx
function Button(props) {
return <button {...props} />
}

const Example = (
<El style={{ padding: 10 }}>
<El as="h1" style={{ fontSize: 20 }}>
Title
</El>
<El
as={Button}
type="button"
style={{ backgroundColor: 'blue' }}
onClick={() => alert('CLICKED')}>
Click me
</El>
</El>
)
```

### createBox

Takes the system object and returns Box component with first-class flexbox layouting props.<br />

> **Important**: It uses different default values for some flexbox properties to align more closely with the React Native defaults.
#### Props

Box renders a [El](#el) component and thus also accepts the `as` and `style` props mentioned above.

| Prop | Shorthand |  CSS Property |  Default |
| ------------------ | --------- | ---------------- | --------- |
| backgroundColor | bg | | |
| gap | | | |
| display | | | `flex` |
| position | | | |
| overflow | | | |
| overflowX | | | |
| overflowY | | | |
| padding | | | |
| paddingLeft | | | |
| paddingRight | | | |
| paddingBottom | | | |
| paddingTop | | | |
| paddingX | | | |
| paddingInline | | | |
| paddingInlineStart | | | |
| paddingInlineEnd | | | |
| paddingY | | | |
| paddingBlock | | | |
| paddingBlockStart | | | |
| paddingBlockEnd | | | |
| margin | | | |
| marginLeft | | | |
| marginRight | | | |
| marginBottom | | | |
| marginTop | | | |
| marginX | | | |
| marginInline | marginX | | |
| marginInlineStart | | | |
| marginInlineEnd | | | |
| marginY | | | |
| marginBlock | marginY | | |
| marginBlockStart | | | |
| marginBlockEnd | | | |
| height | | | |
| width | | | |
| minWidth | | | |
| maxWidth | | | |
| minHeight | | | |
| maxHeight | | | |
| order | | | |
| alignContent | | | |
| justifyContent | | | |
| alignItems | | | `stretch` |
| alignSelf | | | |
| flex | | | |
| grow | | `flex-grow` | |
| shrink | | `flex-shrink` | |
| basis | | `flex-basis` | |
| direction | | `flex-direction` | `column` |
| wrap | | `flex-wrap` | |

#### Example

```tsx
import { createBox } from 'brandeur-primitives'

const Box = createBox(system)

const App = (
<Box padding={10} gap={4}>
<Box direction="row" gap={2}>
<Box bg="red" width={50} height={50} />
<Box bg="blue" width={50} height={50} />
</Box>
<Box direction="row" gap={2}>
<Box bg="green" width={50} height={50} />
<Box bg="yellow" width={50} height={50} />
</Box>
</Box>
)
```

### createText

### createClick
Expand Down
6 changes: 3 additions & 3 deletions packages/brandeur-primitives/src/components/createBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ export default function createBox({ El, baselineGrid = 1 }) {
alignItems = 'stretch',
alignSelf,
flex,
grow = 0,
shrink = 0,
grow,
shrink,
basis = 'auto',
direction = 'column',
display = 'flex',
wrap = 'nowrap',
wrap,
...props
},
ref
Expand Down

0 comments on commit d5771ee

Please sign in to comment.