@grantbii/design-system 1.0.50 → 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.
@@ -0,0 +1 @@
1
+ export * from "country-flag-icons/react/3x2";
@@ -0,0 +1 @@
1
+ export * from "country-flag-icons/react/3x2";
@@ -0,0 +1,5 @@
1
+ export * from "@phosphor-icons/react";
2
+ type GrantMatchIconProps = {
3
+ size?: number;
4
+ };
5
+ export declare const GrantMatchIcon: ({ size }: GrantMatchIconProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,4 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ export * from "@phosphor-icons/react";
3
+ import Image from "next/image";
4
+ export const GrantMatchIcon = ({ size = 20 }) => (_jsx(Image, { src: "/icons/grant_match.webp", alt: "Grant Match", width: size, height: size }));
@@ -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";
@@ -1,4 +1,4 @@
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";
@@ -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
+ `;
@@ -1,2 +1,3 @@
1
+ export { default as GrantMatch } from "./GrantMatch";
1
2
  export { default as TallyModal } from "./TallyModal";
2
3
  export { default as YesNoOptions } from "./YesNoOptions";
@@ -1,2 +1,3 @@
1
+ export { default as GrantMatch } from "./GrantMatch";
1
2
  export { default as TallyModal } from "./TallyModal";
2
3
  export { default as YesNoOptions } from "./YesNoOptions";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grantbii/design-system",
3
- "version": "1.0.50",
3
+ "version": "1.0.51",
4
4
  "description": "Grantbii's Design System",
5
5
  "homepage": "https://design.grantbii.com",
6
6
  "repository": {
@@ -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
+ };