Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added modal custom padding property #1136

Merged
merged 1 commit into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions src/components/Button/Button.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,8 @@ const Template: StoryFn<ButtonProps> = (args) => (
Content
</Button>{" "}
-- CHILDREN BUTTON
<Button
id={"random_btn2"}
label={"Content"}
variant={args.variant}
/> -- LABEL BUTTON
<Button id={"random_btn2"} label={"Content"} variant={args.variant} /> --
LABEL BUTTON
<Button id={"random_btn1"} icon={<TestIcon />} variant={args.variant}>
Content
</Button>{" "}
Expand Down
11 changes: 11 additions & 0 deletions src/components/ModalBox/ModalBox.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const Template: StoryFn<ModalBoxProps> = ({
widthLimit,
customMaxWidth,
backgroundOverlay,
customContentPadding,
}) => {
const [openModal, setOpenModal] = useState<boolean>(false);

Expand All @@ -62,6 +63,7 @@ const Template: StoryFn<ModalBoxProps> = ({
titleIcon={titleIcon}
widthLimit={widthLimit}
customMaxWidth={customMaxWidth}
customContentPadding={customContentPadding}
>
<h1>Inside my Computer</h1>
<p>
Expand Down Expand Up @@ -127,6 +129,15 @@ NoOverlayBG.args = {
backgroundOverlay: false,
};

export const CustomPadding = Template.bind({});

CustomPadding.args = {
title: "Test Title",
titleIcon: <TestIcon />,
backgroundOverlay: false,
customContentPadding: 0,
};

export const CustomMaxWidth = Template.bind({});

CustomMaxWidth.args = {
Expand Down
8 changes: 6 additions & 2 deletions src/components/ModalBox/ModalBox.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ import { css, Theme } from "@emotion/react";

import { CssProperties } from "../../../styled-system/types";

export const modalContainer = (theme: Theme, width: CssProperties["width"]) =>
export const modalContainer = (
theme: Theme,
width: CssProperties["width"],
padding: CssProperties["padding"],
) =>
css({
fontFamily: "'Geist', sans-serif",
color: theme.colors["Color/Neutral/Text/colorTextLabel"],
Expand All @@ -31,7 +35,7 @@ export const modalContainer = (theme: Theme, width: CssProperties["width"]) =>
boxSizing: "border-box",
"& .dialogContent": {
boxSizing: "border-box",
padding: 24,
padding: padding,
maxHeight: "calc(100vh - 150px)",
overflowY: "auto",
},
Expand Down
3 changes: 2 additions & 1 deletion src/components/ModalBox/ModalBox.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

import React from "react";
import React, { CSSProperties } from "react";

import { OverrideTheme } from "../../global/global.types";

Expand All @@ -27,5 +27,6 @@ export interface ModalBoxProps {
titleIcon?: React.ReactNode;
backgroundOverlay?: boolean;
customMaxWidth?: number | string;
customContentPadding?: CSSProperties["padding"];
sx?: OverrideTheme;
}
4 changes: 3 additions & 1 deletion src/components/ModalBox/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

import { FC, useEffect, useState } from "react";
import { FC } from "react";
import { createPortal } from "react-dom";
import { useTheme } from "@emotion/react";

Expand All @@ -33,6 +33,7 @@ const ModalBox: FC<ModalBoxProps> = ({
titleIcon,
backgroundOverlay = true,
customMaxWidth = 750,
customContentPadding = 24,
sx,
}) => {
const theme = useTheme();
Expand All @@ -41,6 +42,7 @@ const ModalBox: FC<ModalBoxProps> = ({
const containerStyles = modalContainer(
theme,
widthLimit ? customMaxWidth : "100%",
customContentPadding,
);
const titleStyles = modalTitleBar(theme);

Expand Down
Loading