Skip to content

Commit

Permalink
Release 0.0.112 - error modal dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
oharsta committed Sep 3, 2024
1 parent e1c0c8d commit a11d52f
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 16 deletions.
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,6 +1,6 @@
{
"name": "@surfnet/sds",
"version": "0.0.111",
"version": "0.0.112",
"description": "SURF Design System for React",
"main": "cjs/index.js",
"module": "esm/index.js",
Expand Down
29 changes: 17 additions & 12 deletions src/components/Modal/Modal.scss
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
.sds--modal {
&--container {
min-width: 22.875rem;
&--container {
min-width: 22.875rem;

&.full {
max-width: 65.875rem;
}
span.sds--modal--close {
cursor: pointer;
padding: 4px;
&.full {
max-width: 65.875rem;
}

span.sds--modal--close {
cursor: pointer;
padding: 4px;
}

.sds--modal--title.error {
background-color: var(--sds--color--red--400);
}
}
}
}

body.modal-open {
height: 100vh;
overflow-y: hidden;
padding-right: 15px;
height: 100vh;
overflow-y: hidden;
padding-right: 15px;
}
9 changes: 9 additions & 0 deletions src/components/Modal/Modal.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ ModalTemplateNoCancel.args = {
confirmationButtonLabel: "Ok",
};

export const ModalTemplateError = Template.bind({});
ModalTemplateError.args = {
confirm: () => true,
isError: true,
title: "Title",
question: "Question.",
confirmationButtonLabel: "Ok",
};

export const ModalTemplateNoConfirm = Template.bind({});
ModalTemplateNoConfirm.args = {
title: "Title",
Expand Down
4 changes: 3 additions & 1 deletion src/components/Modal/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export interface ModalProps {
question?: string;
cancel?: React.MouseEventHandler<HTMLButtonElement>;
alertType?: AlertType;
isError?: boolean;
subTitle?: string;
confirmDisabled?: boolean;
confirmationButtonLabel?: string;
Expand All @@ -25,6 +26,7 @@ const Modal = (props: React.PropsWithChildren<ModalProps>) => {
const alertType = props.alertType || AlertType.Info;
const full = props.full ? "full" : "";
const className = props.className || "";
const classNameTitle = `sds--modal--title ${props.isError || false ? "error" : ""}`

useEffect(() => {
document.body.classList.add("modal-open");
Expand All @@ -36,7 +38,7 @@ const Modal = (props: React.PropsWithChildren<ModalProps>) => {
return (
<div className="sds--modal sds--backdrop">
<div className={`sds--modal--container ${full} ${className}`}>
<div className="sds--modal--title">
<div className={classNameTitle}>
<p className="sds--text--h4">{props.title}</p>
{props.cancel && <span className="sds--modal--close" onClick={props.cancel}><CloseIcon/></span>}
</div>
Expand Down

0 comments on commit a11d52f

Please sign in to comment.