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

Modal component #347

Merged
merged 100 commits into from
Jul 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
100 commits
Select commit Hold shift + click to select a range
f40fbaa
adds Modal files
coostenbrug Jul 2, 2019
240c0d1
adds modal markup and scrolling
coostenbrug Jul 2, 2019
993f232
adjust some height values
coostenbrug Jul 3, 2019
55a4d6b
adds button mapping
coostenbrug Jul 3, 2019
af840d3
adds case where there is no footer
coostenbrug Jul 3, 2019
961ef25
fixes spacing
coostenbrug Jul 3, 2019
d283e95
changes strategy for scrolling/responsive to flex
coostenbrug Jul 3, 2019
ac47ae6
removes set heights on header/footer
coostenbrug Jul 3, 2019
fc07bb8
responsive width
coostenbrug Jul 3, 2019
24de63b
adds case when there is no modal title
coostenbrug Jul 3, 2019
d5418bb
brings in React-Modal
coostenbrug Jul 3, 2019
0ba70ef
removed close on an outside click
coostenbrug Jul 3, 2019
8b7d254
removes DimPage and restyles overlay
coostenbrug Jul 3, 2019
ee39a7d
resets border style
coostenbrug Jul 3, 2019
95233f8
adds close button to the modal component
coostenbrug Jul 4, 2019
9f75fce
adds extra padding when close button is present
coostenbrug Jul 5, 2019
30af414
corrects centering of the modal on the screen
coostenbrug Jul 15, 2019
c58b2d8
allows all button props to be passed in
coostenbrug Jul 15, 2019
976eaa6
changes ButtonSet styling so that margin is applied on the right of b…
coostenbrug Jul 15, 2019
3c7509b
makes Modal component controlled only
coostenbrug Jul 15, 2019
ee62bb1
clears some console errors
coostenbrug Jul 15, 2019
ca97e28
supports Modal.setAppElement
coostenbrug Jul 15, 2019
448b668
fixes media query on modal width
coostenbrug Jul 16, 2019
e3b0909
moved button font override to modal component
coostenbrug Jul 16, 2019
a3f1b6f
makes shouldCloseOnOverlayClick a prop set default to true
coostenbrug Jul 16, 2019
230e0e8
removes requirements on buttons
coostenbrug Jul 16, 2019
1b12d1f
adds controlled Modal example with Form
coostenbrug Jul 17, 2019
4313868
setups up ButtonSet files
coostenbrug Jul 17, 2019
2ff9b5b
sets up ButtonSet stories
coostenbrug Jul 17, 2019
541d048
corrects button gutters on ButtonSet
coostenbrug Jul 17, 2019
20ed557
updates Modal to use ButtonSet and renames center to spaced on ButtonSet
coostenbrug Jul 17, 2019
23608b6
reorders modal buttons depending on alignment
coostenbrug Jul 17, 2019
436cef2
refactors button ordering code
coostenbrug Jul 17, 2019
cf4f610
adds support to pass in single button as an object and not an array o…
coostenbrug Jul 17, 2019
be86993
renames primaryButtons to primaryButton and only accepts 1 button
coostenbrug Jul 17, 2019
4174f28
cleans up StyledReactModal component
coostenbrug Jul 18, 2019
e76e629
fixes PropTypes for primaryButton and secondaryButtons
coostenbrug Jul 18, 2019
520f3db
small propType change
coostenbrug Jul 18, 2019
1cbfb8e
renames closeFunction to onRequestClose to support React Modal
coostenbrug Jul 18, 2019
251ce5c
fixes prop type
coostenbrug Jul 18, 2019
6f050be
fixes story with close button
coostenbrug Jul 18, 2019
6a7b756
adds aria-label to close button
coostenbrug Jul 18, 2019
d7e5b5e
overlay color change
coostenbrug Jul 19, 2019
07b1b01
restyle dividers to be closer to the edges of the modal
coostenbrug Jul 19, 2019
f122407
eslint fixes
coostenbrug Jul 19, 2019
b26db9a
adds spaceing to buttons when alignment="spaced"
coostenbrug Jul 19, 2019
5c2f841
forces array on secondaryButtons
coostenbrug Jul 22, 2019
001009a
adds ability to modify width
coostenbrug Jul 22, 2019
e08ac49
changes default width value
coostenbrug Jul 22, 2019
b081e7d
changes default wdith
coostenbrug Jul 22, 2019
5a1df4d
conditionally renders header based on title and close button
coostenbrug Jul 22, 2019
7d5bc59
eslintgst
coostenbrug Jul 22, 2019
c9f3b8c
skips setAppElement for modal when running in test env
coostenbrug Jul 23, 2019
d033036
if env is test will not throw console error for missing setAppElement
coostenbrug Jul 23, 2019
ae535e3
storyshots update
coostenbrug Jul 23, 2019
1b016f9
changes button ordering and default button alignment
coostenbrug Jul 23, 2019
4959071
refactor on getModalButtons for readability
coostenbrug Jul 23, 2019
84cc37c
storyshots update
coostenbrug Jul 23, 2019
4e1408c
creates ModalStateWrapper for docs
coostenbrug Jul 24, 2019
9ee5fc8
adds zIndex to overlay
coostenbrug Jul 24, 2019
c439b7d
Edits the copy and adds variations
nikola-nulogy Jul 24, 2019
1f8e231
adds util component that prevents scolling of the body on iOS and des…
coostenbrug Jul 24, 2019
570c100
Fixes typo
nikola-nulogy Jul 24, 2019
4252593
Updates copy
nikola-nulogy Jul 24, 2019
211a47f
changes lock body t not support iOS
coostenbrug Jul 24, 2019
f2d26eb
fixes bug in LockBodyScroll;
coostenbrug Jul 24, 2019
79bf6da
adds LockBodyScroll to NavBar
coostenbrug Jul 24, 2019
0b4ee8b
eslint fixes
coostenbrug Jul 25, 2019
bcf34ee
updates Modal story to correctly style Form modals
coostenbrug Jul 25, 2019
c58c909
adds variants code to docs
coostenbrug Jul 25, 2019
60cfd96
removes esc in example as it is handled by react-modal
coostenbrug Jul 25, 2019
334e1a0
adds more props from react-modal to modal
coostenbrug Jul 25, 2019
f5b8bf0
removes props spread from being passed down on Modal
coostenbrug Jul 25, 2019
3a6e3be
completes props table
coostenbrug Jul 25, 2019
fc0c3b7
changes proptypes for className props to default to undefined
coostenbrug Jul 25, 2019
d683b29
updates docs tables to use smaller font and less padding
coostenbrug Jul 25, 2019
2c4b70a
adds appElement props to Modal
coostenbrug Jul 25, 2019
6d8dcfe
applied aria-labelledby automatically to modal
coostenbrug Jul 25, 2019
797be30
adds accessibility to docs
coostenbrug Jul 25, 2019
d3b9b94
fixes missing import
coostenbrug Jul 25, 2019
7d592b5
adds missing spaces to the Box page
coostenbrug Jul 25, 2019
59911d8
adds related components section to docs
coostenbrug Jul 26, 2019
1cbcd25
updates changelog
coostenbrug Jul 26, 2019
b03db1a
eslint
coostenbrug Jul 26, 2019
c7d1ab7
storyshots update
coostenbrug Jul 26, 2019
fd6ce67
eslint docs
coostenbrug Jul 26, 2019
b472745
adds a default viewport to story with wrapping buttons
coostenbrug Jul 29, 2019
9071694
renames LockBodyScroll to PreventBodyElementScrolling
coostenbrug Jul 29, 2019
93362bc
saves overflow x and y on body
coostenbrug Jul 29, 2019
9056c3d
update docs to add Closing the Modal section and more asseccability
coostenbrug Jul 29, 2019
1f06d49
adds note about ie11 support
coostenbrug Jul 29, 2019
c4ad387
fixes some docs console errors
coostenbrug Jul 29, 2019
c080382
solves storybook deploy bug where results of functions were being cac…
coostenbrug Jul 29, 2019
99ec40c
eslint components
coostenbrug Jul 29, 2019
e5eaf26
docs spelling+grammar
coostenbrug Jul 29, 2019
6cd7434
storyshots update
coostenbrug Jul 29, 2019
2e5ab6a
replaces all instances of React.Fragment with the empty syntax
coostenbrug Jul 31, 2019
06d07cd
removes unneeded import in NavBar docs
coostenbrug Jul 31, 2019
a0696e4
removes InnerModalContent
coostenbrug Jul 31, 2019
f7ab1a4
storyshots spec update
coostenbrug Jul 31, 2019
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Added

- Added Accessibility tab to storybook
- Added [Modal](https://nulogy.design/components/modal/) component

### Changed

Expand Down
1 change: 1 addition & 0 deletions components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
"@storybook/theming": "^5.0.11",
"downshift": "3.2.2",
"polished": "3.0.0",
"react-modal": "^3.8.2",
"react-popper": "^1.3.3",
"styled-components": "^4.1.3",
"styled-system": "^3.2.1",
Expand Down
83,926 changes: 58,519 additions & 25,407 deletions components/spec/__snapshots__/Storyshots.spec.js.snap

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions components/src/Button/Button.story.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@ storiesOf("Buttons", module)
.add("DangerButton", () => <DangerButton>Delete project</DangerButton>)
.add("QuietButton", () => <QuietButton>Create project</QuietButton>)
.add("With a selected size", () => (
<React.Fragment>
<>
<Button size="small">Create project</Button>
<Button size="medium">Create project</Button>
<Button size="large">Create project</Button>
</React.Fragment>
</>
))
.add("With a selected Icon", () => (
<React.Fragment>
<>
<Button icon="add" iconSide="left">
Create project
</Button>
<Button icon="add" iconSide="right">
Create project
</Button>
</React.Fragment>
</>
))
.add("Set to full width", () => <PrimaryButton fullWidth>Create project</PrimaryButton>)
.add("Set to disabled", () => <PrimaryButton disabled>Create project</PrimaryButton>)
Expand Down
56 changes: 56 additions & 0 deletions components/src/Button/CloseButton.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import React from "react";
import styled from "styled-components";
import { Icon } from "../Icon";
import theme from "../theme";

const WrapperButton = styled.button(({ disabled }) => ({
background: "transparent",
border: "none",
position: "relative",
display: "inline-flex",
alignItems: "center",
padding: 0,
color: theme.colors.black,
cursor: disabled ? "arrow" : "pointer",

[`${Icon}`]: {
borderRadius: theme.radii.circle,
transition: ".2s"
},
"&:hover": {
[`${Icon}`]: {
backgroundColor: theme.colors.lightGrey
}
},
"&:active": {
[`${Icon}`]: {
transform: "scale(0.875)",
transition: ".2s ease-in"
}
},
"&:disabled": {
opacity: ".5",
"&:hover, &:active": {
[`${Icon}`]: {
background: "none",
transform: "none"
}
}
},
"&:focus": {
outline: "none",
[`${Icon}`]: {
boxShadow: theme.shadows.focus
}
}
}));

const BaseCloseButton = React.forwardRef(({ ...props }, ref) => (
<WrapperButton aria-label="close" ref={ref} label="close" {...props}>
<Icon size={theme.space.x4} icon="close" p="half" />
</WrapperButton>
));

const CloseButton = styled(BaseCloseButton)({});

export default CloseButton;
4 changes: 2 additions & 2 deletions components/src/Button/IconicButton.story.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ storiesOf("IconicButton", module)
<IconicButton icon="user">I am an Iconic Button with a really really really long label</IconicButton>
))
.add("set to disabled", () => (
<React.Fragment>
<>
<IconicButton icon="cancel" disabled>
Cancel
</IconicButton>
<IconicButton icon="lock" disabled>
Lock
</IconicButton>
</React.Fragment>
</>
))
.add("with a hidden label", () => (
<IconicButton ml="x6" labelHidden icon="user">
Expand Down
1 change: 1 addition & 0 deletions components/src/Button/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ export { default as PrimaryButton } from "./PrimaryButton";
export { default as DangerButton } from "./DangerButton";
export { default as QuietButton } from "./QuietButton";
export { default as IconicButton } from "./IconicButton";
export { default as CloseButton } from "./CloseButton";
52 changes: 52 additions & 0 deletions components/src/ButtonSet/ButtonSet.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import PropTypes from "prop-types";
import styled from "styled-components";
import theme from "../theme";

const alignments = {
left: "flex-start",
spaced: "space-between",
right: "flex-end"
};

const buttonSpacings = {
left: {
"button:not(:last-child)": {
marginRight: theme.space.x1
}
},
spaced: {
"button:not(:last-child)": {
marginRight: theme.space.x1
}
},
right: {
"button:not(:first-child)": {
marginLeft: theme.space.x1
}
}
};

const getAlignment = alignment => alignments[alignment] || alignments.right;

const getButtonSpacing = alignment => buttonSpacings[alignment] || buttonSpacings.right;

const ButtonSet = styled.div(({ alignment }) => ({
display: "flex",
flexWrap: "wrap",
marginBottom: `-${theme.space.x1}`,
justifyContent: getAlignment(alignment),
button: {
marginBottom: theme.space.x1
},
...getButtonSpacing(alignment)
}));

ButtonSet.propTypes = {
alignment: PropTypes.oneOf(["left", "spaced", "right"])
};

ButtonSet.defaultProps = {
alignment: "right"
};

export default ButtonSet;
79 changes: 79 additions & 0 deletions components/src/ButtonSet/ButtonSet.story.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import React from "react";
import { storiesOf } from "@storybook/react";
import { Box, ButtonSet, Button, PrimaryButton, DangerButton, QuietButton, IconicButton } from "../index";

storiesOf("ButtonSet", module)
.add("ButtonSet", () => (
<Box bg="whiteGrey" p="x2" width="500px">
<ButtonSet>
<Button>Button</Button>
<Button>Button</Button>
<PrimaryButton>Button</PrimaryButton>
</ButtonSet>
</Box>
))
.add("with alignment left", () => (
<Box bg="whiteGrey" p="x2" width="500px">
<ButtonSet alignment="left">
<PrimaryButton>Button</PrimaryButton>
<Button>Button</Button>
<Button>Button</Button>
</ButtonSet>
</Box>
))
.add("with alignment spaced", () => (
<Box bg="whiteGrey" p="x2" width="500px">
<ButtonSet alignment="spaced">
<Button>Button</Button>
<PrimaryButton>Button</PrimaryButton>
</ButtonSet>
</Box>
))
.add("more button types", () => (
<Box bg="whiteGrey" p="x2" width="600px">
<ButtonSet>
<Button>Button</Button>
<PrimaryButton>Button</PrimaryButton>
<DangerButton>Button</DangerButton>
<QuietButton>Button</QuietButton>
<IconicButton icon="menu" />
<IconicButton icon="menu">Button</IconicButton>
</ButtonSet>
</Box>
))
.add(
"wrapping buttons",
() => (
<>
<Box bg="whiteGrey" p="x2">
<ButtonSet>
<Button>Button</Button>
<Button>Button</Button>
<Button>Button</Button>
<Button>Button</Button>
<Button>Button</Button>
<Button>Button</Button>
<Button>Button</Button>
<Button>Button</Button>
<Button>Button</Button>
<Button>Button</Button>
</ButtonSet>
</Box>
<Box bg="whiteGrey" p="x2" mt="x2">
<ButtonSet alignment="left">
<Button>Button</Button>
<Button>Button</Button>
<Button>Button</Button>
<Button>Button</Button>
<Button>Button</Button>
<Button>Button</Button>
<Button>Button</Button>
<Button>Button</Button>
<Button>Button</Button>
<Button>Button</Button>
</ButtonSet>
</Box>
</>
),
{ viewport: { defaultViewport: "extraSmall" } }
);
1 change: 1 addition & 0 deletions components/src/ButtonSet/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as ButtonSet } from "./ButtonSet";
4 changes: 2 additions & 2 deletions components/src/Icon/Icon.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ const iconNames = Object.keys(icons);

/* eslint-disable react/no-array-index-key */
const getPathElements = icon => (
<React.Fragment>
<>
{icon.path.map((path, index) => (
<path key={index} d={path} />
))}
</React.Fragment>
</>
);
/* eslint-enable react/no-array-index-key */

Expand Down
20 changes: 10 additions & 10 deletions components/src/Icon/Icon.story.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ IconCode.propTypes = {

storiesOf("Icon", module)
.add("Icon", () => (
<React.Fragment>
<>
{iconNames.map(iconName => (
<Flex my="x2" key={iconName}>
<Icon mr="20px" icon={iconName} />
<IconCode icon={iconName} />
</Flex>
))}
</React.Fragment>
</>
))
.add("InlineIcon", () => (
<React.Fragment>
<>
{[1, 2, 3, 4].map(size => (
<p style={{ fontSize: `${size}em` }} key={size}>
@{size}em: &nbsp;
Expand All @@ -41,10 +41,10 @@ storiesOf("Icon", module)
))}
</p>
))}
</React.Fragment>
</>
))
.add("With a color", () => (
<React.Fragment>
<>
{[theme.colors.red, theme.colors.yellow, theme.colors.green, theme.colors.blue, theme.colors.blackBlue].map(
color => (
<Box key={color}>
Expand All @@ -54,18 +54,18 @@ storiesOf("Icon", module)
</Box>
)
)}
</React.Fragment>
</>
))
.add("With a size", () => (
<React.Fragment>
<>
{[theme.space.x1, theme.space.x2, theme.space.x3].map(size => (
<Box key={size}>
{iconSubset.map(iconName => (
<Icon icon={iconName} size={size} key={iconName} />
))}
</Box>
))}
</React.Fragment>
</>
))
.add("With added margin", () => (
<Box m="x3">
Expand Down Expand Up @@ -93,7 +93,7 @@ storiesOf("Icon", module)
</Box>
))
.add("With accessibility title", () => (
<React.Fragment>
<>
<Flex p="x2">
<Icon icon="user" title="User account" />
{" This has a title attribute so it will be read by assistive devices."}
Expand All @@ -102,5 +102,5 @@ storiesOf("Icon", module)
<Icon icon="user" />
{" This doesn't have a title attribute, so it has aria-hidden set true instead."}
</Flex>
</React.Fragment>
</>
));
Loading