{
/**
* The minimum Dialog content width, defined by a CSS width value like `50vw` (50% of the viewport). Be careful on using fixed `minWidth` so you don't break responsiveness. Defaults to `30rem` (average width is set to `60vw`).
*/
@@ -74,4 +73,19 @@ export interface DialogContentProps extends ScrollViewProps {
* Same as `noAnimation`, but gets triggered only if the viewport width is less than `40em`. Defaults to false.
*/
noAnimationOnMobile?: string | boolean
+
+ /**
+ * Variant of Dialog. Defaults to 'inform'.
+ */
+ variant?: 'inform' | 'confirm'
+
+ /**
+ * An icon to display at the top of the component. Should be of size medium, so make sure you import the `_medium` version of the Eufemia icon.
+ */
+ icon?: IconPrimaryIcon
+
+ /**
+ * For variant confirm, the dialog is either an informational or a warning message. Defaults to 'info'.
+ */
+ confirmType?: 'info' | 'warning'
}
diff --git a/packages/dnb-eufemia/src/components/modal/__tests__/__snapshots__/Modal.test.tsx.snap b/packages/dnb-eufemia/src/components/modal/__tests__/__snapshots__/Modal.test.tsx.snap
index 2a37ae906e1..cbbd9d3dffd 100644
--- a/packages/dnb-eufemia/src/components/modal/__tests__/__snapshots__/Modal.test.tsx.snap
+++ b/packages/dnb-eufemia/src/components/modal/__tests__/__snapshots__/Modal.test.tsx.snap
@@ -810,7 +810,7 @@ exports[`Modal component have to match snapshot 1`] = `
"props": Object {},
}
}
- className="dnb-dialog dnb-dialog--auto-fullscreen dnb-core-style dnb-dialog--spacing dnb-dialog__align--left dnb-dialog--no-animation"
+ className="dnb-dialog dnb-dialog--auto-fullscreen dnb-core-style dnb-dialog--inform dnb-dialog--spacing dnb-dialog__align--left dnb-dialog--no-animation"
class_name={null}
close_modal={null}
containerPlacement={null}
@@ -836,7 +836,7 @@ exports[`Modal component have to match snapshot 1`] = `
}
}
class={null}
- className="dnb-dialog dnb-dialog--auto-fullscreen dnb-core-style dnb-dialog--spacing dnb-dialog__align--left dnb-dialog--no-animation"
+ className="dnb-dialog dnb-dialog--auto-fullscreen dnb-core-style dnb-dialog--inform dnb-dialog--spacing dnb-dialog__align--left dnb-dialog--no-animation"
class_name={null}
close_modal={null}
containerPlacement={null}
@@ -856,7 +856,7 @@ exports[`Modal component have to match snapshot 1`] = `
title="modal_title"
>
@@ -1129,7 +1130,7 @@ exports[`Modal component have to match snapshot 1`] = `
id="dnb-modal-modal_id-title"
>
modal_title
@@ -2096,22 +2097,28 @@ button.dnb-button::-moz-focus-inner {
:root {
--dialog-min-width: 320px;
--dialog-avg-width: 60vw;
- --dialog-max-width: 60rem;
+ --dialog-max-width: 49rem;
+ --dialog-confirm-avg-width: 40vw;
+ --dialog-confirm-max-width: 40rem;
--dialog-spacing: 2rem;
--dialog-spacing-minus: -2rem; }
.dnb-dialog {
position: relative;
- width: var(--dialog-avg-width);
- min-width: var(--dialog-min-width);
- max-width: var(--dialog-max-width);
max-height: 100vh;
- box-shadow: var(--shadow-default);
border-radius: 0.5rem;
+ box-shadow: var(--shadow-default);
user-select: text;
-webkit-user-select: text;
border: none;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0); }
+ .dnb-dialog--inform {
+ min-width: var(--dialog-min-width);
+ width: var(--dialog-avg-width);
+ max-width: var(--dialog-max-width); }
+ .dnb-dialog--confirm {
+ max-width: var(--dialog-confirm-max-width);
+ margin: 0 1rem; }
@media screen and (max-width: 40em) {
.dnb-dialog--auto-fullscreen {
width: 100%;
@@ -2125,10 +2132,33 @@ button.dnb-button::-moz-focus-inner {
max-width: 100%;
border-radius: 0;
box-shadow: none; }
- @supports (-webkit-touch-callout: none) {
- @media (max-height: 40em) and (orientation: landscape) {
- .dnb-dialog:not(.dnb-dialog--fullscreen) {
- max-height: 80vh; } } }
+ .dnb-dialog--spacing.dnb-dialog--inform .dnb-dialog__inner {
+ padding-bottom: calc(var(--dialog-spacing) * 1.25); }
+ @supports (-webkit-touch-callout: none) {
+ .dnb-dialog--spacing.dnb-dialog--inform .dnb-dialog__inner {
+ padding-bottom: calc(var(--dialog-spacing) * 8); } }
+ .dnb-dialog--spacing.dnb-dialog--inform .dnb-dialog__inner {
+ padding-left: calc(var(--dialog-spacing) * 1.75);
+ padding-right: calc(var(--dialog-spacing) * 1.75); }
+ @media screen and (max-width: 60em) {
+ .dnb-dialog--spacing.dnb-dialog--inform .dnb-dialog__inner {
+ padding-left: calc(var(--dialog-spacing));
+ padding-right: calc(var(--dialog-spacing)); } }
+ @media screen and (max-width: 40em) {
+ .dnb-dialog--spacing.dnb-dialog--inform .dnb-dialog__inner {
+ padding-left: calc(var(--dialog-spacing) / 2);
+ padding-right: calc(var(--dialog-spacing) / 2); } }
+ .dnb-dialog--spacing.dnb-dialog--inform .dnb-dialog__navigation.dnb-section {
+ margin-top: calc(var(--dialog-spacing));
+ margin-bottom: calc(var(--dialog-spacing) / 2); }
+ @media screen and (max-width: 50em) {
+ .dnb-dialog--spacing.dnb-dialog--inform .dnb-dialog__navigation.dnb-section {
+ margin-top: calc(var(--dialog-spacing) / 2); } }
+ .dnb-dialog--spacing.dnb-dialog--confirm .dnb-dialog__inner {
+ padding: calc(var(--dialog-spacing)); }
+ @supports (-webkit-touch-callout: none) {
+ .dnb-dialog--spacing.dnb-dialog--confirm .dnb-dialog__inner {
+ padding-bottom: calc(var(--dialog-spacing) * 8); } }
.dnb-dialog__inner {
position: relative;
display: flex;
@@ -2144,38 +2174,22 @@ button.dnb-button::-moz-focus-inner {
top: 0;
width: 100vw;
height: 100%; }
- .dnb-dialog--spacing .dnb-dialog__inner {
- padding: 0 var(--dialog-spacing) 0; }
- @media screen and (min-width: 72em) {
- .dnb-dialog--spacing .dnb-dialog__inner {
- padding: 0 calc(var(--dialog-spacing) * 1.75) 0; } }
- @media screen and (max-width: 50em) {
- .dnb-dialog--spacing .dnb-dialog__inner {
- padding: 0 calc(var(--dialog-spacing) / 1.333333) 0; } }
- @media screen and (max-width: 40em) {
- .dnb-dialog--spacing .dnb-dialog__inner {
- padding: 0 calc(var(--dialog-spacing) / 2) 0; } }
.dnb-dialog__align--centered .dnb-dialog__inner {
align-items: center;
justify-content: center; }
- html:not([data-visual-test]) .dnb-dialog {
- animation: show-modal var(--modal-animation-duration) ease-out forwards; }
- html:not([data-visual-test]) .dnb-dialog--hide {
- animation: hide-modal 220ms ease-in-out forwards; }
- .dnb-dialog--no-animation {
- animation-duration: 0ms !important; }
- @media screen and (max-width: 40em) {
- .dnb-dialog--no-animation-on-mobile {
- animation-delay: 0ms !important;
- animation-duration: 0ms !important; } }
+ .dnb-dialog__align--centered .dnb-dialog__title,
+ .dnb-dialog__align--centered.dnb-dialog--confirm .dnb-dialog__content {
+ text-align: center; }
.dnb-dialog__content {
position: relative;
z-index: 1; }
- .dnb-dialog--spacing .dnb-dialog__content {
- padding-bottom: calc(var(--dialog-spacing) * 2); }
- @supports (-webkit-touch-callout: none) {
- .dnb-dialog--spacing .dnb-dialog__content {
- padding-bottom: calc(var(--dialog-spacing) * 8); } }
+ .dnb-dialog__actions {
+ padding-top: 1.5rem;
+ display: flex;
+ justify-content: center;
+ width: 100%; }
+ .dnb-dialog__actions > :not(:last-child) {
+ margin-right: 1rem; }
.dnb-dialog__align--center .dnb-dialog__content {
align-items: center;
text-align: center; }
@@ -2184,33 +2198,82 @@ button.dnb-button::-moz-focus-inner {
text-align: right; }
.dnb-dialog__title ~ .dnb-dialog__content {
padding-top: calc(var(--dialog-spacing) / 2); }
- .dnb-dialog .dnb-dialog__header [class*='dnb-h--'],
- .dnb-dialog .dnb-dialog__header .dnb-modal__title {
- padding: 0; }
- .dnb-dialog .dnb-dialog__header [class*='dnb-h--']:not([class*='__top']),
- .dnb-dialog .dnb-dialog__header .dnb-modal__title:not([class*='__top']) {
- margin-top: 0; }
- .dnb-dialog .dnb-dialog__header [class*='dnb-h--']:not([class*='__bottom']),
- .dnb-dialog .dnb-dialog__header .dnb-modal__title:not([class*='__bottom']) {
- margin-bottom: 0; }
- .dnb-dialog .dnb-dialog__header::after {
- top: -500%;
- height: 600%; }
+ @media screen and (max-width: 50em) {
+ .dnb-dialog__title {
+ font-size: var(--font-size-large) !important;
+ line-height: var(--line-height-medium) !important; } }
+ @media screen and (max-width: 40em) {
+ .dnb-dialog__title {
+ font-size: var(--font-size-medium) !important;
+ line-height: calc(var(--line-height-medium) - 0.25rem) !important; } }
+ .dnb-dialog--inform .dnb-dialog__title {
+ margin-bottom: var(--spacing-small) !important; }
+ .dnb-dialog--confirm .dnb-dialog__title {
+ margin-bottom: var(--spacing-x-small) !important; }
+ .dnb-dialog__icon ~ .dnb-dialog__header {
+ margin-top: 1.5rem; }
+ .dnb-dialog__navigation.dnb-section {
+ display: flex;
+ flex-direction: row;
+ justify-content: space-between; }
+ .dnb-dialog__icon {
+ padding: 0.5rem; }
+ .dnb-dialog__icon__primary {
+ position: relative;
+ vertical-align: baseline; }
+ .dnb-dialog__icon__primary::after {
+ content: '';
+ position: absolute;
+ left: -40%;
+ right: -40%;
+ top: -40%;
+ bottom: -40%;
+ margin: auto;
+ border-radius: 50%;
+ background-color: currentColor;
+ z-index: -1;
+ opacity: 0.1; }
+ .dnb-dialog__icon__primary.dnb-dialog__icon--warning {
+ color: var(--color-fire-red); }
+ .dnb-dialog__icon__primary.dnb-dialog__icon--warning ::after {
+ background-color: var(--color-fire-red-8);
+ opacity: 1; }
+ .dnb-dialog__icon__primary.dnb-dialog__icon--info {
+ color: var(--color-emerald-green); }
+ .dnb-dialog__icon__primary.dnb-dialog__icon--info ::after {
+ background-color: var(--color-pistachio);
+ opacity: 1; }
+ html:not([data-visual-test]) .dnb-dialog {
+ animation: show-modal var(--modal-animation-duration) ease-out forwards; }
+ html:not([data-visual-test]) .dnb-dialog--hide {
+ animation: hide-modal 220ms ease-in-out forwards; }
+ .dnb-dialog--no-animation {
+ animation-duration: 0ms !important; }
+ @media screen and (max-width: 40em) {
+ .dnb-dialog--no-animation-on-mobile {
+ animation-delay: 0ms !important;
+ animation-duration: 0ms !important; } }
.dnb-dialog--spacing .dnb-dialog__header .dnb-tabs {
margin-top: 3.5rem; }
.dnb-dialog__body {
padding-bottom: calc(var(--dialog-spacing) * 2);
margin-bottom: calc(var(--dialog-spacing-minus) * 2); }
- .dnb-dialog__navigation.dnb-section {
- display: flex;
- flex-direction: row;
- justify-content: space-between; }
- .dnb-dialog--spacing .dnb-dialog__navigation.dnb-section {
- margin-top: calc(var(--dialog-spacing) * 1.75);
- margin-bottom: calc(var(--dialog-spacing) / 2); }
- @media screen and (max-width: 50em) {
- .dnb-dialog--spacing .dnb-dialog__navigation.dnb-section {
- margin-top: calc(var(--dialog-spacing) / 2); } }
+ .dnb-dialog__header [class*='dnb-h--'],
+ .dnb-dialog__header .dnb-modal__title {
+ padding: 0; }
+ .dnb-dialog__header [class*='dnb-h--']:not([class*='__top']),
+ .dnb-dialog__header .dnb-modal__title:not([class*='__top']) {
+ margin-top: 0; }
+ .dnb-dialog__header [class*='dnb-h--']:not([class*='__bottom']),
+ .dnb-dialog__header .dnb-modal__title:not([class*='__bottom']) {
+ margin-bottom: 0; }
+ .dnb-dialog__header::after {
+ top: -500%;
+ height: 600%; }
+ @supports (-webkit-touch-callout: none) {
+ @media (max-height: 40em) and (orientation: landscape) {
+ .dnb-dialog:not(.dnb-dialog--fullscreen) {
+ max-height: 80vh; } } }
[data-visual-test].hide-page-content #___gatsby {
opacity: 0; }
@@ -2292,7 +2355,8 @@ html[data-dnb-modal-active] {
.dnb-modal__header__bar.dnb-section {
display: flex;
flex-direction: row;
- justify-content: space-between; }
+ justify-content: space-between;
+ width: 100%; }
@media screen and (-ms-high-contrast: none) {
.dnb-modal__header__bar.dnb-section {
align-items: center; } }
diff --git a/packages/dnb-eufemia/src/components/modal/__tests__/__snapshots__/modal-screenshot-test-js-modal-screenshot-have-to-match-the-default-modal-window-1-b836a.snap.png b/packages/dnb-eufemia/src/components/modal/__tests__/__snapshots__/modal-screenshot-test-js-modal-screenshot-have-to-match-the-default-modal-window-1-b836a.snap.png
index c0760d57db7..a9d5d4ed4fd 100644
Binary files a/packages/dnb-eufemia/src/components/modal/__tests__/__snapshots__/modal-screenshot-test-js-modal-screenshot-have-to-match-the-default-modal-window-1-b836a.snap.png and b/packages/dnb-eufemia/src/components/modal/__tests__/__snapshots__/modal-screenshot-test-js-modal-screenshot-have-to-match-the-default-modal-window-1-b836a.snap.png differ
diff --git a/packages/dnb-eufemia/src/components/modal/__tests__/__snapshots__/modal-screenshot-test-js-modal-screenshot-have-to-match-the-default-modal-window-with-title-1-8e313.snap.png b/packages/dnb-eufemia/src/components/modal/__tests__/__snapshots__/modal-screenshot-test-js-modal-screenshot-have-to-match-the-default-modal-window-with-title-1-8e313.snap.png
index 89ecb563562..407322c1b51 100644
Binary files a/packages/dnb-eufemia/src/components/modal/__tests__/__snapshots__/modal-screenshot-test-js-modal-screenshot-have-to-match-the-default-modal-window-with-title-1-8e313.snap.png and b/packages/dnb-eufemia/src/components/modal/__tests__/__snapshots__/modal-screenshot-test-js-modal-screenshot-have-to-match-the-default-modal-window-with-title-1-8e313.snap.png differ
diff --git a/packages/dnb-eufemia/src/components/modal/style/_modal.scss b/packages/dnb-eufemia/src/components/modal/style/_modal.scss
index 2f84429b0da..6e639397554 100644
--- a/packages/dnb-eufemia/src/components/modal/style/_modal.scss
+++ b/packages/dnb-eufemia/src/components/modal/style/_modal.scss
@@ -120,6 +120,7 @@ html[data-dnb-modal-active] {
display: flex;
flex-direction: row;
justify-content: space-between;
+ width: 100%;
@include IS_IE() {
align-items: center; // IE11 uses top as default
diff --git a/packages/dnb-eufemia/src/shared/locales/en-GB.js b/packages/dnb-eufemia/src/shared/locales/en-GB.js
index 305bd4ddec5..9c4ff533021 100644
--- a/packages/dnb-eufemia/src/shared/locales/en-GB.js
+++ b/packages/dnb-eufemia/src/shared/locales/en-GB.js
@@ -72,6 +72,10 @@ export default {
dialog_title: 'Dialog Window',
close_title: 'Close',
},
+ Dialog: {
+ declineText: 'Cancel',
+ confirmText: 'Approve',
+ },
NumberFormat: {
clipboard_copy: 'Copied',
},
diff --git a/packages/dnb-eufemia/src/shared/locales/nb-NO.js b/packages/dnb-eufemia/src/shared/locales/nb-NO.js
index 646c644d894..9c1f144c19b 100644
--- a/packages/dnb-eufemia/src/shared/locales/nb-NO.js
+++ b/packages/dnb-eufemia/src/shared/locales/nb-NO.js
@@ -72,6 +72,10 @@ export default {
dialog_title: 'Separat Vindu',
close_title: 'Lukk',
},
+ Dialog: {
+ declineText: 'Avbryt',
+ confirmText: 'Godta',
+ },
NumberFormat: {
clipboard_copy: 'Kopiert',
},