Skip to content

Commit

Permalink
fix(modal): added conditional padding for modal, adjusted zindex of c…
Browse files Browse the repository at this point in the history
…lose modal icon
  • Loading branch information
Se-Gl committed Aug 7, 2022
1 parent 6088a5f commit 02026bb
Show file tree
Hide file tree
Showing 11 changed files with 50 additions and 41 deletions.
3 changes: 1 addition & 2 deletions CHANGELOG.md
@@ -1,9 +1,8 @@
## [7.0.6](https://github.com/Se-Gl/codn/compare/v7.0.5...v7.0.6) (2022-08-06)


### Bug Fixes

* **css:** re-added css imports in components ([5ad9486](https://github.com/Se-Gl/codn/commit/5ad948608c612b6d12351763d8f018f73f9400bc))
- **css:** re-added css imports in components ([5ad9486](https://github.com/Se-Gl/codn/commit/5ad948608c612b6d12351763d8f018f73f9400bc))

## [7.0.5](https://github.com/Se-Gl/codn/compare/v7.0.4...v7.0.5) (2022-08-06)

Expand Down
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -297,6 +297,7 @@ export default App
| setToggle | - | useState toggle setToggle |
| useKeyInput | true | Use the default key inputs "CTRL + k" to open the modal and "ESC" to close the modal |
| shadow | true | Set a black shadow modal content |
| modalPadding | true | Apply a 20px padding around the modal |
| className | "" | Use your own className to style the modal content |
| backgroundAnimation | 'fade-in animation-duration-500ms animation-forwards' | Add your custom animation className in order to overwrite the default fade in animation for the background |
| modalContentAnimation | 'fade-in animation-duration-500ms animation-forwards' | Add your custom animation className in order to overwrite the default fade in animation for the modal content component |
Expand Down
2 changes: 1 addition & 1 deletion dist/index.es.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/style/green.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion images/badges/badge-branches.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 16 additions & 5 deletions src/components/Modal/Modal.js
Expand Up @@ -12,7 +12,8 @@ export const Modal = ({
closeIcon = <CloseIcon />,
modalContentAnimation = 'fade-in animation-duration-500ms animation-forwards',
useKeyInput = true,
shadow = true
shadow = true,
modalPadding = true
}) => {
useKeyInput === true &&
useEffect(() => {
Expand Down Expand Up @@ -51,6 +52,7 @@ export const Modal = ({
className={className}
setToggle={setToggle}
closeIcon={closeIcon}
modalPadding={modalPadding}
modalContentAnimation={modalContentAnimation}>
{children}
</ModalContent>
Expand All @@ -62,7 +64,16 @@ export const Modal = ({
)
}

const ModalContent = ({ children, className, modalContentAnimation, closeIcon, shadow, setToggle, ...restProps }) => {
const ModalContent = ({
children,
className,
modalContentAnimation,
closeIcon,
shadow,
setToggle,
modalPadding,
...restProps
}) => {
const modalRef = useRef()

return (
Expand All @@ -80,11 +91,11 @@ const ModalContent = ({ children, className, modalContentAnimation, closeIcon, s
tabIndex={0}
onKeyPress={setToggle.bind(this, false)}
onClick={setToggle.bind(this, false)}
className='absolute z-1 focus:outline-1px focus:outline-solid focus:outline-gray text-gray-9'
style={{ top: '20px', right: '20px' }}>
className='absolute focus:outline-1px focus:outline-solid focus:outline-gray text-gray-9'
style={{ top: '20px', right: '20px', zIndex: '99999' }}>
{closeIcon}
</div>
<div className='p-20px'>{children}</div>
<div className={modalPadding ? 'p-20px' : ''}>{children}</div>
</div>
)
}
Expand Down
2 changes: 1 addition & 1 deletion src/stories/Modal.stories.js
Expand Up @@ -18,7 +18,7 @@ export const StoryModal = stories.add('Modal', () => {

{/* Modal */}
<div className='relative z-2'>
<Modal toggle={toggleModal} setToggle={setToggleModal}>
<Modal toggle={toggleModal} setToggle={setToggleModal} modalPadding={false}>
<Modal.Header className='sans font-900 text-30px fade-in-left animation-duration-500ms animation-forwards'>
<h3>👋 Hi, I'm your modal</h3>
</Modal.Header>
Expand Down
39 changes: 27 additions & 12 deletions src/stories/Toast.stories.js
Expand Up @@ -81,17 +81,32 @@ stories.add('Toast', () => {
const [toastList, setToastList] = useState([])

return (
<div className='' style={{ fontFamily: 'Inter' }}>
<button onClick={() => handleShowToast('info', 'Success', 'You did it! codn toast works successfully!', setToastList)}>
Show warning
</button>
<Toast
toastList={toastList}
setToastList={setToastList}
duration={50000}
position='top-right'
progressColor='from-blue to-magenta gradient-to-left'
/>
</div>
<>
<div className='min-h-100vh bg-red-7' style={{ fontFamily: 'Inter' }}>
<button onClick={() => handleShowToast('info', 'Success', 'You did it! codn toast works successfully!', setToastList)}>
Show info
</button>
<Toast
toastList={toastList}
setToastList={setToastList}
duration={50000}
position='top-right'
progressColor='from-blue to-magenta gradient-to-left'
/>
</div>

<div
className='h-100vh py-10rem sm:my-0px md:my-0px sm:m-10px md:m-10px opacity-100per fade-in-bottom animate animation-forwards transition-all transition-duration-300ms transition-delay-700ms'
style={{ fontFamily: 'Inter' }}>
<button onClick={() => handleShowToast('error', 'Error', 'ufff!', setToastList)}>Show error</button>
<Toast
toastList={toastList}
setToastList={setToastList}
duration={50000}
position='top-right'
progressColor='from-blue to-magenta gradient-to-left'
/>
</div>
</>
)
})
1 change: 0 additions & 1 deletion src/style/green.css

This file was deleted.

16 changes: 0 additions & 16 deletions src/style/input.css

This file was deleted.

0 comments on commit 02026bb

Please sign in to comment.