@grantbii/design-system 1.0.49 → 1.0.51
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.
- package/core/foundations/flags.d.ts +1 -0
- package/core/foundations/flags.js +1 -0
- package/core/foundations/icons.d.ts +5 -0
- package/core/foundations/icons.js +4 -0
- package/core/foundations/index.d.ts +2 -2
- package/core/foundations/index.js +2 -2
- package/core/molecules/Modal.js +9 -8
- package/core/organisms/GrantMatch.d.ts +21 -0
- package/core/organisms/GrantMatch.js +142 -0
- package/core/organisms/TallyModal.d.ts +10 -0
- package/core/organisms/TallyModal.js +20 -0
- package/core/organisms/index.d.ts +2 -0
- package/core/organisms/index.js +2 -0
- package/package.json +1 -1
- package/stories/molecules/Modal.stories.js +1 -1
- package/stories/organisms/GrantMatch.stories.d.ts +6 -0
- package/stories/organisms/GrantMatch.stories.js +19 -0
- package/stories/organisms/TallyModal.stories.d.ts +14 -0
- package/stories/organisms/TallyModal.stories.js +25 -0
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "country-flag-icons/react/3x2";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "country-flag-icons/react/3x2";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * as Icons from "@phosphor-icons/react";
|
|
2
|
-
export * as Flags from "country-flag-icons/react/3x2";
|
|
3
1
|
export * as Breakpoints from "./breakpoints";
|
|
4
2
|
export * as Colors from "./colors";
|
|
3
|
+
export * as Flags from "./flags";
|
|
4
|
+
export * as Icons from "./icons";
|
|
5
5
|
export type * from "./types";
|
package/core/molecules/Modal.js
CHANGED
|
@@ -3,7 +3,7 @@ import { useCallback, useState } from "react";
|
|
|
3
3
|
import styled from "styled-components";
|
|
4
4
|
import { Button } from "../atoms";
|
|
5
5
|
import { Colors } from "../foundations";
|
|
6
|
-
const Modal = ({ header, content, footer, width, height, isFullScreen, onClickCancel, }) => (_jsx(Overlay, { "$isFullScreen": isFullScreen, children: _jsxs(ModalWindow, { "$isFullScreen": isFullScreen, "$width": width, "$height": height, children: [header ? _jsx(ModalHeader, { children: header }) : _jsx(_Fragment, {}), _jsx(ModalBody, { children:
|
|
6
|
+
const Modal = ({ header, content, footer, width, height, isFullScreen, onClickCancel, }) => (_jsx(Overlay, { "$isFullScreen": isFullScreen, children: _jsxs(ModalWindow, { "$isFullScreen": isFullScreen, "$width": width, "$height": height, children: [header ? _jsx(ModalHeader, { children: header }) : _jsx(_Fragment, {}), _jsx(ModalBody, { children: content }), _jsxs(ModalFooter, { children: [_jsx(CancelButton, { onClick: onClickCancel }), footer ? footer : _jsx(_Fragment, {})] })] }) }));
|
|
7
7
|
export default Modal;
|
|
8
8
|
export const useModal = () => {
|
|
9
9
|
const [showModal, setShowModal] = useState(false);
|
|
@@ -70,14 +70,15 @@ const ModalBody = styled.div `
|
|
|
70
70
|
height: 100%;
|
|
71
71
|
padding-top: 24px;
|
|
72
72
|
overflow-y: auto;
|
|
73
|
-
`;
|
|
74
|
-
const ModalContent = styled.div `
|
|
75
|
-
width: 100%;
|
|
76
|
-
height: 100%;
|
|
77
|
-
min-height: 100px;
|
|
78
73
|
|
|
79
|
-
|
|
80
|
-
|
|
74
|
+
> * {
|
|
75
|
+
width: 100%;
|
|
76
|
+
height: 100%;
|
|
77
|
+
min-height: 100px;
|
|
78
|
+
|
|
79
|
+
padding: 2px 24px;
|
|
80
|
+
border: none;
|
|
81
|
+
}
|
|
81
82
|
`;
|
|
82
83
|
const ModalFooter = styled.div `
|
|
83
84
|
display: flex;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
type MatchQuery = {
|
|
2
|
+
files: File[];
|
|
3
|
+
text: string;
|
|
4
|
+
};
|
|
5
|
+
type GrantMatchProps = {
|
|
6
|
+
query: MatchQuery;
|
|
7
|
+
updateQueryFiles: (newFiles: File[]) => void;
|
|
8
|
+
updateQueryText: (newText: string) => void;
|
|
9
|
+
onPerformGrantMatch: (query: MatchQuery) => void;
|
|
10
|
+
onResetGrantMatch: () => void;
|
|
11
|
+
};
|
|
12
|
+
declare const GrantMatch: ({ query, updateQueryFiles, updateQueryText, onPerformGrantMatch, onResetGrantMatch, }: GrantMatchProps) => import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export default GrantMatch;
|
|
14
|
+
export declare const useMatchQuery: () => {
|
|
15
|
+
query: {
|
|
16
|
+
files: File[];
|
|
17
|
+
text: string;
|
|
18
|
+
};
|
|
19
|
+
updateQueryFiles: (newFiles: File[]) => void;
|
|
20
|
+
updateQueryText: (newText: string) => void;
|
|
21
|
+
};
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import styled from "styled-components";
|
|
4
|
+
import { Badge, Button, Textarea } from "../atoms";
|
|
5
|
+
import { Colors, Icons } from "../foundations";
|
|
6
|
+
import { FileDrop, Modal, useFileDrop, useModal } from "../molecules";
|
|
7
|
+
const GrantMatch = ({ query, updateQueryFiles, updateQueryText, onPerformGrantMatch, onResetGrantMatch, }) => {
|
|
8
|
+
const { showModal, openModal, closeModal } = useModal();
|
|
9
|
+
const { performGrantMatch, resetGrantMatch, removeUploadedFile, removeQueryText, } = useGrantMatch(query, updateQueryFiles, updateQueryText, onPerformGrantMatch, onResetGrantMatch, closeModal);
|
|
10
|
+
return (_jsxs(Container, { children: [_jsx(GrantMatchButtons, { active: isQueryActive(query), onClickMatch: () => openModal(), onClickReset: () => resetGrantMatch() }), isQueryActive(query) ? (_jsx(QueryItems, { uploadedFiles: query.files, removeUploadedFile: removeUploadedFile, queryText: query.text, removeQueryText: removeQueryText })) : (_jsx(_Fragment, {})), showModal ? (_jsx(GrantMatchModal, { activeFiles: query.files, activeText: query.text, performGrantMatch: performGrantMatch, onClickCancel: () => closeModal() })) : (_jsx(_Fragment, {}))] }));
|
|
11
|
+
};
|
|
12
|
+
export default GrantMatch;
|
|
13
|
+
export const useMatchQuery = () => {
|
|
14
|
+
const [files, setFiles] = useState([]);
|
|
15
|
+
const [text, setText] = useState("");
|
|
16
|
+
return {
|
|
17
|
+
query: { files, text },
|
|
18
|
+
updateQueryFiles: (newFiles) => setFiles(newFiles),
|
|
19
|
+
updateQueryText: (newText) => setText(newText),
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
const useGrantMatch = (matchQuery, updateQueryFiles, updateQueryText, onPerformGrantMatch, onResetGrantMatch, closeModal) => {
|
|
23
|
+
const performGrantMatch = (newFiles, newText) => {
|
|
24
|
+
updateQueryFiles(newFiles);
|
|
25
|
+
updateQueryText(newText);
|
|
26
|
+
onPerformGrantMatch({ files: newFiles, text: newText });
|
|
27
|
+
closeModal();
|
|
28
|
+
};
|
|
29
|
+
const resetGrantMatch = () => {
|
|
30
|
+
updateQueryFiles([]);
|
|
31
|
+
updateQueryText("");
|
|
32
|
+
onResetGrantMatch();
|
|
33
|
+
};
|
|
34
|
+
const removeUploadedFile = (fileName) => {
|
|
35
|
+
const newFiles = matchQuery.files.filter((file) => file.name !== fileName);
|
|
36
|
+
updateQueryFiles(newFiles);
|
|
37
|
+
const newQuery = { files: newFiles, text: matchQuery.text };
|
|
38
|
+
if (isQueryActive(newQuery)) {
|
|
39
|
+
onPerformGrantMatch(newQuery);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
onResetGrantMatch();
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
const removeQueryText = () => {
|
|
46
|
+
updateQueryText("");
|
|
47
|
+
const newQuery = { files: matchQuery.files, text: "" };
|
|
48
|
+
if (isQueryActive(newQuery)) {
|
|
49
|
+
onPerformGrantMatch(newQuery);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
onResetGrantMatch();
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
return {
|
|
56
|
+
performGrantMatch,
|
|
57
|
+
resetGrantMatch,
|
|
58
|
+
removeUploadedFile,
|
|
59
|
+
removeQueryText,
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
const isQueryActive = (query) => query.files.length !== 0 || query.text.trim() !== "";
|
|
63
|
+
const Container = styled.div `
|
|
64
|
+
display: flex;
|
|
65
|
+
flex-direction: column;
|
|
66
|
+
gap: 8px;
|
|
67
|
+
|
|
68
|
+
padding: 16px 16px 0px 16px;
|
|
69
|
+
|
|
70
|
+
width: 100%;
|
|
71
|
+
max-width: 100vw;
|
|
72
|
+
`;
|
|
73
|
+
const GrantMatchButtons = ({ active, onClickMatch, onClickReset, }) => (_jsxs(Buttons, { children: [_jsx(GrantMatchButton, { active: active, onClick: onClickMatch }), active ? (_jsx(Button, { text: "Reset", onClick: onClickReset, color: Colors.typography.blackMedium, underline: true })) : (_jsx(_Fragment, {}))] }));
|
|
74
|
+
const Buttons = styled.div `
|
|
75
|
+
display: flex;
|
|
76
|
+
align-items: center;
|
|
77
|
+
gap: 8px;
|
|
78
|
+
`;
|
|
79
|
+
const GrantMatchButton = ({ active, onClick }) => (_jsxs(BaseGrantMatchButton, { type: "button", "$active": active, onClick: onClick, children: [_jsx(Icons.GrantMatchIcon, { size: 20 }), _jsx("p", { children: "Find grants that match your needs" }), _jsx(Icons.MagnifyingGlassIcon, { size: 20 })] }));
|
|
80
|
+
const BaseGrantMatchButton = styled.button `
|
|
81
|
+
display: flex;
|
|
82
|
+
align-items: center;
|
|
83
|
+
gap: 8px;
|
|
84
|
+
|
|
85
|
+
height: 20px;
|
|
86
|
+
padding: 10px 16px;
|
|
87
|
+
border-radius: 200px;
|
|
88
|
+
|
|
89
|
+
font-size: 14px;
|
|
90
|
+
font-weight: 500;
|
|
91
|
+
|
|
92
|
+
color: ${Colors.typography.blackMedium};
|
|
93
|
+
background-color: ${Colors.base.white};
|
|
94
|
+
border: 1px solid
|
|
95
|
+
${({ $active }) => ($active ? Colors.accent.yellow1 : Colors.neutral.grey3)};
|
|
96
|
+
`;
|
|
97
|
+
const QueryItems = ({ uploadedFiles, removeUploadedFile, queryText, removeQueryText, }) => (_jsxs(BaseQueryItems, { children: [uploadedFiles.map((file) => {
|
|
98
|
+
var _a;
|
|
99
|
+
return (_jsx(Badge, { text: file.name, Icon: (_a = FILE_TYPE_ICON_MAP[file.type]) !== null && _a !== void 0 ? _a : Icons.FileIcon, onClickClose: () => removeUploadedFile(file.name), textWidthPixels: 160 }, file.name));
|
|
100
|
+
}), queryText === "" ? (_jsx(_Fragment, {})) : (_jsx(Badge, { text: "Additional Information", Icon: Icons.TextAaIcon, onClickClose: () => removeQueryText(), textWidthPixels: 160 }, "additional-information-query-item"))] }));
|
|
101
|
+
const BaseQueryItems = styled.div `
|
|
102
|
+
display: flex;
|
|
103
|
+
align-items: center;
|
|
104
|
+
gap: 8px;
|
|
105
|
+
|
|
106
|
+
overflow-x: auto;
|
|
107
|
+
|
|
108
|
+
/* hide scrollbar but still allow for scrolling */
|
|
109
|
+
-ms-overflow-style: none;
|
|
110
|
+
scrollbar-width: none;
|
|
111
|
+
::-webkit-scrollbar {
|
|
112
|
+
display: none;
|
|
113
|
+
}
|
|
114
|
+
`;
|
|
115
|
+
const FILE_TYPE_ICON_MAP = {
|
|
116
|
+
"application/pdf": Icons.FilePdfIcon,
|
|
117
|
+
};
|
|
118
|
+
const GrantMatchModal = ({ activeFiles, activeText, performGrantMatch, onClickCancel, }) => {
|
|
119
|
+
const { files, uploadFiles, removeFile } = useFileDrop(activeFiles);
|
|
120
|
+
const [queryText, setQueryText] = useState(activeText);
|
|
121
|
+
const updateQueryText = (newText) => setQueryText(newText);
|
|
122
|
+
return (_jsx(Modal, { header: _jsx(Header, {}), content: _jsx(Content, { files: files, uploadFiles: uploadFiles, removeFile: removeFile, queryText: queryText, updateQueryText: updateQueryText }), footer: _jsx(Button, { text: "Find My Grants", onClick: () => performGrantMatch(files, queryText), backgroundColor: Colors.accent.yellow1 }), onClickCancel: onClickCancel }));
|
|
123
|
+
};
|
|
124
|
+
const Header = () => (_jsxs(BaseHeader, { children: [_jsx(Icons.GrantMatchIcon, { size: 24 }), _jsx("div", { children: "Grant Match" })] }));
|
|
125
|
+
const BaseHeader = styled.div `
|
|
126
|
+
display: flex;
|
|
127
|
+
align-items: center;
|
|
128
|
+
gap: 12px;
|
|
129
|
+
`;
|
|
130
|
+
const Content = ({ files, uploadFiles, removeFile, queryText, updateQueryText, }) => {
|
|
131
|
+
const additionalInformationId = "grant-match-additional-information";
|
|
132
|
+
return (_jsxs(BaseContent, { children: [_jsx(FileDrop, { uploadedFiles: files, uploadFiles: uploadFiles, removeFile: removeFile }), _jsxs(QueryText, { children: [_jsx("label", { htmlFor: additionalInformationId, children: "Additional Information" }), _jsx(Textarea, { id: additionalInformationId, value: queryText, onChange: (event) => updateQueryText(event.target.value) })] })] }));
|
|
133
|
+
};
|
|
134
|
+
const BaseContent = styled.div `
|
|
135
|
+
display: flex;
|
|
136
|
+
flex-direction: column;
|
|
137
|
+
gap: 12px;
|
|
138
|
+
`;
|
|
139
|
+
const QueryText = styled.div `
|
|
140
|
+
display: flex;
|
|
141
|
+
flex-direction: column;
|
|
142
|
+
`;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { MouseEventHandler, ReactNode } from "react";
|
|
2
|
+
type TallyModalProps = {
|
|
3
|
+
header?: ReactNode;
|
|
4
|
+
tallyId: string;
|
|
5
|
+
prefilledFieldsQueryParams?: string;
|
|
6
|
+
isFullScreen?: boolean;
|
|
7
|
+
onClickCancel: MouseEventHandler<HTMLButtonElement>;
|
|
8
|
+
};
|
|
9
|
+
declare const TallyModal: ({ tallyId, prefilledFieldsQueryParams, ...modalProps }: TallyModalProps) => import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export default TallyModal;
|
|
@@ -0,0 +1,20 @@
|
|
|
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 } from "react/jsx-runtime";
|
|
13
|
+
import { Modal } from "../molecules";
|
|
14
|
+
const TallyModal = (_a) => {
|
|
15
|
+
var { tallyId, prefilledFieldsQueryParams } = _a, modalProps = __rest(_a, ["tallyId", "prefilledFieldsQueryParams"]);
|
|
16
|
+
return (_jsx(Modal, Object.assign({}, modalProps, { content: _jsx("iframe", { src: constructIframeSrc(tallyId, prefilledFieldsQueryParams), loading: "lazy" }), width: "640px", height: "480px" })));
|
|
17
|
+
};
|
|
18
|
+
export default TallyModal;
|
|
19
|
+
const constructIframeSrc = (tallyId, prefilledFieldsQueryParams) => `https://tally.so/embed/${tallyId}?${TALLY_QUERIES}${prefilledFieldsQueryParams ? `&${prefilledFieldsQueryParams}` : ""}`;
|
|
20
|
+
const TALLY_QUERIES = "alignLeft=1&hideTitle=1&transparentBackground=1&dynamicHeight=0";
|
package/core/organisms/index.js
CHANGED
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
2
2
|
import { Button, Modal, useModal } from "@/.";
|
|
3
3
|
const ModalExample = (props) => {
|
|
4
4
|
const { showModal, openModal, closeModal } = useModal();
|
|
5
|
-
return (_jsxs(_Fragment, { children: [_jsx(Button, { text: "Click to open modal", onClick: openModal }), showModal ? (_jsx(Modal, Object.assign({}, props, { onClickCancel: () => closeModal() }))) : (_jsx(_Fragment, {}))] }));
|
|
5
|
+
return (_jsxs(_Fragment, { children: [_jsx(Button, { text: "Click to open modal", onClick: () => openModal() }), showModal ? (_jsx(Modal, Object.assign({}, props, { onClickCancel: () => closeModal() }))) : (_jsx(_Fragment, {}))] }));
|
|
6
6
|
};
|
|
7
7
|
const meta = {
|
|
8
8
|
title: "Molecules/Modal",
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Meta, StoryObj } from "@storybook/nextjs-vite";
|
|
2
|
+
declare const GrantMatchExample: () => import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
declare const meta: Meta<typeof GrantMatchExample>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof meta>;
|
|
6
|
+
export declare const Example: Story;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { GrantMatch } from "@/.";
|
|
3
|
+
import { useMatchQuery } from "@/core/organisms/GrantMatch";
|
|
4
|
+
const GrantMatchExample = () => {
|
|
5
|
+
const matchQuery = useMatchQuery();
|
|
6
|
+
return (_jsx(GrantMatch, Object.assign({}, matchQuery, { onPerformGrantMatch: () => console.log("finding grants..."), onResetGrantMatch: () => console.log("resetting grant match...") })));
|
|
7
|
+
};
|
|
8
|
+
const meta = {
|
|
9
|
+
title: "Organisms/Grant Match",
|
|
10
|
+
component: GrantMatchExample,
|
|
11
|
+
tags: ["autodocs"],
|
|
12
|
+
parameters: {
|
|
13
|
+
layout: "centered",
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
export default meta;
|
|
17
|
+
export const Example = {
|
|
18
|
+
args: {},
|
|
19
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Meta, StoryObj } from "@storybook/nextjs-vite";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
type TallyModalExampleProps = {
|
|
4
|
+
header?: ReactNode;
|
|
5
|
+
tallyId: string;
|
|
6
|
+
prefilledFieldsQueryParams?: string;
|
|
7
|
+
isFullScreen?: boolean;
|
|
8
|
+
};
|
|
9
|
+
declare const TallyModalExample: (props: TallyModalExampleProps) => import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
declare const meta: Meta<typeof TallyModalExample>;
|
|
11
|
+
export default meta;
|
|
12
|
+
type Story = StoryObj<typeof meta>;
|
|
13
|
+
export declare const PopUp: Story;
|
|
14
|
+
export declare const FullScreen: Story;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Button, TallyModal, useModal } from "@/.";
|
|
3
|
+
const TallyModalExample = (props) => {
|
|
4
|
+
const { showModal, openModal, closeModal } = useModal();
|
|
5
|
+
return (_jsxs(_Fragment, { children: [_jsx(Button, { text: "Click to open modal", onClick: () => openModal() }), showModal ? (_jsx(TallyModal, Object.assign({}, props, { onClickCancel: () => closeModal() }))) : (_jsx(_Fragment, {}))] }));
|
|
6
|
+
};
|
|
7
|
+
const meta = {
|
|
8
|
+
title: "Organisms/Tally Modal",
|
|
9
|
+
component: TallyModalExample,
|
|
10
|
+
tags: ["autodocs"],
|
|
11
|
+
parameters: {
|
|
12
|
+
layout: "centered",
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
export default meta;
|
|
16
|
+
const baseArgs = {
|
|
17
|
+
header: "Apply with us",
|
|
18
|
+
tallyId: "3jAj5Q",
|
|
19
|
+
};
|
|
20
|
+
export const PopUp = {
|
|
21
|
+
args: baseArgs,
|
|
22
|
+
};
|
|
23
|
+
export const FullScreen = {
|
|
24
|
+
args: Object.assign(Object.assign({}, baseArgs), { isFullScreen: true }),
|
|
25
|
+
};
|