-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(presets): add preset and example for bottom left
- Loading branch information
Simon Mollweide
committed
Mar 23, 2018
1 parent
f0f52e1
commit 4b0b1c5
Showing
5 changed files
with
151 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
src/gh-pages/PageExampleBottomLeft/PageExampleBottomLeft.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
// @flow | ||
/* eslint no-alert: 0*/ | ||
import React from 'react'; | ||
import { withStyles } from 'material-ui/styles'; | ||
import Button from 'material-ui/Button'; | ||
import Avatar from 'material-ui/Avatar'; | ||
|
||
import AddIcon from 'material-ui-icons/Add'; | ||
import EditIcon from 'material-ui-icons/Edit'; | ||
import LinkIcon from 'material-ui-icons/Link'; | ||
|
||
import SpeedDial, { SpeedDialItem, SpeedDialLabel, SpeedDialBackdrop } from '../../speed-dial'; | ||
import presetFixedBottomLeft from '../../presets/presetFixedBottomLeft'; | ||
import TemplateExample from '../TemplateExample/TemplateExample'; | ||
|
||
// types | ||
import type { | ||
PresetType, | ||
RenderPropsType, | ||
RenderButtonPropsType, | ||
RenderButtonIconPropsType, | ||
RenderOpenedButtonPropsType, | ||
RenderOpenedButtonIconPropsType, | ||
RenderOuterRimButtonPropsType, | ||
RenderOuterRimButtonIconPropsType, | ||
RenderListPropsType, | ||
RenderAvatarPropsType, | ||
RenderLabelPropsType, | ||
RenderBackdropPropsType, | ||
} from '../../../material-ui-speed-dial.js.flow'; | ||
|
||
export type PageExampleBottomLeftPropsType = { | ||
classes: PresetType, | ||
}; | ||
|
||
const PageExampleBottomLeft = ({ classes }: PageExampleBottomLeftPropsType) => { | ||
return ( | ||
<TemplateExample | ||
title="Bottom left example" | ||
hrefCode="https://github.com/smollweide/material-ui-speed-dial/blob/master/src/gh-pages/PageExampleBottomLeft/PageExampleBottomLeft.js" | ||
> | ||
<SpeedDial | ||
preset={classes} | ||
renderButton={(props: RenderButtonPropsType, propsIcon: RenderButtonIconPropsType) => ( | ||
<Button {...props} variant="fab" color="secondary" aria-label="add"> | ||
<AddIcon {...propsIcon} /> | ||
</Button> | ||
)} | ||
renderOpenedButton={( | ||
props: RenderOpenedButtonPropsType, | ||
propsIcon: RenderOpenedButtonIconPropsType | ||
) => ( | ||
<Button {...props} onClick={() => alert('edit')} variant="fab" color="secondary" aria-label="edit"> | ||
<EditIcon {...propsIcon} /> | ||
</Button> | ||
)} | ||
renderOuterRimButton={( | ||
props: RenderOuterRimButtonPropsType, | ||
propsIcon: RenderOuterRimButtonIconPropsType | ||
) => ( | ||
<Button {...props} mini variant="fab" color="primary" aria-label="add-link"> | ||
<LinkIcon {...propsIcon} /> | ||
</Button> | ||
)} | ||
renderList={(props: RenderListPropsType) => <ul {...props} />} | ||
renderBackdrop={(props: RenderBackdropPropsType) => <SpeedDialBackdrop {...props} />} | ||
> | ||
{(props: RenderPropsType): Array<React$Element<*>> => [ | ||
<SpeedDialItem | ||
{...props} | ||
key="c" | ||
renderAvatar={(propsAvatar: RenderAvatarPropsType) => <Avatar {...propsAvatar}>C</Avatar>} | ||
> | ||
{(propsLabel: RenderLabelPropsType) => <SpeedDialLabel {...propsLabel} text="Eric Hoffman" />} | ||
</SpeedDialItem>, | ||
<SpeedDialItem | ||
{...props} | ||
key="b" | ||
renderAvatar={(propsAvatar: RenderAvatarPropsType) => <Avatar {...propsAvatar}>B</Avatar>} | ||
> | ||
{(propsLabel: RenderLabelPropsType) => <SpeedDialLabel {...propsLabel} text="Grace Ng" />} | ||
</SpeedDialItem>, | ||
<SpeedDialItem {...{ ...props, className: `${props.className} ${classes.firstItem}` }} key="a"> | ||
{(propsLabel: RenderLabelPropsType) => <SpeedDialLabel {...propsLabel} text="Edit" />} | ||
</SpeedDialItem>, | ||
]} | ||
</SpeedDial> | ||
</TemplateExample> | ||
); | ||
}; | ||
PageExampleBottomLeft.displayName = 'PageExampleBottomLeft'; | ||
|
||
export default withStyles(presetFixedBottomLeft)(PageExampleBottomLeft); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// @flow | ||
|
||
import type { PresetRawType } from '../../material-ui-speed-dial.js.flow'; | ||
import type { ThemeType } from '../types/styles'; | ||
|
||
const styles = (theme: ThemeType): PresetRawType => { | ||
return { | ||
root: { | ||
position: 'fixed', | ||
bottom: 0, | ||
left: 0, | ||
zIndex: theme.zIndex.appBar + 2, | ||
}, | ||
button: { | ||
position: 'absolute', | ||
bottom: theme.spacing.unit * 2, | ||
left: theme.spacing.unit * 2, | ||
}, | ||
buttonOuterRim: { | ||
position: 'absolute', | ||
bottom: theme.spacing.unit * 10.8, | ||
left: theme.spacing.unit * 3, | ||
}, | ||
list: { | ||
bottom: theme.spacing.unit * 2.5, | ||
left: 0, | ||
}, | ||
item: { | ||
textAlign: 'left', | ||
}, | ||
firstItem: { | ||
paddingTop: theme.spacing.unit, | ||
}, | ||
avatar: { | ||
top: theme.spacing.unit * 0.7, | ||
left: theme.spacing.unit * 3, | ||
}, | ||
label: { | ||
paddingTop: theme.spacing.unit * 0.5, | ||
paddingRight: theme.spacing.unit, | ||
paddingBottom: theme.spacing.unit * 0.5, | ||
paddingLeft: theme.spacing.unit, | ||
marginLeft: theme.spacing.unit * 9, | ||
}, | ||
backdrop: { | ||
bottom: 0, | ||
left: 0, | ||
}, | ||
}; | ||
}; | ||
|
||
export default styles; |