Skip to content

Commit

Permalink
Merge pull request #98 from perimetre/9.3.0
Browse files Browse the repository at this point in the history
9.3.0
  • Loading branch information
adarleyjrr authored Mar 13, 2023
2 parents 9827cc1 + 6cdd73f commit d954986
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

## [9.3.0] 2023-03-13

### Added

- Added option to center modal container

## [9.2.5] 2023-01-18

### Fixed
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@perimetre/ui",
"description": "A component library made by @perimetre",
"version": "9.2.5",
"version": "9.3.0",
"repository": {
"type": "git",
"url": "git+https://github.com/perimetre/ui.git"
Expand Down
7 changes: 7 additions & 0 deletions src/components/Modal/Modal.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ export default {
options: minWidthOptions
}
},
position: {
defaultValue: 'default',
control: {
type: 'select',
options: ['default', 'center']
}
},
isClosable: {
defaultValue: true,
control: {
Expand Down
4 changes: 4 additions & 0 deletions src/components/Modal/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@
&.new {
border-radius: 20px 45px 20px 20px;
}
/* Centers modal container */
&.center {
@apply my-auto
}
}

.pui-modal-header {
Expand Down
10 changes: 9 additions & 1 deletion src/components/Modal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ export type ModalProps = {
* What style of the component should be used
*/
variant?: 'default' | 'new';
/**
* Define how modal should position itself
*/
position?: 'default' | 'center';
/**
* Whether the padding of content container should be removed or not
*/
Expand All @@ -51,6 +55,7 @@ export type ModalProps = {
* @param props.title A title string
* @param props.isClosable If true close button won't be displayed and the user won't be able to close modal by any means
* @param props.variant What style of the component should be used
* @param props.position Define how modal should position itself
* @param props.removePadding Whether the padding of content container should be removed or not
* @param props.actions A component that if provided will add a "actions" footer
* @param props.children The provided children content
Expand All @@ -63,6 +68,7 @@ export const Modal: React.FC<PropsWithChildren<ModalProps>> = ({
actions,
removePadding,
variant = 'default',
position = 'default',
isClosable = true,
children
}) => {
Expand Down Expand Up @@ -105,7 +111,9 @@ export const Modal: React.FC<PropsWithChildren<ModalProps>> = ({
return (
<ReactPortal selector="#modal-root">
<div className={classnames('pui-modal', { open: isOpen })}>
<div className={classnames('pui-modal-container', { new: variant === 'new' })}>
<div
className={classnames('pui-modal-container', { new: variant === 'new' }, { center: position === 'center' })}
>
<div className={classnames('pui-modal-header ', { 'absolute z-30': isHeaderAbsolute })}>
<h3 className={classnames(removePadding ? 'p-0' : 'p-4')}>{title}</h3>
{/* Adds a close icon */}
Expand Down

0 comments on commit d954986

Please sign in to comment.