This repository has been archived by the owner on Jun 20, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from smooth-code/modals
feat: add Modal
- Loading branch information
Showing
18 changed files
with
551 additions
and
188 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,61 @@ | ||
import React from 'react' | ||
import PropTypes from 'prop-types' | ||
import styled from 'styled-components' | ||
import styled, { css } from 'styled-components' | ||
import classNames from 'classnames' | ||
import handleRef from './internal/handleRef' | ||
import setWithComponent from './internal/setWithComponent' | ||
import * as defaultTheme from './theme/defaultTheme' | ||
import { mixin } from './utils' | ||
import { mixin, th, up } from './utils' | ||
|
||
const ModalContentComponent = ({ className, theme, ...props }) => ( | ||
<div className={classNames('sui-modal-content', className)} {...props} /> | ||
const ModalContentComponent = ({ | ||
className, | ||
component: Component = 'div', | ||
theme, | ||
...props | ||
}) => ( | ||
<Component | ||
className={classNames('sui-modal-content', className)} | ||
{...props} | ||
/> | ||
) | ||
|
||
const ModalContentRefComponent = handleRef(ModalContentComponent) | ||
|
||
const ModalContent = styled(ModalContentComponent)` | ||
${mixin('base')}; | ||
position: relative; | ||
display: flex; | ||
flex-direction: column; | ||
/* Ensure "ModalContent" extends the full width of the parent "ModalDialog" */ | ||
width: 100%; | ||
/* Counteract the pointer-events: none; in the ModalDialog */ | ||
pointer-events: auto; | ||
background-color: #fff; | ||
background-color: ${th('modalContentBg')}; | ||
background-clip: padding-box; | ||
border: 1px solid rgba(0, 0, 0, 0.2); | ||
border-radius: 0.3rem; | ||
border: ${th('modalContentBorderWidth')} solid | ||
${th('modalContentBorderColor')}; | ||
border-radius: ${th('modalContentBorderRadius')}; | ||
box-shadow: ${th('modalContentBoxShadowXs')}; | ||
/* Remove focus outline from opened modal */ | ||
outline: 0; | ||
${up( | ||
'sm', | ||
css` | ||
box-shadow: ${th('modalContentBoxShadowSmUp')}; | ||
`, | ||
)}; | ||
` | ||
|
||
ModalContent.propTypes = { | ||
children: PropTypes.node, | ||
className: PropTypes.string, | ||
theme: PropTypes.object, | ||
} | ||
|
||
ModalContent.defaultProps = { | ||
theme: defaultTheme, | ||
} | ||
|
||
setWithComponent(ModalContent, ModalContentRefComponent) | ||
|
||
/** @component */ | ||
export default ModalContent |
Oops, something went wrong.