diff --git a/package-lock.json b/package-lock.json index 6ce1536d2..625c70f3a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@dabapps/roe", - "version": "0.9.8", + "version": "0.9.9", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index e19e88ed9..8edb0bcc5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@dabapps/roe", - "version": "0.9.8", + "version": "0.9.9", "description": "A Collection of React Components for Project Development", "main": "dist/js/index.js", "types": "dist/js/index.d.ts", diff --git a/src/less/modals.less b/src/less/modals.less index 73ee8bea2..e55111b78 100644 --- a/src/less/modals.less +++ b/src/less/modals.less @@ -69,17 +69,20 @@ } .modal-position { - padding: 0 @gutter-width / 2; + padding: @modal-margin-vertical @modal-margin-horizontal; margin: 0 auto; - @modal-margins: @margin-large * 2; - @modal-header-and-footer-margins: (@margin-large * 2) * 2; - @modal-header-and-footer-content: 50px * 2; // Magic number to allow slightly larger content - @modal-header-and-footer-space: @modal-margins + @modal-header-and-footer-margins + @modal-header-and-footer-content; + // For internal use only + @modal-margin-vertical-double: @modal-margin-vertical * 2; &.scrollable { + .modal { + display: flex; + flex-direction: column; + max-height: ~'calc(100vh - @{modal-margin-vertical-double})'; + } + .modal-body { - max-height: ~'calc(100vh - @{modal-header-and-footer-space})'; overflow: auto; } } @@ -115,6 +118,7 @@ .modal { .content-box(); + margin: 0; position: relative; z-index: 1; transform: translate3d(0, 0, 0); diff --git a/src/less/variables.less b/src/less/variables.less index e0525d282..fa4821bd8 100644 --- a/src/less/variables.less +++ b/src/less/variables.less @@ -122,6 +122,9 @@ @modal-footer-background: @modal-header-background; @modal-footer-border: @modal-header-border; +@modal-margin-vertical: @gutter-width / 2; +@modal-margin-horizontal: @gutter-width / 2; + @well-background: @grey-lightest; @well-border: @border-base; diff --git a/src/ts/components/modals/modal.examples.md b/src/ts/components/modals/modal.examples.md index f71cfc512..c8dfc71c4 100644 --- a/src/ts/components/modals/modal.examples.md +++ b/src/ts/components/modals/modal.examples.md @@ -16,6 +16,8 @@ class ModalExample extends React.Component { }; this.onClickOpenModal = this.onClickOpenModal.bind(this); + this.onClickOpenScrollableModal = this.onClickOpenScrollableModal.bind(this); + this.onClickOpenSmallModal = this.onClickOpenSmallModal.bind(this); this.onClickCloseModal = this.onClickCloseModal.bind(this); } @@ -56,15 +58,85 @@ class ModalExample extends React.Component { }); } + onClickOpenScrollableModal () { + this.setState({ + modals: [ + + + + {/* Replace this char with an icon */} + {X_CHAR} + +
+ Header +
+
+ + + + + + + + + +
+ ] + }); + } + + onClickOpenSmallModal () { + this.setState({ + modals: [ + + + + {/* Replace this char with an icon */} + {X_CHAR} + +
+ Header +
+
+ + + + + + + + + +
+ ] + }); + } + render () { const { modals } = this.state; return (
- + + + +
); @@ -73,3 +145,18 @@ class ModalExample extends React.Component { ``` + +#### Less variables +```less +@modal-background: @content-box-background; +@modal-header-background: @content-box-header-background; +@modal-header-border: @content-box-header-border; + +@modal-footer-background: @modal-header-background; +@modal-footer-border: @modal-header-border; + +@modal-margin-vertical: @gutter-width / 2; +@modal-margin-horizontal: @gutter-width / 2; + +@modal-z-index: 1100; +``` diff --git a/src/ts/components/modals/modal.tsx b/src/ts/components/modals/modal.tsx index 3cdeee5af..75801dd18 100644 --- a/src/ts/components/modals/modal.tsx +++ b/src/ts/components/modals/modal.tsx @@ -55,7 +55,9 @@ export class Modal extends PureComponent {
- {children} + + {children} +
); diff --git a/src/ts/components/navigation/nav-bar.examples.md b/src/ts/components/navigation/nav-bar.examples.md index d8c494ea4..c7d2dce96 100644 --- a/src/ts/components/navigation/nav-bar.examples.md +++ b/src/ts/components/navigation/nav-bar.examples.md @@ -88,4 +88,6 @@ class NavBarExample extends React.Component { @nav-bar-background: @body-background; // @white; @nav-bar-border: @border-base; @nav-bar-height: @input-height + @padding-base * 2; + +@nav-bar-z-index: 500; ``` diff --git a/src/ts/components/navigation/side-bar.examples.md b/src/ts/components/navigation/side-bar.examples.md index 91c26e4a7..db6735116 100644 --- a/src/ts/components/navigation/side-bar.examples.md +++ b/src/ts/components/navigation/side-bar.examples.md @@ -70,4 +70,6 @@ class SideBarExample extends React.Component { @side-bar-background: @body-background; @side-bar-border: @border-base; @side-bar-width: 250px; + +@side-bar-z-index: 1200; ``` diff --git a/tests/__snapshots__/modals.tsx.snap b/tests/__snapshots__/modals.tsx.snap index cb8cc35ba..99624c82b 100644 --- a/tests/__snapshots__/modals.tsx.snap +++ b/tests/__snapshots__/modals.tsx.snap @@ -129,7 +129,7 @@ exports[`Modal should take regular element attributes 1`] = ` className="modal-position" >