@grantbii/design-system 1.0.36 → 1.0.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,12 @@
1
+ import { MouseEventHandler, ReactElement, ReactNode } from "react";
2
+ type ModalProps = {
3
+ clickable: (openModal: MouseEventHandler<HTMLButtonElement>) => ReactNode;
4
+ header?: ReactNode;
5
+ content: ReactElement;
6
+ footer?: ReactNode;
7
+ width?: string;
8
+ height?: string;
9
+ isFullScreen?: boolean;
10
+ };
11
+ declare const Modal: ({ clickable, ...props }: ModalProps) => import("react/jsx-runtime").JSX.Element;
12
+ export default Modal;
@@ -0,0 +1,103 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import { useCallback, useState, } from "react";
14
+ import styled from "styled-components";
15
+ import { Button } from "../atoms";
16
+ import { Colors } from "../foundations";
17
+ const Modal = (_a) => {
18
+ var { clickable } = _a, props = __rest(_a, ["clickable"]);
19
+ const [showModal, setShowModal] = useState(false);
20
+ const { lockScroll, unlockScroll } = useScrollLock();
21
+ const openModal = () => {
22
+ setShowModal(true);
23
+ lockScroll();
24
+ };
25
+ const closeModal = () => {
26
+ setShowModal(false);
27
+ unlockScroll();
28
+ };
29
+ return (_jsxs(_Fragment, { children: [clickable(openModal), showModal ? _jsx(PopUp, Object.assign({}, props, { closeModal: closeModal })) : _jsx(_Fragment, {})] }));
30
+ };
31
+ export default Modal;
32
+ const useScrollLock = () => {
33
+ const lockScroll = useCallback(() => {
34
+ document.body.style.overflow = "hidden";
35
+ }, []);
36
+ const unlockScroll = useCallback(() => {
37
+ document.body.style.overflow = "initial";
38
+ }, []);
39
+ return {
40
+ lockScroll,
41
+ unlockScroll,
42
+ };
43
+ };
44
+ const PopUp = ({ header, content, footer, width, height, isFullScreen, closeModal, }) => (_jsx(Overlay, { children: _jsxs(ModalWindow, { "$isFullScreen": isFullScreen, "$width": width, children: [header ? _jsx(ModalHeader, { children: header }) : _jsx(_Fragment, {}), _jsx(ModalBody, { "$isFullScreen": isFullScreen, "$height": height, children: content }), _jsxs(ModalFooter, { children: [_jsx(CancelButton, { onClick: () => closeModal() }), footer ? footer : _jsx(_Fragment, {})] })] }) }));
45
+ const Overlay = styled.div `
46
+ background-color: ${Colors.semantic.overlay};
47
+
48
+ z-index: ${Number.MAX_SAFE_INTEGER};
49
+ position: fixed;
50
+ top: 0px;
51
+ left: 0px;
52
+
53
+ width: 100vw;
54
+ height: 100vh;
55
+
56
+ display: flex;
57
+ flex-direction: column;
58
+ justify-content: center;
59
+ align-items: center;
60
+ `;
61
+ const ModalWindow = styled.div `
62
+ background-color: ${Colors.base.white};
63
+ border-radius: ${({ $isFullScreen }) => ($isFullScreen ? 0 : 6)}px;
64
+
65
+ width: ${({ $isFullScreen, $width = "auto" }) => $isFullScreen ? "100%" : $width};
66
+
67
+ height: ${({ $isFullScreen }) => ($isFullScreen ? "100%" : "auto")};
68
+ min-height: 100px;
69
+ `;
70
+ const ModalHeader = styled.div `
71
+ font-weight: 500;
72
+ font-size: 18px;
73
+
74
+ padding: 12px 24px;
75
+ border-bottom: 1px solid ${Colors.neutral.grey3};
76
+ `;
77
+ const ModalBody = styled.div `
78
+ display: flex;
79
+ flex-direction: column;
80
+ gap: 12px;
81
+
82
+ height: ${({ $isFullScreen, $height = "auto" }) => $isFullScreen ? "calc(100% - 160px)" : $height};
83
+
84
+ padding-top: 24px;
85
+
86
+ > * {
87
+ width: 100%;
88
+ height: 100%;
89
+
90
+ padding: 0px 24px;
91
+ border: none;
92
+
93
+ overflow-y: auto;
94
+ }
95
+ `;
96
+ const ModalFooter = styled.div `
97
+ display: flex;
98
+ justify-content: space-between;
99
+ gap: 12px;
100
+
101
+ padding: 24px;
102
+ `;
103
+ const CancelButton = ({ onClick }) => (_jsx(Button, { text: "Cancel", onClick: onClick, backgroundColor: Colors.neutral.grey3, color: Colors.typography.blackHigh }));
@@ -0,0 +1 @@
1
+ export { default as Modal } from "./Modal";
@@ -0,0 +1 @@
1
+ export { default as Modal } from "./Modal";
package/index.d.ts CHANGED
@@ -2,3 +2,4 @@ export * from "./core/atoms";
2
2
  export * from "./core/foundations";
3
3
  export { default as GlobalStyle } from "./core/global/GlobalStyle";
4
4
  export * from "./core/integrations";
5
+ export * from "./core/molecules";
package/index.js CHANGED
@@ -2,3 +2,4 @@ export * from "./core/atoms";
2
2
  export * from "./core/foundations";
3
3
  export { default as GlobalStyle } from "./core/global/GlobalStyle";
4
4
  export * from "./core/integrations";
5
+ export * from "./core/molecules";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grantbii/design-system",
3
- "version": "1.0.36",
3
+ "version": "1.0.37",
4
4
  "description": "Grantbii's Design System",
5
5
  "homepage": "https://design.grantbii.com",
6
6
  "repository": {
@@ -0,0 +1,8 @@
1
+ import { Modal } from "@/.";
2
+ import type { StoryObj } from "@storybook/nextjs-vite";
3
+ import { Meta } from "@storybook/nextjs-vite";
4
+ declare const meta: Meta<typeof Modal>;
5
+ export default meta;
6
+ type Story = StoryObj<typeof meta>;
7
+ export declare const DesktopVersion: Story;
8
+ export declare const MobileVersion: Story;
@@ -0,0 +1,28 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Button, Modal } from "@/.";
3
+ const meta = {
4
+ title: "Molecules/Modal",
5
+ component: Modal,
6
+ tags: ["autodocs"],
7
+ parameters: {
8
+ layout: "centered",
9
+ },
10
+ };
11
+ export default meta;
12
+ const text = "Grantbii is an AI-powered grant intelligence and matching platform that helps grant seekers effortlessly find, match, prep & apply for the right business grants - maximizing grant funding success with minimal effort. Our platform connects businesses with a trusted Grant Enabler Network - solution providers, consulting experts, and delivery partners - ensuring that every dollar of grant funding leads to real business transformation impact.";
13
+ export const DesktopVersion = {
14
+ args: {
15
+ clickable: (openModal) => (_jsx(Button, { text: "Click to open modal", onClick: openModal })),
16
+ header: "What is Grantbii?",
17
+ content: _jsx("p", { children: text }),
18
+ width: "600px",
19
+ },
20
+ };
21
+ export const MobileVersion = {
22
+ args: {
23
+ clickable: (openModal) => (_jsx(Button, { text: "Click to open modal", onClick: openModal })),
24
+ header: "What is Grantbii?",
25
+ content: _jsx("p", { children: text }),
26
+ isFullScreen: true,
27
+ },
28
+ };