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

Support modal headers with no bottom border #78

Merged
merged 2 commits into from
Nov 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
20 changes: 20 additions & 0 deletions catalog/modal/variations.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,3 +210,23 @@ state: { modal: false, value: '' }
</Modal>
</ModalDemo>
```
## Modal with no title border

```react
showSource: true
state: { modal: false, value: '' }
---
<ModalDemo>
<Button primary medium onClick={() => setState({ modal: !state.modal })}>Open a modal!</Button>
<Modal
isOpen={state.modal}
onClose={() => setState({ modal: false })}
title="Modal with no title border"
styleOverrides={{ bottomBorder: 'none' }}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dustinsoftware, something like this pattern you had in mind?

>
<div className="content">
This modal has no title border!
</div>
</Modal>
</ModalDemo>
```
5 changes: 3 additions & 2 deletions components/modal/modal-header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import PropTypes from 'prop-types';
import { Close } from '../icons';
import * as Styled from './styled.jsx';

export const ModalHeader = ({ title, subtitle, onClose }) => (
<Styled.ModalHeader>
export const ModalHeader = ({ title, subtitle, onClose, styleOverrides }) => (
<Styled.ModalHeader styleOverrides={styleOverrides}>
<Styled.ModalTitleBar>
<Styled.ModalTitle>{title}</Styled.ModalTitle>
<Styled.ModalClose onClick={onClose}>
Expand All @@ -19,4 +19,5 @@ ModalHeader.propTypes = {
title: PropTypes.string.isRequired,
onClose: PropTypes.func.isRequired,
subtitle: PropTypes.string,
styleOverrides: PropTypes.object.isRequired,
};
13 changes: 12 additions & 1 deletion components/modal/modal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ export class Modal extends React.Component {
children: PropTypes.node.isRequired,
/** Customizable theme properties */
theme: PropTypes.object,
/** Style overrides */
styleOverrides: PropTypes.shape({
bottomBorder: PropTypes.string,
}),
/** Values for rendering an FL standard footer */
footerProps: PropTypes.shape({
commitButton: PropTypes.shape({
Expand All @@ -49,6 +53,7 @@ export class Modal extends React.Component {
theme: {
background: 'white',
},
styleOverrides: {},
};

state = {
Expand Down Expand Up @@ -81,6 +86,7 @@ export class Modal extends React.Component {
renderFooter,
footerProps,
withoutFooter,
styleOverrides,
} = this.props;

if (!isOpen) {
Expand All @@ -104,7 +110,12 @@ export class Modal extends React.Component {
if (modal && modalWidth === null) this.setState({ modalWidth: modal.clientWidth });
}}
>
<ModalHeader title={title} subtitle={subtitle} onClose={onClose} />
<ModalHeader
title={title}
subtitle={subtitle}
onClose={onClose}
styleOverrides={styleOverrides}
/>
<Styled.ModalContent> {children} </Styled.ModalContent>
{!withoutFooter &&
(renderFooter ? (
Expand Down
5 changes: 4 additions & 1 deletion components/modal/styled.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ export const ModalHeader = styled.div`
width: 100%;
padding-bottom: ${thickness.twelve};
margin-bottom: ${thickness.twelve};
border-bottom: 1px solid ${colors.borderColor};
${props =>
props.styleOverrides.bottomBorder
? props.styleOverrides.bottomBorder
: `border-bottom: 1px solid ${colors.borderColor}`};
`;

export const ModalTitleBar = styled.div`
Expand Down