diff --git a/gallery/package.json b/gallery/package.json index 21220ead52..1e84e2ca59 100644 --- a/gallery/package.json +++ b/gallery/package.json @@ -1,6 +1,6 @@ { "name": "@sonatype/react-shared-components-gallery", - "version": "1.6.17", + "version": "2.0.0", "description": "Gallery application to demonstrate usage and look of Sonatype shared UI components", "main": "src/main.ts", "scripts": { diff --git a/gallery/src/RawHtmlExample.tsx b/gallery/src/RawHtmlExample.tsx index 05fa9092f9..ad710d4dc7 100644 --- a/gallery/src/RawHtmlExample.tsx +++ b/gallery/src/RawHtmlExample.tsx @@ -11,6 +11,6 @@ interface Props { } const RawHtmlExample = ({ html }: Props) => -
; +
; export default RawHtmlExample; diff --git a/gallery/src/components/NxLoadWrapper/NxLoadWrapperChildrenExample.tsx b/gallery/src/components/NxLoadWrapper/NxLoadWrapperChildrenExample.tsx index 39f47ee901..204e8bce42 100644 --- a/gallery/src/components/NxLoadWrapper/NxLoadWrapperChildrenExample.tsx +++ b/gallery/src/components/NxLoadWrapper/NxLoadWrapperChildrenExample.tsx @@ -9,7 +9,7 @@ import React from 'react'; import { NxLoadWrapper } from '@sonatype/react-shared-components'; const NxLoadWrapperChildrenExample = () => - + {}}>
Children!
; diff --git a/gallery/src/components/NxLoadWrapper/NxLoadWrapperLoadingExample.tsx b/gallery/src/components/NxLoadWrapper/NxLoadWrapperLoadingExample.tsx index c6649325b8..42230662c3 100644 --- a/gallery/src/components/NxLoadWrapper/NxLoadWrapperLoadingExample.tsx +++ b/gallery/src/components/NxLoadWrapper/NxLoadWrapperLoadingExample.tsx @@ -9,7 +9,7 @@ import React from 'react'; import { NxLoadWrapper } from '@sonatype/react-shared-components'; const NxLoadWrapperLoadingExample = () => - + {}}>
Children will not render
; diff --git a/gallery/src/components/NxLoadWrapper/NxLoadWrapperPage.tsx b/gallery/src/components/NxLoadWrapper/NxLoadWrapperPage.tsx index 7b443524e2..9bf38d6043 100644 --- a/gallery/src/components/NxLoadWrapper/NxLoadWrapperPage.tsx +++ b/gallery/src/components/NxLoadWrapper/NxLoadWrapperPage.tsx @@ -60,11 +60,8 @@ const NxLoadWrapperPage = () => Function Yes - If this is defined, a Retry button will be rendered in - the NxLoadError which executes this function - when clicked. For backwards compatibility reasons, this prop is not technically required. However - current UX standards are that it should always be present. If not specified - the NxLoadError will be rendered without a Retry button. + A Retry button will be rendered in the NxLoadError which + executes this function when clicked. diff --git a/gallery/src/components/NxModal/NxModalAlertExample.tsx b/gallery/src/components/NxModal/NxModalAlertExample.tsx index 2dff467f8c..d1f5fd15a8 100644 --- a/gallery/src/components/NxModal/NxModalAlertExample.tsx +++ b/gallery/src/components/NxModal/NxModalAlertExample.tsx @@ -6,7 +6,7 @@ */ import React, {useState} from 'react'; -import {NxModal, NxWarningAlert} from '@sonatype/react-shared-components'; +import {NxModal, NxWarningAlert, NxButton} from '@sonatype/react-shared-components'; export default function NxModalAlertExample() { const [showModal, setShowModal] = useState(false); @@ -14,24 +14,20 @@ export default function NxModalAlertExample() { return ( <> - + setShowModal(true)}>Open Modal { showModal &&
-

- Example NxModal with NxAlert -

+

Example NxModal with NxAlert

- - - The page may contain unsaved changes; continuing will discard them. - + + The page may contain unsaved changes; continuing will discard them.
-
+
- + Close
diff --git a/gallery/src/components/NxModal/NxModalExtraWideExample.tsx b/gallery/src/components/NxModal/NxModalExtraWideExample.tsx index 4b0d4d6328..27150dc09b 100644 --- a/gallery/src/components/NxModal/NxModalExtraWideExample.tsx +++ b/gallery/src/components/NxModal/NxModalExtraWideExample.tsx @@ -6,10 +6,7 @@ */ import React, {useState} from 'react'; -import {NxModal} from '@sonatype/react-shared-components'; -import {NxVulnerabilityDetails} from '@sonatype/react-shared-components'; - -const vulnerabilityDetailsJson = require('../../resources/vulnerabilities/vulnerabilityDetailsJson.json'); +import {NxModal, NxButton} from '@sonatype/react-shared-components'; export default function NxModalExtraWideExample() { const [showModal, setShowModal] = useState(false); @@ -17,20 +14,18 @@ export default function NxModalExtraWideExample() { return ( <> - + setShowModal(true)}>Open wide modal {showModal && - +

Vulnerability Information

- +

This is some content inside a wider modal.

-
+
- + Close
diff --git a/gallery/src/components/NxModal/NxModalFormErrorExample.tsx b/gallery/src/components/NxModal/NxModalFormErrorExample.tsx index 3e1c25c63c..2d49fd34da 100644 --- a/gallery/src/components/NxModal/NxModalFormErrorExample.tsx +++ b/gallery/src/components/NxModal/NxModalFormErrorExample.tsx @@ -6,7 +6,7 @@ */ import React, {useState} from 'react'; -import {NxModal, NxFontAwesomeIcon, NxTextInput, NxLoadError} from '@sonatype/react-shared-components'; +import {NxModal, NxFontAwesomeIcon, NxTextInput, NxLoadError, NxButton} from '@sonatype/react-shared-components'; import {faAngry} from '@fortawesome/free-solid-svg-icons'; import { initialState, userInput } from '@sonatype/react-shared-components/components/NxTextInput/stateHelpers'; @@ -25,10 +25,10 @@ export default function NxModalFormErrorExample() { return ( <> - + setShowModal(true)}>Open Modal with Form and Error Styling {showModal && -
+

@@ -38,23 +38,21 @@ export default function NxModalFormErrorExample() {
-
+
- + Cancel
diff --git a/gallery/src/components/NxModal/NxModalFormExample.tsx b/gallery/src/components/NxModal/NxModalFormExample.tsx index 068b46eef4..f63a748311 100644 --- a/gallery/src/components/NxModal/NxModalFormExample.tsx +++ b/gallery/src/components/NxModal/NxModalFormExample.tsx @@ -6,7 +6,7 @@ */ import React, {useState} from 'react'; -import {NxModal, NxFontAwesomeIcon} from '@sonatype/react-shared-components'; +import {NxModal, NxFontAwesomeIcon, NxButton, NxStatefulTextInput} from '@sonatype/react-shared-components'; import {faAngry} from '@fortawesome/free-solid-svg-icons'; export default function NxModalFormExample() { @@ -15,10 +15,10 @@ export default function NxModalFormExample() { return ( <> - + setShowModal(true)}>Open Modal with Form {showModal && -
+

@@ -28,30 +28,22 @@ export default function NxModalFormExample() {
-
+
- - - + Primary + Default + Tertiary
diff --git a/gallery/src/components/NxModal/NxModalNarrowExample.tsx b/gallery/src/components/NxModal/NxModalNarrowExample.tsx new file mode 100644 index 0000000000..477f2a4d03 --- /dev/null +++ b/gallery/src/components/NxModal/NxModalNarrowExample.tsx @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2019-present Sonatype, Inc. + * This program and the accompanying materials are made available under + * the terms of the Eclipse Public License 2.0 which accompanies this + * distribution and is available at https://www.eclipse.org/legal/epl-2.0/. + */ +import React, {useState} from 'react'; + +import {NxModal, NxFontAwesomeIcon, NxButton} from '@sonatype/react-shared-components'; +import {faAngry} from '@fortawesome/free-solid-svg-icons'; + +export default function NxModalSimpleExample() { + const [showModal, setShowModal] = useState(false); + const modalCloseHandler = () => setShowModal(false); + + return ( + <> + setShowModal(true)}>Open Modal + { showModal && + +
+

+ + + Example NxModal header - this header is long to demonstrate the truncation that all modal headers + can do + +

+
+
+

This is some content inside a narrower modal.

+
+
+
+ Close +
+
+
+ } + + ); +}; diff --git a/gallery/src/components/NxModal/NxModalPage.tsx b/gallery/src/components/NxModal/NxModalPage.tsx index 21630ae046..7a951b9191 100644 --- a/gallery/src/components/NxModal/NxModalPage.tsx +++ b/gallery/src/components/NxModal/NxModalPage.tsx @@ -5,6 +5,7 @@ * distribution and is available at https://www.eclipse.org/legal/epl-2.0/. */ import React from 'react'; +import { NxInfoAlert } from '@sonatype/react-shared-components'; import { GalleryDescriptionTile, GalleryExampleTile } from '../../gallery-components/GalleryTiles'; import NxModalSimpleExample from './NxModalSimpleExample'; @@ -13,6 +14,7 @@ import NxModalFormExample from './NxModalFormExample'; import NxModalStackedExample from './NxModalStackedExample'; import NxModalFormErrorExample from './NxModalFormErrorExample'; import NxModalExtraWideExample from './NxModalExtraWideExample'; +import NxModalNarrowExample from './NxModalNarrowExample'; const NxModalSimpleSourceCode = require('!!raw-loader!./NxModalSimpleExample').default; const NxModalAlertSourceCode = require('!!raw-loader!./NxModalAlertExample').default; @@ -20,6 +22,7 @@ const NxModalFormSourceCode = require('!!raw-loader!./NxModalFormExample').defau const NxModalStackedSourceCode = require('!!raw-loader!./NxModalStackedExample').default; const NxModalFormErrorSourceCode = require('!!raw-loader!./NxModalFormErrorExample').default; const NxModalExtraWideSourceCode = require('!!raw-loader!./NxModalExtraWideExample').default; +const NxModalNarrowSourceCode = require('!!raw-loader!./NxModalNarrowExample').default; export default function NxModalPage() { return ( @@ -58,22 +61,30 @@ export default function NxModalPage() { Wrapping the modal content All content between the header and footer should be wrapped in a div with - the .nx-modal-content className. + the .nx-modal-content className. This element (and thus the modal + overall) will shrink to fit the content, or expand vertically until the modal reaches its maximum height + (determined as a distance from the viewport edges). If the contents of + the nx-modal-content continue to grow beyond that height, it + introduces a scrollbar. - .nx-modal-footer + .nx-footer HTML footer element - The NxModal component supports - buttons, nx-error or nx-alert classes + Each modal should contain a footer containing buttons for various actions. At a minimum, there + should be a button that enables the user to close the modal. Further, the footer may contain + an NxAlert as would typically be the case after a form submission + which resulted in an error. - .nx-modal--wide - The NxModal component + .nx-modal-content--tabs + Modifier of .nx-modal-content - Applies an extra-wide style, for modals with large contents. + A modifier class that must be added to .nx-modal-content when + you want to use tabs within an NxModal as the sole contents of + the modal body. The modifier keeps the tabs "sticky" while allowing the tab content to scroll. @@ -85,6 +96,7 @@ export default function NxModalPage() { Prop Type Required + Default Details @@ -93,6 +105,7 @@ export default function NxModalPage() { className string No + Any className attributes passed in on the NxModal element will be added to @@ -103,11 +116,22 @@ export default function NxModalPage() { onClose Function (() => void) Yes + The function to be called to close the modal when pressing the Escape key. + + variant + "wide" | "narrow" | "normal" + No + "normal" + + This prop specifies a style variant for the modal. Currently, variants only differ in width. + "wide" modals are 1000px wide, "normal" modals are 800px wide, and "narrow" modals are 600px wide. + + Div HTML Attributes @@ -118,16 +142,24 @@ export default function NxModalPage() { No + NxModal supports any html attribute that's normally supported by Div elements + + Note: Placing content into the modal which exceeds its horizontal bounds is not supported. The resulting + layout is unspecified. + - A basic example of an NxModal. Click the button to open the modal. + A basic example of an NxModal. Click the button to open the modal. Note that + this modal has sufficient content to induce scrolling (on most monitors). You will see in other examples that + when modals have smaller contents, the scrollbar does not appear and the modal content area shrinks to fit. NxModal also supports stacked or nested modals. A second modal can be @@ -151,6 +184,7 @@ export default function NxModalPage() { This NxModal also contains a form, but additionally demonstrates the typical @@ -158,10 +192,20 @@ export default function NxModalPage() { an NxErrorAlert in the footer - - A demonstration of the extra-wide styles for NxModal. + A demonstration of the wide styles + for NxModal. + + + + A demonstration of the narrow styles + for NxModal. ); diff --git a/gallery/src/components/NxModal/NxModalSimpleExample.tsx b/gallery/src/components/NxModal/NxModalSimpleExample.tsx index 116af6ddf9..b3a1ee8505 100644 --- a/gallery/src/components/NxModal/NxModalSimpleExample.tsx +++ b/gallery/src/components/NxModal/NxModalSimpleExample.tsx @@ -6,7 +6,7 @@ */ import React, {useState} from 'react'; -import {NxModal, NxFontAwesomeIcon} from '@sonatype/react-shared-components'; +import {NxModal, NxFontAwesomeIcon, NxButton} from '@sonatype/react-shared-components'; import {faAngry} from '@fortawesome/free-solid-svg-icons'; export default function NxModalSimpleExample() { @@ -15,7 +15,7 @@ export default function NxModalSimpleExample() { return ( <> - + setShowModal(true)}>Open Modal { showModal &&
@@ -25,11 +25,45 @@ export default function NxModalSimpleExample() {

-

This is some content inside a modal.

+

+ Bacon ipsum dolor amet tri-tip pork belly pork chop, prosciutto cupim short ribs strip steak frankfurter + sausage shank alcatra corned beef. Buffalo prosciutto leberkas swine bacon turducken kevin, biltong pork + chop ham andouille. Landjaeger swine strip steak, cow andouille jerky fatback pork loin short loin. Beef + ribs t-bone chislic filet mignon chuck porchetta bresaola pork loin. Strip steak rump pancetta, salami + sausage chicken short ribs tenderloin ham pork belly t-bone sirloin pastrami ground round kielbasa. Cupim + alcatra landjaeger shank, venison turkey capicola short ribs spare ribs meatloaf. Chislic strip steak + jowl, ball tip prosciutto salami ham ground round pig pork chop cupim shoulder. +

+

+ Short ribs pancetta tri-tip bacon shoulder jowl bresaola biltong picanha chislic beef ribs jerky + turducken. Pork chop swine pork belly, meatloaf jerky tail sirloin meatball. Capicola short loin shoulder + strip steak, tail beef ribs tongue prosciutto turducken tri-tip leberkas. Tenderloin leberkas doner flank + ball tip tongue drumstick short loin shankle pork. +

+

+ Jowl frankfurter buffalo chuck chicken, pastrami shankle drumstick bresaola picanha strip steak. Sausage + ball tip buffalo capicola ham shoulder. Beef short loin salami strip steak shankle jowl short ribs rump + venison. Turkey jerky ham drumstick flank doner boudin sirloin cow tri-tip andouille. Beef ribs burgdoggen + strip steak shank buffalo turkey corned beef. +

+

+ Shankle boudin filet mignon alcatra jerky. Buffalo prosciutto boudin biltong ball tip, leberkas burgdoggen + meatloaf pig turducken. Landjaeger turducken pig fatback. Ribeye boudin tongue pork chop short loin pork + belly buffalo flank tri-tip pancetta fatback shoulder short ribs spare ribs. Brisket chuck buffalo, + landjaeger pancetta cow jowl rump shankle strip steak turducken burgdoggen spare ribs pork belly + frankfurter. +

+

+ Doner ham hock cupim, buffalo chicken pig sirloin tri-tip. T-bone sirloin swine capicola ham. Kielbasa + leberkas doner cupim venison. Ground round pancetta tri-tip prosciutto t-bone brisket, buffalo leberkas + frankfurter jerky flank chislic corned beef. Swine cow t-bone meatball. Sausage salami turducken bresaola + brisket kielbasa ham hock. Landjaeger boudin bresaola biltong, ham hock brisket turducken kielbasa + meatloaf capicola porchetta hamburger shank jerky ribeye. +

-
+
- + Close
diff --git a/gallery/src/components/NxModal/NxModalStackedExample.tsx b/gallery/src/components/NxModal/NxModalStackedExample.tsx index 09366f7ecf..17391b80d7 100644 --- a/gallery/src/components/NxModal/NxModalStackedExample.tsx +++ b/gallery/src/components/NxModal/NxModalStackedExample.tsx @@ -6,7 +6,7 @@ */ import React, {useState} from 'react'; -import {NxModal, NxFontAwesomeIcon} from '@sonatype/react-shared-components'; +import {NxModal, NxFontAwesomeIcon, NxButton} from '@sonatype/react-shared-components'; import {faAngry} from '@fortawesome/free-solid-svg-icons'; export default function NxModalStackedExample() { @@ -17,7 +17,7 @@ export default function NxModalStackedExample() { return ( <> - + setShowModal(true)}>Open modal with stacked example {showModal &&
@@ -34,12 +34,10 @@ export default function NxModalStackedExample() { This is some more content inside a modal.

-
-