@grantbii/design-system 1.0.50 → 1.0.52
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/organisms/GrantMatch.d.ts +18 -0
- package/core/organisms/GrantMatch.js +143 -0
- package/core/organisms/YesNoOptions.js +1 -1
- package/core/organisms/index.d.ts +1 -0
- package/core/organisms/index.js +1 -0
- package/package.json +2 -2
- package/stories/molecules/RadioButtons.stories.js +1 -1
- package/stories/organisms/GrantMatch.stories.d.ts +6 -0
- package/stories/organisms/GrantMatch.stories.js +23 -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";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { GrantMatchQuery } from "@grantbii/ui-base/match/models";
|
|
2
|
+
type GrantMatchProps = {
|
|
3
|
+
query: GrantMatchQuery;
|
|
4
|
+
updateQueryFiles: (newFiles: File[]) => void;
|
|
5
|
+
updateQueryText: (newText: string) => void;
|
|
6
|
+
onPerformGrantMatch: (query: GrantMatchQuery) => void;
|
|
7
|
+
onResetGrantMatch: () => void;
|
|
8
|
+
};
|
|
9
|
+
declare const GrantMatch: ({ query, updateQueryFiles, updateQueryText, onPerformGrantMatch, onResetGrantMatch, }: GrantMatchProps) => import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export default GrantMatch;
|
|
11
|
+
export declare const useMatchQuery: () => {
|
|
12
|
+
query: {
|
|
13
|
+
files: File[];
|
|
14
|
+
text: string;
|
|
15
|
+
};
|
|
16
|
+
updateQueryFiles: (newFiles: File[]) => void;
|
|
17
|
+
updateQueryText: (newText: string) => void;
|
|
18
|
+
};
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { isGrantMatchActive } from "@grantbii/ui-base/match/mappings";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import styled from "styled-components";
|
|
5
|
+
import { Badge, Button, Textarea } from "../atoms";
|
|
6
|
+
import { Colors, Icons } from "../foundations";
|
|
7
|
+
import { FileDrop, Modal, useFileDrop, useModal } from "../molecules";
|
|
8
|
+
const GrantMatch = ({ query, updateQueryFiles, updateQueryText, onPerformGrantMatch, onResetGrantMatch, }) => {
|
|
9
|
+
const { showModal, openModal, closeModal } = useModal();
|
|
10
|
+
const { performGrantMatch, resetGrantMatch, removeUploadedFile, removeQueryText, } = useGrantMatch(query, updateQueryFiles, updateQueryText, onPerformGrantMatch, onResetGrantMatch, closeModal);
|
|
11
|
+
const isActive = isGrantMatchActive(query);
|
|
12
|
+
return (_jsxs(Container, { children: [_jsx(GrantMatchButtons, { isActive: isActive, onClickMatch: () => openModal(), onClickReset: () => resetGrantMatch() }), isActive ? (_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, {}))] }));
|
|
13
|
+
};
|
|
14
|
+
export default GrantMatch;
|
|
15
|
+
export const useMatchQuery = () => {
|
|
16
|
+
const [files, setFiles] = useState([]);
|
|
17
|
+
const [text, setText] = useState("");
|
|
18
|
+
return {
|
|
19
|
+
query: { files, text },
|
|
20
|
+
updateQueryFiles: (newFiles) => setFiles(newFiles),
|
|
21
|
+
updateQueryText: (newText) => setText(newText),
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
const useGrantMatch = (query, updateQueryFiles, updateQueryText, onPerformGrantMatch, onResetGrantMatch, closeModal) => {
|
|
25
|
+
const performGrantMatch = (newFiles, newText) => {
|
|
26
|
+
updateQueryFiles(newFiles);
|
|
27
|
+
updateQueryText(newText);
|
|
28
|
+
onPerformGrantMatch({ files: newFiles, text: newText });
|
|
29
|
+
closeModal();
|
|
30
|
+
};
|
|
31
|
+
const resetGrantMatch = () => {
|
|
32
|
+
updateQueryFiles([]);
|
|
33
|
+
updateQueryText("");
|
|
34
|
+
onResetGrantMatch();
|
|
35
|
+
};
|
|
36
|
+
const removeUploadedFile = (fileName) => {
|
|
37
|
+
const newFiles = query.files.filter((file) => file.name !== fileName);
|
|
38
|
+
updateQueryFiles(newFiles);
|
|
39
|
+
const newQuery = { files: newFiles, text: query.text };
|
|
40
|
+
if (isGrantMatchActive(newQuery)) {
|
|
41
|
+
onPerformGrantMatch(newQuery);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
onResetGrantMatch();
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
const removeQueryText = () => {
|
|
48
|
+
updateQueryText("");
|
|
49
|
+
const newQuery = { files: query.files, text: "" };
|
|
50
|
+
if (isGrantMatchActive(newQuery)) {
|
|
51
|
+
onPerformGrantMatch(newQuery);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
onResetGrantMatch();
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
return {
|
|
58
|
+
performGrantMatch,
|
|
59
|
+
resetGrantMatch,
|
|
60
|
+
removeUploadedFile,
|
|
61
|
+
removeQueryText,
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
const Container = styled.div `
|
|
65
|
+
display: flex;
|
|
66
|
+
flex-direction: column;
|
|
67
|
+
gap: 8px;
|
|
68
|
+
|
|
69
|
+
padding: 16px 16px 0px 16px;
|
|
70
|
+
|
|
71
|
+
width: 100%;
|
|
72
|
+
max-width: 100vw;
|
|
73
|
+
`;
|
|
74
|
+
const GrantMatchButtons = ({ isActive, onClickMatch, onClickReset, }) => (_jsxs(Buttons, { children: [_jsx(GrantMatchButton, { isActive: isActive, onClick: onClickMatch }), isActive ? (_jsx(Button, { text: "Reset", onClick: onClickReset, color: Colors.typography.blackMedium, underline: true })) : (_jsx(_Fragment, {}))] }));
|
|
75
|
+
const Buttons = styled.div `
|
|
76
|
+
display: flex;
|
|
77
|
+
align-items: center;
|
|
78
|
+
gap: 8px;
|
|
79
|
+
`;
|
|
80
|
+
const GrantMatchButton = ({ isActive, onClick }) => (_jsxs(BaseGrantMatchButton, { type: "button", "$isActive": isActive, onClick: onClick, children: [_jsx(Icons.GrantMatchIcon, { size: 20 }), _jsx("p", { children: "Find grants that match your needs" }), _jsx(Icons.MagnifyingGlassIcon, { size: 20 })] }));
|
|
81
|
+
const BaseGrantMatchButton = styled.button `
|
|
82
|
+
display: flex;
|
|
83
|
+
align-items: center;
|
|
84
|
+
gap: 8px;
|
|
85
|
+
|
|
86
|
+
height: 20px;
|
|
87
|
+
padding: 10px 16px;
|
|
88
|
+
border-radius: 200px;
|
|
89
|
+
|
|
90
|
+
font-size: 14px;
|
|
91
|
+
font-weight: 500;
|
|
92
|
+
|
|
93
|
+
color: ${Colors.typography.blackMedium};
|
|
94
|
+
background-color: ${Colors.base.white};
|
|
95
|
+
border: 1px solid
|
|
96
|
+
${({ $isActive }) => $isActive ? Colors.accent.yellow1 : Colors.neutral.grey3};
|
|
97
|
+
`;
|
|
98
|
+
const QueryItems = ({ uploadedFiles, removeUploadedFile, queryText, removeQueryText, }) => (_jsxs(BaseQueryItems, { children: [uploadedFiles.map((file) => {
|
|
99
|
+
var _a;
|
|
100
|
+
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));
|
|
101
|
+
}), queryText === "" ? (_jsx(_Fragment, {})) : (_jsx(Badge, { text: "Additional Information", Icon: Icons.TextAaIcon, onClickClose: () => removeQueryText(), textWidthPixels: 160 }, "additional-information-query-item"))] }));
|
|
102
|
+
const BaseQueryItems = styled.div `
|
|
103
|
+
display: flex;
|
|
104
|
+
align-items: center;
|
|
105
|
+
gap: 8px;
|
|
106
|
+
|
|
107
|
+
overflow-x: auto;
|
|
108
|
+
|
|
109
|
+
/* hide scrollbar but still allow for scrolling */
|
|
110
|
+
-ms-overflow-style: none;
|
|
111
|
+
scrollbar-width: none;
|
|
112
|
+
::-webkit-scrollbar {
|
|
113
|
+
display: none;
|
|
114
|
+
}
|
|
115
|
+
`;
|
|
116
|
+
const FILE_TYPE_ICON_MAP = {
|
|
117
|
+
"application/pdf": Icons.FilePdfIcon,
|
|
118
|
+
};
|
|
119
|
+
const GrantMatchModal = ({ activeFiles, activeText, performGrantMatch, onClickCancel, }) => {
|
|
120
|
+
const { files, uploadFiles, removeFile } = useFileDrop(activeFiles);
|
|
121
|
+
const [queryText, setQueryText] = useState(activeText);
|
|
122
|
+
const updateQueryText = (newText) => setQueryText(newText);
|
|
123
|
+
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 }));
|
|
124
|
+
};
|
|
125
|
+
const Header = () => (_jsxs(BaseHeader, { children: [_jsx(Icons.GrantMatchIcon, { size: 24 }), _jsx("div", { children: "Grant Match" })] }));
|
|
126
|
+
const BaseHeader = styled.div `
|
|
127
|
+
display: flex;
|
|
128
|
+
align-items: center;
|
|
129
|
+
gap: 12px;
|
|
130
|
+
`;
|
|
131
|
+
const Content = ({ files, uploadFiles, removeFile, queryText, updateQueryText, }) => {
|
|
132
|
+
const additionalInformationId = "grant-match-additional-information";
|
|
133
|
+
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) })] })] }));
|
|
134
|
+
};
|
|
135
|
+
const BaseContent = styled.div `
|
|
136
|
+
display: flex;
|
|
137
|
+
flex-direction: column;
|
|
138
|
+
gap: 12px;
|
|
139
|
+
`;
|
|
140
|
+
const QueryText = styled.div `
|
|
141
|
+
display: flex;
|
|
142
|
+
flex-direction: column;
|
|
143
|
+
`;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { LogicOption } from "@grantbii/ui-base/grant/enums";
|
|
2
3
|
import styled from "styled-components";
|
|
3
4
|
import { RadioButton } from "../atoms";
|
|
4
|
-
import { LogicOption } from "@grantbii/ui-base/enums";
|
|
5
5
|
const YesNoOptions = ({ name, yesProps, noProps, unsureProps, }) => (_jsxs(RadioGroup, { children: [_jsx(RadioButton, Object.assign({}, yesProps, { id: `${name}-yes`, label: LogicOption.YES, value: LogicOption.YES, name: name })), _jsx(RadioButton, Object.assign({}, noProps, { id: `${name}-no`, label: LogicOption.NO, value: LogicOption.NO, name: name })), unsureProps ? (_jsx(RadioButton, Object.assign({}, unsureProps, { id: `${name}-unsure`, label: LogicOption.UNSURE, value: LogicOption.UNSURE, name: name }))) : (_jsx(_Fragment, {}))] }));
|
|
6
6
|
export default YesNoOptions;
|
|
7
7
|
const RadioGroup = styled.div `
|
package/core/organisms/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@grantbii/design-system",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.52",
|
|
4
4
|
"description": "Grantbii's Design System",
|
|
5
5
|
"homepage": "https://design.grantbii.com",
|
|
6
6
|
"repository": {
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"build-storybook": "storybook build"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@grantbii/ui-base": "1.0.
|
|
21
|
+
"@grantbii/ui-base": "1.0.14",
|
|
22
22
|
"@phosphor-icons/react": "^2.1.10",
|
|
23
23
|
"country-flag-icons": "^1.5.19",
|
|
24
24
|
"next": "^15.3.5",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { RadioButtons } from "@/.";
|
|
3
|
-
import { Location } from "@grantbii/ui-base/enums";
|
|
3
|
+
import { Location } from "@grantbii/ui-base/grant/enums";
|
|
4
4
|
import { useState } from "react";
|
|
5
5
|
const RadioButtonsExample = ({ controlled }) => {
|
|
6
6
|
const [location, setLocation] = useState("");
|
|
@@ -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,23 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { GrantMatch } from "@/.";
|
|
3
|
+
import { useMatchQuery } from "@/core/organisms/GrantMatch";
|
|
4
|
+
import styled from "styled-components";
|
|
5
|
+
const GrantMatchExample = () => {
|
|
6
|
+
const matchQuery = useMatchQuery();
|
|
7
|
+
return (_jsx(Container, { children: _jsx(GrantMatch, Object.assign({}, matchQuery, { onPerformGrantMatch: () => console.log("finding grants..."), onResetGrantMatch: () => console.log("resetting grant match...") })) }));
|
|
8
|
+
};
|
|
9
|
+
const Container = styled.div `
|
|
10
|
+
width: 90vw;
|
|
11
|
+
`;
|
|
12
|
+
const meta = {
|
|
13
|
+
title: "Organisms/Grant Match",
|
|
14
|
+
component: GrantMatchExample,
|
|
15
|
+
tags: ["autodocs"],
|
|
16
|
+
parameters: {
|
|
17
|
+
layout: "centered",
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
export default meta;
|
|
21
|
+
export const Example = {
|
|
22
|
+
args: {},
|
|
23
|
+
};
|