Skip to content

Commit

Permalink
[docs] Separate ButtonGroup and Fab pages from Button
Browse files Browse the repository at this point in the history
  • Loading branch information
mbrookes committed Jan 25, 2020
1 parent 0177cd6 commit 439507a
Show file tree
Hide file tree
Showing 26 changed files with 327 additions and 159 deletions.
14 changes: 14 additions & 0 deletions docs/pages/components/button-group.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from 'react';
import MarkdownDocs from 'docs/src/modules/components/MarkdownDocs';

const req = require.context('docs/src/pages/components/button-group', false, /\.(md|js|tsx)$/);
const reqSource = require.context(
'!raw-loader!../../src/pages/components/button-group',
false,
/\.(js|tsx)$/,
);
const reqPrefix = 'pages/components/button-group';

export default function Page() {
return <MarkdownDocs req={req} reqSource={reqSource} reqPrefix={reqPrefix} />;
}
14 changes: 14 additions & 0 deletions docs/pages/components/floating-action-button.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from 'react';
import MarkdownDocs from 'docs/src/modules/components/MarkdownDocs';

const req = require.context('docs/src/pages/components/floating-action-button', false, /\.(md|js|tsx)$/);
const reqSource = require.context(
'!raw-loader!../../src/pages/components/floating-action-button',
false,
/\.(js|tsx)$/,
);
const reqPrefix = 'pages/components/floating-action-button';

export default function Page() {
return <MarkdownDocs req={req} reqSource={reqSource} reqPrefix={reqPrefix} />;
}
2 changes: 2 additions & 0 deletions docs/src/pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ const pages = [
subheader: '/components/inputs',
children: [
{ pathname: '/components/buttons' },
{ pathname: '/components/button-group' },
{ pathname: '/components/checkboxes' },
{ pathname: '/components/floating-action-button' },
{ pathname: '/components/pickers', title: 'Date / Time' },
{ pathname: '/components/radio-buttons' },
{ pathname: '/components/selects' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const useStyles = makeStyles(theme => ({
},
}));

export default function GroupedButtons() {
export default function BasicButtonGroup() {
const classes = useStyles();

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const useStyles = makeStyles((theme: Theme) =>
}),
);

export default function GroupedButtons() {
export default function BasicButtonGroup() {
const classes = useStyles();

return (
Expand Down
51 changes: 51 additions & 0 deletions docs/src/pages/components/button-group/GroupOrientation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import React from 'react';
import Button from '@material-ui/core/Button';
import ButtonGroup from '@material-ui/core/ButtonGroup';
import { makeStyles } from '@material-ui/core/styles';

const useStyles = makeStyles(theme => ({
root: {
display: 'flex',
'& > *': {
margin: theme.spacing(1),
},
},
}));

export default function GroupOrientation() {
const classes = useStyles();

return (
<div className={classes.root}>
<ButtonGroup
orientation="vertical"
color="primary"
aria-label="vertical outlined primary button group"
>
<Button>One</Button>
<Button>Two</Button>
<Button>Three</Button>
</ButtonGroup>
<ButtonGroup
orientation="vertical"
color="primary"
aria-label="vertical contained primary button group"
variant="contained"
>
<Button>One</Button>
<Button>Two</Button>
<Button>Three</Button>
</ButtonGroup>
<ButtonGroup
orientation="vertical"
color="primary"
aria-label="vertical contained primary button group"
variant="text"
>
<Button>One</Button>
<Button>Two</Button>
<Button>Three</Button>
</ButtonGroup>
</div>
);
}
52 changes: 52 additions & 0 deletions docs/src/pages/components/button-group/GroupOrientation.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import React from 'react';
import Button from '@material-ui/core/Button';
import ButtonGroup from '@material-ui/core/ButtonGroup';
import { makeStyles } from '@material-ui/core/styles';

const useStyles = makeStyles(theme => ({
root: {
display: 'flex',
'& > *': {
margin: theme.spacing(1),
},
},
}));


export default function GroupOrientation() {
const classes = useStyles();

return (
<div className={classes.root}>
<ButtonGroup
orientation="vertical"
color="primary"
aria-label="vertical outlined primary button group"
>
<Button>One</Button>
<Button>Two</Button>
<Button>Three</Button>
</ButtonGroup>
<ButtonGroup
orientation="vertical"
color="primary"
aria-label="vertical contained primary button group"
variant="contained"
>
<Button>One</Button>
<Button>Two</Button>
<Button>Three</Button>
</ButtonGroup>
<ButtonGroup
orientation="vertical"
color="primary"
aria-label="vertical contained primary button group"
variant="text"
>
<Button>One</Button>
<Button>Two</Button>
<Button>Three</Button>
</ButtonGroup>
</div>
);
}
26 changes: 26 additions & 0 deletions docs/src/pages/components/button-group/button-group.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
title: ButtonGroup React component
components: Button, ButtonGroup
---

# Button group

<p class="description">The ButtonGroup component can be used to group related buttons.</p>

## Basic button group

{{"demo": "pages/components/button-group/BasicButtonGroup.js"}}

### Group sizes and colors

{{"demo": "pages/components/button-group/GroupSizesColors.js"}}

### Group orientation

{{"demo": "pages/components/button-group/GroupOrientation.js"}}

### Split Button

ButtonGroup can also be used to create a split button. The dropdown can change the button action (as in this example), or be used to immediately trigger a related action.

{{"demo": "pages/components/button-group/SplitButton.js"}}
43 changes: 3 additions & 40 deletions docs/src/pages/components/buttons/ButtonSizes.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React from 'react';
import { makeStyles } from '@material-ui/core/styles';
import Button from '@material-ui/core/Button';
import Fab from '@material-ui/core/Fab';

import IconButton from '@material-ui/core/IconButton';
import AddIcon from '@material-ui/icons/Add';

import DeleteIcon from '@material-ui/icons/Delete';
import NavigationIcon from '@material-ui/icons/Navigation';

import ArrowDownwardIcon from '@material-ui/icons/ArrowDownward';

const useStyles = makeStyles(theme => ({
Expand Down Expand Up @@ -55,43 +55,6 @@ export default function ButtonSizes() {
Large
</Button>
</div>
<div>
<Fab size="small" color="secondary" aria-label="add" className={classes.margin}>
<AddIcon />
</Fab>
<Fab size="medium" color="secondary" aria-label="add" className={classes.margin}>
<AddIcon />
</Fab>
<Fab color="secondary" aria-label="add" className={classes.margin}>
<AddIcon />
</Fab>
</div>
<div>
<Fab
variant="extended"
size="small"
color="primary"
aria-label="add"
className={classes.margin}
>
<NavigationIcon className={classes.extendedIcon} />
Extended
</Fab>
<Fab
variant="extended"
size="medium"
color="primary"
aria-label="add"
className={classes.margin}
>
<NavigationIcon className={classes.extendedIcon} />
Extended
</Fab>
<Fab variant="extended" color="primary" aria-label="add" className={classes.margin}>
<NavigationIcon className={classes.extendedIcon} />
Extended
</Fab>
</div>
<div>
<IconButton aria-label="delete" className={classes.margin} size="small">
<ArrowDownwardIcon fontSize="inherit" />
Expand Down
37 changes: 0 additions & 37 deletions docs/src/pages/components/buttons/ButtonSizes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,43 +57,6 @@ export default function ButtonSizes() {
Large
</Button>
</div>
<div>
<Fab size="small" color="secondary" aria-label="add" className={classes.margin}>
<AddIcon />
</Fab>
<Fab size="medium" color="secondary" aria-label="add" className={classes.margin}>
<AddIcon />
</Fab>
<Fab color="secondary" aria-label="add" className={classes.margin}>
<AddIcon />
</Fab>
</div>
<div>
<Fab
variant="extended"
size="small"
color="primary"
aria-label="add"
className={classes.margin}
>
<NavigationIcon className={classes.extendedIcon} />
Extended
</Fab>
<Fab
variant="extended"
size="medium"
color="primary"
aria-label="add"
className={classes.margin}
>
<NavigationIcon className={classes.extendedIcon} />
Extended
</Fab>
<Fab variant="extended" color="primary" aria-label="add" className={classes.margin}>
<NavigationIcon className={classes.extendedIcon} />
Extended
</Fab>
</div>
<div>
<IconButton aria-label="delete" className={classes.margin} size="small">
<ArrowDownwardIcon fontSize="inherit" />
Expand Down
17 changes: 0 additions & 17 deletions docs/src/pages/components/buttons/GroupOrientation.js

This file was deleted.

17 changes: 0 additions & 17 deletions docs/src/pages/components/buttons/GroupOrientation.tsx

This file was deleted.

48 changes: 2 additions & 46 deletions docs/src/pages/components/buttons/buttons.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Button React component
components: Button, ButtonGroup, Fab, IconButton, ButtonBase, Zoom
components: Button, IconButton, ButtonBase
---

# Button
Expand Down Expand Up @@ -52,50 +52,6 @@ or a higher emphasis alternative to text buttons.

{{"demo": "pages/components/buttons/OutlinedButtons.js"}}

## Grouped Buttons

The `ButtonGroup` component can be used to group buttons.

{{"demo": "pages/components/buttons/GroupedButtons.js"}}

### Group sizes and colors

{{"demo": "pages/components/buttons/GroupSizesColors.js"}}

### Group orientation

{{"demo": "pages/components/buttons/GroupOrientation.js"}}

### Split Button

ButtonGroup can also be used to create a split button. The dropdown can change the button action (as in this example), or be used to immediately trigger a related action.

{{"demo": "pages/components/buttons/SplitButton.js"}}

## Floating Action Buttons

A [floating action button](https://material.io/design/components/buttons-floating-action-button.html)
(FAB) performs the primary, or most common, action on a screen.
It appears in front of all screen content, typically as a circular shape with an icon in its center.
FABs come in two types: regular, and extended.

Only use a FAB if it is the most suitable way to present a screen’s primary action.

Only one floating action button is recommended per screen to represent the most common action.

{{"demo": "pages/components/buttons/FloatingActionButtons.js"}}

The floating action button animates onto the screen as an expanding piece of material, by default.

A floating action button that spans multiple lateral screens (such as tabbed screens) should briefly disappear,
then reappear if its action changes.

The Zoom transition can be used to achieve this. Note that since both the exiting and entering
animations are triggered at the same time, we use `enterDelay` to allow the outgoing Floating Action Button's
animation to finish before the new one enters.

{{"demo": "pages/components/buttons/FloatingActionButtonZoom.js", "bg": true}}

## Upload button

{{"demo": "pages/components/buttons/UploadButtons.js"}}
Expand Down Expand Up @@ -135,7 +91,7 @@ Here are some examples of customizing the component. You can learn more about th
The Text Buttons, Contained Buttons, Floating Action Buttons and Icon Buttons are built on top of the same component: the `ButtonBase`.
You can take advantage of this lower level component to build custom interactions.

{{"demo": "pages/components/buttons/ButtonBases.js"}}
{{"demo": "pages/components/buttons/ButtonBase.js"}}

## Third-party routing library

Expand Down
Loading

0 comments on commit 439507a

Please sign in to comment.