@grantbii/design-system 1.0.35 → 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.
@@ -1,11 +1,12 @@
1
- import { JSX, MouseEventHandler } from "react";
1
+ import { ComponentType, MouseEventHandler } from "react";
2
+ import { Icons } from "../foundations";
2
3
  type BadgeProps = {
3
4
  text: string;
4
- icon?: JSX.Element;
5
+ Icon?: ComponentType<Icons.IconProps>;
5
6
  onClickClose?: MouseEventHandler<HTMLButtonElement>;
6
7
  textWidthPixels?: number;
7
8
  backgroundColor?: string;
8
9
  color?: string;
9
10
  };
10
- declare const Badge: ({ icon, text, onClickClose, textWidthPixels, backgroundColor, color, }: BadgeProps) => import("react/jsx-runtime").JSX.Element;
11
+ declare const Badge: ({ Icon, text, onClickClose, textWidthPixels, backgroundColor, color, }: BadgeProps) => import("react/jsx-runtime").JSX.Element;
11
12
  export default Badge;
@@ -1,7 +1,7 @@
1
- import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import styled from "styled-components";
3
3
  import { Colors, Icons } from "../foundations";
4
- const Badge = ({ icon, text, onClickClose, textWidthPixels, backgroundColor, color, }) => (_jsxs(BaseBadge, { "$backgroundColor": backgroundColor, "$color": color, children: [icon ? icon : _jsx(_Fragment, {}), _jsx(BadgeText, { "$widthPixels": textWidthPixels, children: text }), onClickClose ? (_jsx(Button, { type: "button", onClick: onClickClose, children: _jsx(Icons.XIcon, { size: 12 }) })) : (_jsx(_Fragment, {}))] }));
4
+ const Badge = ({ Icon, text, onClickClose, textWidthPixels, backgroundColor, color, }) => (_jsxs(BaseBadge, { "$backgroundColor": backgroundColor, "$color": color, children: [Icon ? _jsx(Icon, { color: color, size: 20 }) : _jsx(_Fragment, {}), _jsx(BadgeText, { "$widthPixels": textWidthPixels, children: text }), onClickClose ? (_jsx(Button, { type: "button", onClick: onClickClose, children: _jsx(Icons.XIcon, { size: 12 }) })) : (_jsx(_Fragment, {}))] }));
5
5
  export default Badge;
6
6
  const BaseBadge = styled.div `
7
7
  display: flex;
@@ -1,13 +1,14 @@
1
- import { JSX, MouseEventHandler } from "react";
1
+ import { ComponentType, MouseEventHandler } from "react";
2
+ import { Icons } from "../foundations";
2
3
  type ButtonProps = {
3
4
  text: string;
4
5
  disabled?: boolean;
5
6
  onClick: MouseEventHandler<HTMLButtonElement>;
6
7
  type?: "button" | "submit" | "reset";
7
- leftIcon?: JSX.Element;
8
- rightIcon?: JSX.Element;
8
+ LeftIcon?: ComponentType<Icons.IconProps>;
9
+ RightIcon?: ComponentType<Icons.IconProps>;
9
10
  backgroundColor?: string;
10
11
  color?: string;
11
12
  };
12
- declare const Button: ({ text, onClick, disabled, leftIcon, rightIcon, backgroundColor, color, type, }: ButtonProps) => import("react/jsx-runtime").JSX.Element;
13
+ declare const Button: ({ text, onClick, disabled, LeftIcon, RightIcon, backgroundColor, color, type, }: ButtonProps) => import("react/jsx-runtime").JSX.Element;
13
14
  export default Button;
@@ -1,7 +1,7 @@
1
- import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import styled from "styled-components";
3
3
  import { ButtonStyle } from "./shared";
4
- const Button = ({ text, onClick, disabled, leftIcon, rightIcon, backgroundColor, color, type = "button", }) => (_jsx("button", { type: type, onClick: onClick, disabled: disabled, children: _jsxs(BaseButton, { "$backgroundColor": backgroundColor, "$color": color, children: [leftIcon ? leftIcon : _jsx(_Fragment, {}), _jsx("p", { children: text }), rightIcon ? rightIcon : _jsx(_Fragment, {})] }) }));
4
+ const Button = ({ text, onClick, disabled, LeftIcon, RightIcon, backgroundColor, color, type = "button", }) => (_jsx("button", { type: type, onClick: onClick, disabled: disabled, children: _jsxs(BaseButton, { "$backgroundColor": backgroundColor, "$color": color, children: [LeftIcon ? _jsx(LeftIcon, { color: color, size: 20 }) : _jsx(_Fragment, {}), _jsx("p", { children: text }), RightIcon ? _jsx(RightIcon, { color: color, size: 20 }) : _jsx(_Fragment, {})] }) }));
5
5
  export default Button;
6
6
  const BaseButton = styled.div `
7
7
  ${ButtonStyle}
@@ -1,11 +1,12 @@
1
- import { HTMLAttributeAnchorTarget, JSX } from "react";
1
+ import { ComponentType, HTMLAttributeAnchorTarget } from "react";
2
+ import { Icons } from "../foundations";
2
3
  type LinkButtonProps = {
3
4
  text: string;
4
5
  href: string;
5
6
  disabled?: boolean;
6
7
  target?: HTMLAttributeAnchorTarget;
7
- leftIcon?: JSX.Element;
8
- rightIcon?: JSX.Element;
8
+ LeftIcon?: ComponentType<Icons.IconProps>;
9
+ RightIcon?: ComponentType<Icons.IconProps>;
9
10
  backgroundColor?: string;
10
11
  color?: string;
11
12
  };
@@ -18,7 +18,7 @@ const LinkButton = (_a) => {
18
18
  return disabled ? (_jsx(Content, Object.assign({}, contentProps))) : (_jsx(Link, { href: href, target: target, children: _jsx(Content, Object.assign({}, contentProps)) }));
19
19
  };
20
20
  export default LinkButton;
21
- const Content = ({ text, leftIcon, rightIcon, backgroundColor, color, }) => (_jsxs(BaseLinkButton, { "$backgroundColor": backgroundColor, "$color": color, children: [leftIcon ? leftIcon : _jsx(_Fragment, {}), _jsx("p", { children: text }), rightIcon ? rightIcon : _jsx(_Fragment, {})] }));
21
+ const Content = ({ text, LeftIcon, RightIcon, backgroundColor, color, }) => (_jsxs(BaseLinkButton, { "$backgroundColor": backgroundColor, "$color": color, children: [LeftIcon ? _jsx(LeftIcon, { color: color, size: 20 }) : _jsx(_Fragment, {}), _jsx("p", { children: text }), RightIcon ? _jsx(RightIcon, { color: color, size: 20 }) : _jsx(_Fragment, {})] }));
22
22
  const BaseLinkButton = styled.div `
23
23
  ${ButtonStyle}
24
24
  `;
@@ -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.35",
3
+ "version": "1.0.37",
4
4
  "description": "Grantbii's Design System",
5
5
  "homepage": "https://design.grantbii.com",
6
6
  "repository": {
@@ -1,4 +1,3 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
1
  import { Badge, Icons } from "@/.";
3
2
  const meta = {
4
3
  title: "Atoms/Badge",
@@ -11,7 +10,6 @@ const meta = {
11
10
  export default meta;
12
11
  const defaultText = "Badge";
13
12
  const longText = "the quick brown fox jumps over the lazy dog";
14
- const icon = _jsx(Icons.SmileyXEyesIcon, { size: 20 });
15
13
  const onClickClose = () => alert("You have closed the badge.");
16
14
  export const TextOnly = {
17
15
  args: {
@@ -20,7 +18,7 @@ export const TextOnly = {
20
18
  };
21
19
  export const Icon = {
22
20
  args: {
23
- icon: icon,
21
+ Icon: Icons.SmileyXEyesIcon,
24
22
  text: defaultText,
25
23
  },
26
24
  };
@@ -38,7 +36,7 @@ export const LongText = {
38
36
  };
39
37
  export const Everything = {
40
38
  args: {
41
- icon: icon,
39
+ Icon: Icons.SmileyXEyesIcon,
42
40
  text: longText,
43
41
  textWidthPixels: 160,
44
42
  onClickClose: onClickClose,
@@ -1,4 +1,3 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
1
  import { Button, Icons } from "@/.";
3
2
  const meta = {
4
3
  title: "Atoms/Button",
@@ -17,13 +16,13 @@ export const TextOnly = {
17
16
  args: baseArgs,
18
17
  };
19
18
  export const LeftIcon = {
20
- args: Object.assign(Object.assign({}, baseArgs), { leftIcon: _jsx(Icons.PlusIcon, { size: 14 }) }),
19
+ args: Object.assign(Object.assign({}, baseArgs), { LeftIcon: Icons.PlusIcon }),
21
20
  };
22
21
  export const RightIcon = {
23
- args: Object.assign(Object.assign({}, baseArgs), { rightIcon: _jsx(Icons.MinusIcon, { size: 14 }) }),
22
+ args: Object.assign(Object.assign({}, baseArgs), { RightIcon: Icons.MinusIcon }),
24
23
  };
25
24
  export const BothIcons = {
26
- args: Object.assign(Object.assign({}, baseArgs), { leftIcon: _jsx(Icons.SmileyXEyesIcon, { size: 20 }), rightIcon: _jsx(Icons.SmileyMeltingIcon, { size: 20 }) }),
25
+ args: Object.assign(Object.assign({}, baseArgs), { LeftIcon: Icons.SmileyXEyesIcon, RightIcon: Icons.SmileyMeltingIcon }),
27
26
  };
28
27
  export const Wide = {
29
28
  args: Object.assign({}, baseArgs),
@@ -1,4 +1,3 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
1
  import { Icons, LinkButton } from "@/.";
3
2
  const meta = {
4
3
  title: "Atoms/LinkButton",
@@ -18,11 +17,11 @@ export const TextOnly = {
18
17
  args: baseArgs,
19
18
  };
20
19
  export const LeftIcon = {
21
- args: Object.assign(Object.assign({}, baseArgs), { leftIcon: _jsx(Icons.PlusIcon, { size: 14 }) }),
20
+ args: Object.assign(Object.assign({}, baseArgs), { LeftIcon: Icons.PlusIcon }),
22
21
  };
23
22
  export const RightIcon = {
24
- args: Object.assign(Object.assign({}, baseArgs), { rightIcon: _jsx(Icons.MinusIcon, { size: 14 }) }),
23
+ args: Object.assign(Object.assign({}, baseArgs), { RightIcon: Icons.MinusIcon }),
25
24
  };
26
25
  export const BothIcons = {
27
- args: Object.assign(Object.assign({}, baseArgs), { leftIcon: _jsx(Icons.SmileyXEyesIcon, { size: 20 }), rightIcon: _jsx(Icons.SmileyMeltingIcon, { size: 20 }) }),
26
+ args: Object.assign(Object.assign({}, baseArgs), { LeftIcon: Icons.SmileyXEyesIcon, RightIcon: Icons.SmileyMeltingIcon }),
28
27
  };
@@ -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
+ };