Skip to content
This repository was archived by the owner on Mar 31, 2021. It is now read-only.

Commit

Permalink
Add Pane component
Browse files Browse the repository at this point in the history
  • Loading branch information
jxom committed Nov 15, 2018
1 parent e383db1 commit 7b007fc
Show file tree
Hide file tree
Showing 7 changed files with 132 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/Pane/Pane.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// @flow
import React, { type Node } from 'react';

import _Pane from './styled';

type Props = {
border: boolean | 'shadow',
className?: string,
children?: Node,
isFullWidth?: boolean
};

const Pane = ({ children, ...props }: Props) => <_Pane {...props}>{children}</_Pane>;

Pane.defaultProps = {
className: undefined,
children: undefined,
isFullWidth: false
};

export default Pane;
58 changes: 58 additions & 0 deletions src/Pane/Pane.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
name: Pane
route: /layout/pane
menu: Layout
---

import { Playground, PropsTable } from 'docz';
import Pane from '../Pane';

# Pane

## Import

`import { Pane } from 'fannypack'`

## Basic Usage

A `<Pane>` is the same as a `<Box>`, except it has a default border radius, and has the ability to add different types of borders to it. Using `<Pane>` and `<Box>` together are most likely the two building blocks for the layout of your app.

<Playground>
<Pane backgroundColor="whiteDarker" padding="large">Hello world</Pane>
</Playground>

## Shadowed

<Playground>
<Pane border="shadow" padding="large">Hello world</Pane>
</Playground>

## Bordered

<Playground>
<Pane border padding="large">Hello world</Pane>
</Playground>

## Full width

<Playground>
<Pane border isFullWidth padding="large">Hello world</Pane>
</Playground>

## Props

<PropsTable of={Pane} />

## Theming

### Schema

```jsx
{
base: string | Object,
border: {
default: string | Object,
shadow: string | Object
}
}
```
2 changes: 2 additions & 0 deletions src/Pane/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { default } from './Pane';
export { default as Pane } from './Pane';
40 changes: 40 additions & 0 deletions src/Pane/styled.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { palette, theme } from 'styled-tools';
import styled, { css } from '../styled';
import { Box } from '../primitives';

const Pane = styled(Box)`
display: inline-flex;
border-radius: 3px;
flex-wrap: wrap;
${props =>
props.border === 'shadow' &&
css`
box-shadow: 0px 2px 4px 0px ${palette('whiteDarkest')}, 0px 0px 0px 1px ${palette('whiteDarkest')};
& {
${theme('fannypack.Pane.border.shadow')};
}
`};
${props =>
props.border === true &&
css`
border: 1px solid ${palette('whiteDarkest')};
& {
${theme('fannypack.Pane.border.default')};
}
`};
${props =>
props.isFullWidth &&
css`
width: 100%;
margin-right: 0px !important;
`};
& {
${theme('fannypack.Pane.base')};
}
`;

export default Pane;
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export { Label } from './Label';
export { Link } from './Link';
export { List, ListItem } from './List';
export { Navigation } from './Navigation';
export { Pane } from './Pane';
export { Paragraph } from './Paragraph';
export { Radio, RadioGroup, RadioGroupField } from './Radio';
export { Rating, RatingStar } from './Rating';
Expand Down
2 changes: 2 additions & 0 deletions src/themes/themes.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ const App = () => (
Label: LabelThemeConfig,
Link: LinkThemeConfig,
List: ListThemeConfig,
Pane: PaneThemeConfig,
Paragraph: ParagraphThemeConfig,
Radio: RadioThemeConfig,
RadioGroup: RadioGroupThemeConfig
Expand Down Expand Up @@ -217,6 +218,7 @@ Components:
- [LabelThemeConfig](/form/label#theming)
- [LinkThemeConfig](/typography/link#theming)
- [ListThemeConfig](/typography/list#theming)
- [PaneThemeConfig](/layout/pane#theming)
- [ParagraphThemeConfig](/typography/paragraph#theming)
- [RadioThemeConfig](/form/radio#theming)
- [RadioGroupThemeConfig](/form/radiogroup#theming)
Expand Down
8 changes: 8 additions & 0 deletions src/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,13 @@ export type ListThemeConfig = {
export type NavigationThemeConfig = {
base?: Stylesheet
};
export type PaneThemeConfig = {
base?: Stylesheet,
border?: {
default?: Stylesheet,
shadow?: Stylesheet
}
};
export type ParagraphThemeConfig = {
base?: Stylesheet
};
Expand Down Expand Up @@ -285,6 +292,7 @@ export type ThemeConfig = {
Link?: LinkThemeConfig,
List?: ListThemeConfig,
Navigation?: NavigationThemeConfig,
Pane?: PaneThemeConfig,
Paragraph?: ParagraphThemeConfig,
Radio?: RadioThemeConfig,
RadioGroup?: RadioGroupThemeConfig,
Expand Down

0 comments on commit 7b007fc

Please sign in to comment.