Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(docs): Box primitive #1161

Merged
merged 22 commits into from
Jul 12, 2021
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
864549d
adjust folder structure as in navigation and add link to installation…
viktoria-schwarz Jun 29, 2021
241266f
add installation guide
viktoria-schwarz Jun 29, 2021
043dc72
add icons installation hint to iconography
viktoria-schwarz Jun 29, 2021
52a7310
make use of <Text> component for consistency
viktoria-schwarz Jun 29, 2021
b5ce4f7
add and link usestyles, rename theming
viktoria-schwarz Jun 29, 2021
b6df5a1
Create lazy-candles-invite.md
viktoria-schwarz Jun 29, 2021
d29a6f8
Merge branch 'main' of marigold into docs-guides
viktoria-schwarz Jul 5, 2021
05d7794
minor changes
viktoria-schwarz Jul 5, 2021
bd4f7e9
Merge branch 'docs-guides' of github.com:marigold-ui/marigold into do…
viktoria-schwarz Jul 5, 2021
eadf648
merge
viktoria-schwarz Jul 5, 2021
241fa55
rename file
viktoria-schwarz Jul 5, 2021
bb5f5e6
Merge branch 'docs-guides' into docs-boxprimitive
viktoria-schwarz Jul 5, 2021
85da6c5
add box primitive
viktoria-schwarz Jul 5, 2021
ab3626c
Merge branch 'main' of github.com:marigold-ui/marigold into docs-boxp…
viktoria-schwarz Jul 5, 2021
b574205
Merge 'main' of marigold into docs-boxprimitive
viktoria-schwarz Jul 5, 2021
b6a6f91
add section Custom CSS
viktoria-schwarz Jul 5, 2021
ae9a18e
Create curly-snakes-relate.md
viktoria-schwarz Jul 5, 2021
729f2f8
minor changes
viktoria-schwarz Jul 5, 2021
fb800fc
minor changes
viktoria-schwarz Jul 6, 2021
43a1d26
clean Logo
viktoria-schwarz Jul 12, 2021
fb5ad48
fix layout
viktoria-schwarz Jul 12, 2021
c15cec0
nothing
viktoria-schwarz Jul 12, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/curly-snakes-relate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"docs": patch
---

feat(docs): add documentation for Box primitive
44 changes: 43 additions & 1 deletion docs/content/components/box.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,49 @@
title: Box
---

# Box-Component
# Box

viktoria-schwarz marked this conversation as resolved.
Show resolved Hide resolved
## Properties

| Property | Type | Default |
| :-------------------------- | :------------------------------------ | :------ |
| `as` (optional) | `HTMLElement` | `div` |
| `display` (optional) | `ResponsiveStyleValue<string>` | |
| `height` (optional) | `ResponsiveStyleValue<number⎮string>` | |
| `width` (optional) | `ResponsiveStyleValue<number⎮string>` | |
| `minWidth` (optional) | `ResponsiveStyleValue<number⎮string>` | |
| `maxWidth` (optional) | `ResponsiveStyleValue<number⎮string>` | |
| `position` (optional) | `ResponsiveStyleValue<string>` | |
| `top` (optional) | `ResponsiveStyleValue<number⎮string>` | |
| `bottom` (optional) | `ResponsiveStyleValue<number⎮string>` | |
| `right` (optional) | `ResponsiveStyleValue<number⎮string>` | |
| `left` (optional) | `ResponsiveStyleValue<number⎮string>` | |
| `zIndex` (optional) | `ResponsiveStyleValue<number⎮string>` | |
| `p` (optional) | `ResponsiveStyleValue<number⎮string>` | |
| `px` (optional) | `ResponsiveStyleValue<number⎮string>` | |
| `py` (optional) | `ResponsiveStyleValue<number⎮string>` | |
| `pt` (optional) | `ResponsiveStyleValue<number⎮string>` | |
| `pb` (optional) | `ResponsiveStyleValue<number⎮string>` | |
| `pl` (optional) | `ResponsiveStyleValue<number⎮string>` | |
| `pr` (optional) | `ResponsiveStyleValue<number⎮string>` | |
| `m` (optional) | `ResponsiveStyleValue<number⎮string>` | |
| `mx` (optional) | `ResponsiveStyleValue<number⎮string>` | |
| `my` (optional) | `ResponsiveStyleValue<number⎮string>` | |
| `ml` (optional) | `ResponsiveStyleValue<number⎮string>` | |
| `mr` (optional) | `ResponsiveStyleValue<number⎮string>` | |
| `flexDirection` (optional) | `ResponsiveStyleValue<string>` | |
| `flexWrap` (optional) | `ResponsiveStyleValue<string>` | |
| `flexShrink` (optional) | `ResponsiveStyleValue<number⎮string>` | |
| `flexGrow` (optional) | `ResponsiveStyleValue<number⎮string>` | |
| `alignItems` (optional) | `ResponsiveStyleValue<string>` | |
| `justifyContent` (optional) | `ResponsiveStyleValue<string>` | |
| `bg` (optional) | `ResponsiveStyleValue<number⎮string>` | |
| `border` (optional) | `ResponsiveStyleValue<number⎮string>` | |
| `borderRadius` (optional) | `ResponsiveStyleValue<number⎮string>` | |
| `boxShadow` (optional) | `ResponsiveStyleValue<number⎮string>` | |
| `opacity` (optional) | `ResponsiveStyleValue<number⎮string>` | |
| `overflow` (optional) | `ResponsiveStyleValue<string>` | |
| `transition` (optional) | `ResponsiveStyleValue<number⎮string>` | |

## Import

Expand Down
10 changes: 5 additions & 5 deletions docs/content/components/link.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ Element to style links.

## Properties

| Property | Type | Default |
| :-------------------- | :-------------------- | :------ |
| `as` (optional) | string \| `Component` | `a` |
| `variant` (optional) | string \| string[] | `link` |
| `disabled` (optional) | boolean | |
| Property | Type | Default |
| :-------------------- | :------------------- | :------ |
| `as` (optional) | `string Component` | `a` |
| `variant` (optional) | `string string[]` | `link` |
| `disabled` (optional) | boolean | |

## Import

Expand Down
8 changes: 4 additions & 4 deletions docs/content/components/stack.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ Layout component to stack elements. This component uses the spaces from the give

## Properties

| Property | Type | Default |
| :------- | :--------------------------------------------- | :------ |
| `space` | `ResponsiveStyleValue<number `&#124;` string>` | `0` |
| `align` | `left, right, center` | `left` |
| Property | Type | Default |
| :------- | :------------------------------------ | :------ |
| `space` | `ResponsiveStyleValue<numberstring>` | `0` |
| `align` | `left, right, center` | `left` |

## Import

Expand Down
18 changes: 9 additions & 9 deletions docs/content/components/text.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ By adding the `as` prop you can alternatively render a `p` element.

## Properties

| Property | Type | Default |
| :---------------------- | :-------------------- | :------ |
| `as` (optional) | string \| `Component` | `span` |
| `variant` (optional) | string \| string[] | `body` |
| `align` (optional) | string | |
| `color` (optional) | string | |
| `cursor` (optional) | string | |
| `outline` (optional) | string | |
| `userSelect` (optional) | string | |
| Property | Type | Default |
| :---------------------- | :------------------- | :------ |
| `as` (optional) | `string Component` | `span` |
| `variant` (optional) | `string string[]` | `body` |
| `align` (optional) | `string` | |
| `color` (optional) | `string` | |
| `cursor` (optional) | `string` | |
| `outline` (optional) | `string` | |
| `userSelect` (optional) | `string` | |

## Import

Expand Down
75 changes: 75 additions & 0 deletions docs/content/foundation/box-primitive.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
---
title: Box Primitive
---

import Link from 'gatsby-link';
import { useStyles } from '@marigold/system';

# Box Primitive

## Box as Layout Component

As the basis of all our components, we use the `<Box>`. It is a versatile layout component that
can be modified with layout props as listed in the <Link to="../../components/box">Box component</Link> description.
Additionally, use the `variant` prop to define custom styles in your themes. With the `as` prop, you
determine the rendered HTML element. Instead of exposing the underlying tools that will create CSS, the `<Box>` component
wraps them and exposes an API for applying styling to a component while respecting the rules and constraints of our design
system.

```tsx code
import { Box } from '@marigold/components';
import { useStyles } from '@marigold/system';
```

```tsx live
<Box as="button" bg="orange" p="8px">
Button box with backgroundcolor and padding!
</Box>
```

## Building a custom Component with the Box

In case you want to build your own custom component, use the `Box` as the underlying layout component and add
the styles accordingly. You can stack and nest multiple Box instances and build your complex component like this.
By default, the `Box` component will render a `<div />`. This might be fine most of the times, but sometimes you would
rather render a `<button>` or an `<input>` etc. To allow this, the `Box` takes the special prop called `as`, accepting
all HTML tag names as input. Don't forget to define variants in your theme.

```tsx code
export type ButtonProps = {
variant?: string;
} & ComponentPropsWithRef<'button'>;

export const Button: React.FC<ButtonProps> = ({
variant = 'primary.large',
children,
...props
}) => {
return (
<Box as="button" {...props} variant={`button.${variant}`}>
<Box as="span" display="inline-flex" alignItems="center">
{children}
</Box>
</Box>
);
};
```

## Custom CSS

Staying inside the boundaries of the design system and its contraints should be the norm. But as limiting styling only
to allowed values defined by the system can be very restrictive, you can use the `className` prop and generate custom
styles with the <Link to="../../guides/usestyles">`useStyles` hook</Link>.
viktoria-schwarz marked this conversation as resolved.
Show resolved Hide resolved

```tsx code
...
<Box
as="button"
className={useStyles({ css: { fontSize: '11pt' } })}
{...props}
variant={`button.${variant}`}
>
...
</Box>
...
```
4 changes: 2 additions & 2 deletions docs/content/foundation/themes-variants.mdx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
title: Theming
title: Theme & Variants
---

import Link from 'gatsby-link';

# Theming
# Theme & Variants

Marigold uses a theme for its base styles.

Expand Down
6 changes: 4 additions & 2 deletions docs/content/guides/installation.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
---
title: Installation
title: Getting Started
---

import Link from 'gatsby-link';

# Getting Started

## Installation
Expand All @@ -21,7 +23,7 @@ Add the package `@marigold/icons` if you want to use icons in Marigold.
## Usage

Marigold components don't come with a theme by default. In order to add a theme to your application, use the `ThemeProvider`
component and thereby provide a theme in context. You can use one of the following themes: <Link to="themes/b2b">B2B Theme</Link> or <Link to="themes/unicorn">Unicorn Theme</Link>.
component and thereby provide a theme in context. You can use one of the following themes: <Link to="../../themes/b2b">B2B theme</Link> or <Link to="../../themes/unicorn">Unicorn theme</Link>.

```bash code
# with npm
Expand Down
10 changes: 8 additions & 2 deletions docs/src/components/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Link } from './Link';
import { Logo } from './Logo';
import { Navigation } from './Navigation';
import { ThemeSelect } from './ThemeSelect';
import { useStyles } from 'packages/system/src/useStyles';

export const Layout: React.FC = ({ children }) => {
return (
Expand All @@ -19,7 +20,12 @@ export const Layout: React.FC = ({ children }) => {
<title>Marigold Design System</title>
</Helmet>
<Columns space={8}>
<Column width={2}>
<Column
viktoria-schwarz marked this conversation as resolved.
Show resolved Hide resolved
width={3}
className={useStyles({
css: { position: 'fixed', top: 0, left: 0, overflowX: 'hidden', height: '100%' },
})}
>
<Stack space={16}>
<Link to="/">
<Logo />
Expand All @@ -28,7 +34,7 @@ export const Layout: React.FC = ({ children }) => {
<Navigation />
</Stack>
</Column>
<Column width={10}>{children}</Column>
<Column width={9}>{children}</Column>
</Columns>
</>
);
Expand Down
2 changes: 1 addition & 1 deletion docs/src/components/Logo/Logo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ import React from 'react';
import { StaticImage } from 'gatsby-plugin-image';

export const Logo: React.FC = () => (
<StaticImage src="./logo.png" alt="Marigold Logo" />
<StaticImage src="./logo.png" alt="Marigold Logo" width={180} />
viktoria-schwarz marked this conversation as resolved.
Show resolved Hide resolved
);
2 changes: 1 addition & 1 deletion docs/src/components/Navigation/Navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const NavigationSection = ({ name, children }: NavigationSectionProps) => {

export const Navigation: React.FC = () => {
const tree = useNavigation();
console.log(tree);
// console.log(tree);
viktoria-schwarz marked this conversation as resolved.
Show resolved Hide resolved

return (
<Box
Expand Down