@grantbii/design-system 1.0.71 → 1.0.73
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/atoms/Badge.js +9 -2
- package/core/atoms/Checkbox.js +2 -2
- package/core/atoms/RadioButton.js +2 -2
- package/core/atoms/shared.d.ts +1 -1
- package/core/atoms/shared.js +1 -1
- package/core/organisms/GrantMatch/ActiveQueryFiles.d.ts +2 -0
- package/core/organisms/GrantMatch/ActiveQueryFiles.js +51 -0
- package/core/organisms/GrantMatch/GrantMatchModal.d.ts +2 -0
- package/core/organisms/GrantMatch/GrantMatchModal.js +35 -0
- package/core/organisms/GrantMatch/SearchBar.d.ts +2 -0
- package/core/organisms/GrantMatch/SearchBar.js +133 -0
- package/core/organisms/GrantMatch/context.d.ts +12 -0
- package/core/organisms/GrantMatch/context.js +9 -0
- package/core/organisms/GrantMatch/index.js +49 -0
- package/package.json +7 -7
- package/stories/organisms/GrantMatch.stories.js +2 -2
- package/tsconfig.tsbuildinfo +1 -1
- package/core/organisms/GrantMatch.js +0 -209
- /package/core/organisms/{GrantMatch.d.ts → GrantMatch/index.d.ts} +0 -0
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
-
import { checkGrantMatchActive } from "@grantbii/ui-base/match/mappings";
|
|
4
|
-
import { useState } from "react";
|
|
5
|
-
import styled from "styled-components";
|
|
6
|
-
import { Badge, Button, Textarea } from "../atoms";
|
|
7
|
-
import { Colors, Icons, Responsive, Typography } from "../foundations";
|
|
8
|
-
import { BigScreenOnly, SmallScreenOnly } from "../foundations/responsive";
|
|
9
|
-
import { FileDrop, Modal, useFileDrop, useModal } from "../molecules";
|
|
10
|
-
const GrantMatch = ({ activeQuery, updateActiveQuery }) => {
|
|
11
|
-
const { showModal, openModal, closeModal } = useModal();
|
|
12
|
-
const [queryText, setQueryText] = useState(activeQuery.text);
|
|
13
|
-
const updateQueryText = (newText) => setQueryText(newText);
|
|
14
|
-
return (_jsxs(BaseGrantMatch, { children: [_jsx(GrantMatchActions, { activeQuery: activeQuery, updateActiveQuery: updateActiveQuery, queryText: queryText, updateQueryText: updateQueryText, openModal: openModal }), activeQuery.files.length > 0 ? (_jsxs(ActiveQueryRow, { children: [_jsx(ActiveQueryFiles, { activeQuery: activeQuery, updateActiveQuery: updateActiveQuery }), _jsx(SmallScreenOnly, { children: _jsx(ResetButton, { updateActiveQuery: updateActiveQuery, updateQueryText: updateQueryText }) })] })) : (_jsx(_Fragment, {})), showModal ? (_jsx(GrantMatchModal, { activeQuery: activeQuery, updateActiveQuery: updateActiveQuery, queryText: queryText, updateQueryText: updateQueryText, closeModal: closeModal })) : (_jsx(_Fragment, {}))] }));
|
|
15
|
-
};
|
|
16
|
-
export default GrantMatch;
|
|
17
|
-
export const useGrantMatchActiveQuery = (performGrantMatch, resetGrantMatch) => {
|
|
18
|
-
const [activeQuery, setActiveQuery] = useState({
|
|
19
|
-
files: [],
|
|
20
|
-
text: "",
|
|
21
|
-
});
|
|
22
|
-
const updateActiveQuery = (newQuery) => {
|
|
23
|
-
setActiveQuery(Object.assign({}, newQuery));
|
|
24
|
-
if (checkGrantMatchActive(newQuery)) {
|
|
25
|
-
performGrantMatch(newQuery);
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
resetGrantMatch();
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
return { activeQuery, updateActiveQuery };
|
|
32
|
-
};
|
|
33
|
-
const BaseGrantMatch = styled.div `
|
|
34
|
-
display: flex;
|
|
35
|
-
flex-direction: column;
|
|
36
|
-
gap: 8px;
|
|
37
|
-
|
|
38
|
-
width: 100%;
|
|
39
|
-
max-width: 100vw;
|
|
40
|
-
`;
|
|
41
|
-
const GrantMatchActions = ({ activeQuery, updateActiveQuery, queryText, updateQueryText, openModal, }) => {
|
|
42
|
-
const isActive = checkGrantMatchActive(activeQuery);
|
|
43
|
-
const onClickSearch = () => updateActiveQuery({ files: activeQuery.files, text: queryText });
|
|
44
|
-
return (_jsxs(Actions, { children: [_jsxs(SearchBar, { "$isActive": isActive, children: [_jsx(Input, { value: queryText, onChange: (event) => updateQueryText(event.target.value), placeholder: "Find grants that match your needs" }), _jsxs(SearchButtons, { children: [_jsx(SearchButton, { onClick: onClickSearch }), _jsx(FileDropButton, { onClick: () => openModal() })] })] }), isActive ? (_jsx(BigScreenOnly, { children: _jsx(ResetButton, { updateActiveQuery: updateActiveQuery, updateQueryText: updateQueryText }) })) : (_jsx(_Fragment, {}))] }));
|
|
45
|
-
};
|
|
46
|
-
const Actions = styled.div `
|
|
47
|
-
display: flex;
|
|
48
|
-
align-items: center;
|
|
49
|
-
gap: 8px;
|
|
50
|
-
`;
|
|
51
|
-
const SearchBar = styled.div `
|
|
52
|
-
display: flex;
|
|
53
|
-
align-items: center;
|
|
54
|
-
justify-content: space-between;
|
|
55
|
-
|
|
56
|
-
padding: 6px 16px;
|
|
57
|
-
|
|
58
|
-
background-color: ${Colors.base.white};
|
|
59
|
-
color: ${Colors.typography.blackHigh};
|
|
60
|
-
|
|
61
|
-
border: 1px solid
|
|
62
|
-
${({ $isActive }) => $isActive ? Colors.accent.yellow1 : Colors.neutral.grey3};
|
|
63
|
-
border-radius: 12px;
|
|
64
|
-
|
|
65
|
-
@media (width < ${Responsive.WIDTH_BREAKPOINTS.laptop}) {
|
|
66
|
-
gap: 8px;
|
|
67
|
-
width: 100%;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
@media (width >= ${Responsive.WIDTH_BREAKPOINTS.laptop}) {
|
|
71
|
-
gap: 16px;
|
|
72
|
-
width: auto;
|
|
73
|
-
}
|
|
74
|
-
`;
|
|
75
|
-
const Input = styled.input `
|
|
76
|
-
width: 280px;
|
|
77
|
-
border: none;
|
|
78
|
-
outline: none;
|
|
79
|
-
`;
|
|
80
|
-
const SearchButtons = styled.div `
|
|
81
|
-
display: flex;
|
|
82
|
-
align-items: center;
|
|
83
|
-
|
|
84
|
-
@media (width < ${Responsive.WIDTH_BREAKPOINTS.laptop}) {
|
|
85
|
-
gap: 8px;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
@media (width >= ${Responsive.WIDTH_BREAKPOINTS.laptop}) {
|
|
89
|
-
gap: 16px;
|
|
90
|
-
}
|
|
91
|
-
`;
|
|
92
|
-
const SearchButton = ({ onClick }) => (_jsx(BaseSearchButton, { type: "button", onClick: onClick, children: _jsx(Icons.MagnifyingGlassIcon, { size: 16, color: Colors.neutral.grey1 }) }));
|
|
93
|
-
const BaseSearchButton = styled.button `
|
|
94
|
-
display: flex;
|
|
95
|
-
align-items: center;
|
|
96
|
-
justify-content: center;
|
|
97
|
-
|
|
98
|
-
height: 32px;
|
|
99
|
-
width: 32px;
|
|
100
|
-
min-width: 32px;
|
|
101
|
-
|
|
102
|
-
background-color: ${Colors.neutral.grey3};
|
|
103
|
-
|
|
104
|
-
border-radius: 8px;
|
|
105
|
-
`;
|
|
106
|
-
const FileDropButton = ({ onClick }) => (_jsxs(BaseFileDropButton, { onClick: onClick, children: [_jsx(Icons.FileArrowUpIcon, { size: 16 }), _jsx(FileDropButtonText, { children: "File Drop" })] }));
|
|
107
|
-
const BaseFileDropButton = styled.button `
|
|
108
|
-
display: flex;
|
|
109
|
-
align-items: center;
|
|
110
|
-
justify-content: center;
|
|
111
|
-
gap: 4px;
|
|
112
|
-
|
|
113
|
-
height: 31px;
|
|
114
|
-
min-width: 31px;
|
|
115
|
-
|
|
116
|
-
background-color: ${Colors.base.white};
|
|
117
|
-
color: ${Colors.accent.blue1};
|
|
118
|
-
|
|
119
|
-
border: 1px solid ${Colors.accent.blue1};
|
|
120
|
-
border-radius: 8px;
|
|
121
|
-
|
|
122
|
-
@media (width < ${Responsive.WIDTH_BREAKPOINTS.laptop}) {
|
|
123
|
-
padding: 0px;
|
|
124
|
-
font-size: ${Typography.HELPER_FONT_SIZES.small};
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
@media (width >= ${Responsive.WIDTH_BREAKPOINTS.laptop}) {
|
|
128
|
-
padding: 0px 8px;
|
|
129
|
-
font-size: ${Typography.HELPER_FONT_SIZES.big};
|
|
130
|
-
}
|
|
131
|
-
`;
|
|
132
|
-
const FileDropButtonText = styled.p `
|
|
133
|
-
overflow: hidden;
|
|
134
|
-
white-space: nowrap;
|
|
135
|
-
text-overflow: ellipsis;
|
|
136
|
-
|
|
137
|
-
@media (width < ${Responsive.WIDTH_BREAKPOINTS.laptop}) {
|
|
138
|
-
display: none;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
@media (width >= ${Responsive.WIDTH_BREAKPOINTS.laptop}) {
|
|
142
|
-
display: inline;
|
|
143
|
-
}
|
|
144
|
-
`;
|
|
145
|
-
const ResetButton = ({ updateActiveQuery, updateQueryText, }) => {
|
|
146
|
-
const onClickReset = () => {
|
|
147
|
-
updateQueryText("");
|
|
148
|
-
updateActiveQuery({ files: [], text: "" });
|
|
149
|
-
};
|
|
150
|
-
return (_jsx(Button, { text: "Reset", onClick: onClickReset, color: Colors.typography.blackMedium, underline: true }));
|
|
151
|
-
};
|
|
152
|
-
const ActiveQueryRow = styled.div `
|
|
153
|
-
display: flex;
|
|
154
|
-
align-items: center;
|
|
155
|
-
justify-content: space-between;
|
|
156
|
-
`;
|
|
157
|
-
const ActiveQueryFiles = ({ activeQuery, updateActiveQuery, }) => {
|
|
158
|
-
const removeActiveQueryFile = (fileName) => {
|
|
159
|
-
const newQuery = {
|
|
160
|
-
files: activeQuery.files.filter((file) => file.name !== fileName),
|
|
161
|
-
text: activeQuery.text,
|
|
162
|
-
};
|
|
163
|
-
updateActiveQuery(newQuery);
|
|
164
|
-
};
|
|
165
|
-
return (_jsx(BaseActiveQueryFiles, { children: activeQuery.files.map((file) => {
|
|
166
|
-
var _a;
|
|
167
|
-
return (_jsx(Badge, { text: file.name.substring(0, file.name.lastIndexOf(".")), Icon: (_a = FILE_TYPE_ICON_MAP[file.type]) !== null && _a !== void 0 ? _a : Icons.FileIcon, onClickClose: () => removeActiveQueryFile(file.name), textWidthPixels: 160 }, file.name));
|
|
168
|
-
}) }));
|
|
169
|
-
};
|
|
170
|
-
const BaseActiveQueryFiles = styled.div `
|
|
171
|
-
display: flex;
|
|
172
|
-
align-items: center;
|
|
173
|
-
gap: 8px;
|
|
174
|
-
|
|
175
|
-
width: 100%;
|
|
176
|
-
|
|
177
|
-
overflow-x: auto;
|
|
178
|
-
|
|
179
|
-
/* hide scrollbar but still allow for scrolling */
|
|
180
|
-
-ms-overflow-style: none;
|
|
181
|
-
scrollbar-width: none;
|
|
182
|
-
::-webkit-scrollbar {
|
|
183
|
-
display: none;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
/* TODO: fade effect on overflow-x */
|
|
187
|
-
`;
|
|
188
|
-
const FILE_TYPE_ICON_MAP = {
|
|
189
|
-
"application/pdf": Icons.FilePdfIcon,
|
|
190
|
-
};
|
|
191
|
-
const GrantMatchModal = ({ activeQuery, updateActiveQuery, queryText, updateQueryText, closeModal, }) => {
|
|
192
|
-
const { files, uploadFiles, removeFile } = useFileDrop(activeQuery.files);
|
|
193
|
-
const onClickFind = () => {
|
|
194
|
-
updateActiveQuery({ files, text: queryText });
|
|
195
|
-
closeModal();
|
|
196
|
-
};
|
|
197
|
-
return (_jsx(Modal, { header: _jsx("div", { children: "Grant Match" }), content: _jsx(Content, { files: files, uploadFiles: uploadFiles, removeFile: removeFile, queryText: queryText, updateQueryText: updateQueryText }), footer: _jsx(Button, { text: "Find My Grants", onClick: onClickFind, backgroundColor: Colors.accent.yellow1 }), onClickCancel: () => closeModal(), width: "480px", height: "600px" }));
|
|
198
|
-
};
|
|
199
|
-
const Content = ({ files, uploadFiles, removeFile, queryText, updateQueryText, }) => (_jsxs(BaseContent, { children: [_jsx(FileDrop, { uploadedFiles: files, uploadFiles: uploadFiles, removeFile: removeFile }), _jsxs(QueryText, { children: [_jsx("label", { htmlFor: QUERY_TEXTAREA_ID, children: "Search Grants Opportunities" }), _jsx(Textarea, { id: QUERY_TEXTAREA_ID, value: queryText, onChange: (event) => updateQueryText(event.target.value), placeholder: "Explore by grant name or share what your project is about..." })] })] }));
|
|
200
|
-
const QUERY_TEXTAREA_ID = "query-textarea";
|
|
201
|
-
const BaseContent = styled.div `
|
|
202
|
-
display: flex;
|
|
203
|
-
flex-direction: column;
|
|
204
|
-
gap: 12px;
|
|
205
|
-
`;
|
|
206
|
-
const QueryText = styled.div `
|
|
207
|
-
display: flex;
|
|
208
|
-
flex-direction: column;
|
|
209
|
-
`;
|
|
File without changes
|