@grantbii/design-system 1.0.70 → 1.0.71
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,3 +1,5 @@
|
|
|
1
1
|
export declare const WIDTH_BREAKPOINTS: {
|
|
2
2
|
laptop: string;
|
|
3
3
|
};
|
|
4
|
+
export declare const SmallScreenOnly: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
5
|
+
export declare const BigScreenOnly: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
import styled from "styled-components";
|
|
1
2
|
export const WIDTH_BREAKPOINTS = {
|
|
2
3
|
laptop: "1024px",
|
|
3
4
|
};
|
|
5
|
+
export const SmallScreenOnly = styled.div `
|
|
6
|
+
@media (width < ${WIDTH_BREAKPOINTS.laptop}) {
|
|
7
|
+
display: inline;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
@media (width >= ${WIDTH_BREAKPOINTS.laptop}) {
|
|
11
|
+
display: none;
|
|
12
|
+
}
|
|
13
|
+
`;
|
|
14
|
+
export const BigScreenOnly = styled.div `
|
|
15
|
+
@media (width < ${WIDTH_BREAKPOINTS.laptop}) {
|
|
16
|
+
display: none;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
@media (width >= ${WIDTH_BREAKPOINTS.laptop}) {
|
|
20
|
+
display: inline;
|
|
21
|
+
}
|
|
22
|
+
`;
|
|
@@ -5,19 +5,13 @@ import { useState } from "react";
|
|
|
5
5
|
import styled from "styled-components";
|
|
6
6
|
import { Badge, Button, Textarea } from "../atoms";
|
|
7
7
|
import { Colors, Icons, Responsive, Typography } from "../foundations";
|
|
8
|
+
import { BigScreenOnly, SmallScreenOnly } from "../foundations/responsive";
|
|
8
9
|
import { FileDrop, Modal, useFileDrop, useModal } from "../molecules";
|
|
9
10
|
const GrantMatch = ({ activeQuery, updateActiveQuery }) => {
|
|
10
|
-
// TODO: refactor into useGrantMatch
|
|
11
11
|
const { showModal, openModal, closeModal } = useModal();
|
|
12
12
|
const [queryText, setQueryText] = useState(activeQuery.text);
|
|
13
13
|
const updateQueryText = (newText) => setQueryText(newText);
|
|
14
|
-
|
|
15
|
-
const onClickSearch = () => updateActiveQuery({ files: activeQuery.files, text: queryText });
|
|
16
|
-
const onClickReset = () => {
|
|
17
|
-
updateQueryText("");
|
|
18
|
-
resetActiveQuery();
|
|
19
|
-
};
|
|
20
|
-
return (_jsxs(BaseGrantMatch, { children: [_jsx(GrantMatchActions, { queryText: queryText, updateQueryText: updateQueryText, onClickSearch: onClickSearch, onClickFileDrop: () => openModal(), onClickReset: onClickReset, isActive: checkGrantMatchActive(activeQuery) }), activeQuery.files.length > 0 ? (_jsxs(ActiveQueryRow, { children: [_jsx(ActiveQueryFiles, { activeQuery: activeQuery, removeQueryFile: removeActiveQueryFile, removeQueryText: removeActiveQueryText }), _jsx(SmallScreenResetButton, { onClick: onClickReset })] })) : (_jsx(_Fragment, {})), showModal ? (_jsx(GrantMatchModal, { activeQuery: activeQuery, updateActiveQuery: updateActiveQuery, queryText: queryText, updateQueryText: updateQueryText, closeModal: closeModal })) : (_jsx(_Fragment, {}))] }));
|
|
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, {}))] }));
|
|
21
15
|
};
|
|
22
16
|
export default GrantMatch;
|
|
23
17
|
export const useGrantMatchActiveQuery = (performGrantMatch, resetGrantMatch) => {
|
|
@@ -36,25 +30,6 @@ export const useGrantMatchActiveQuery = (performGrantMatch, resetGrantMatch) =>
|
|
|
36
30
|
};
|
|
37
31
|
return { activeQuery, updateActiveQuery };
|
|
38
32
|
};
|
|
39
|
-
const useGrantMatch = (activeQuery, updateActiveQuery) => {
|
|
40
|
-
const removeActiveQueryFile = (fileName) => {
|
|
41
|
-
const newQuery = {
|
|
42
|
-
files: activeQuery.files.filter((file) => file.name !== fileName),
|
|
43
|
-
text: activeQuery.text,
|
|
44
|
-
};
|
|
45
|
-
updateActiveQuery(newQuery);
|
|
46
|
-
};
|
|
47
|
-
const removeActiveQueryText = () => {
|
|
48
|
-
const newQuery = { files: activeQuery.files, text: "" };
|
|
49
|
-
updateActiveQuery(newQuery);
|
|
50
|
-
};
|
|
51
|
-
const resetActiveQuery = () => updateActiveQuery({ files: [], text: "" });
|
|
52
|
-
return {
|
|
53
|
-
removeActiveQueryFile,
|
|
54
|
-
removeActiveQueryText,
|
|
55
|
-
resetActiveQuery,
|
|
56
|
-
};
|
|
57
|
-
};
|
|
58
33
|
const BaseGrantMatch = styled.div `
|
|
59
34
|
display: flex;
|
|
60
35
|
flex-direction: column;
|
|
@@ -63,7 +38,11 @@ const BaseGrantMatch = styled.div `
|
|
|
63
38
|
width: 100%;
|
|
64
39
|
max-width: 100vw;
|
|
65
40
|
`;
|
|
66
|
-
const GrantMatchActions = ({
|
|
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
|
+
};
|
|
67
46
|
const Actions = styled.div `
|
|
68
47
|
display: flex;
|
|
69
48
|
align-items: center;
|
|
@@ -163,36 +142,31 @@ const FileDropButtonText = styled.p `
|
|
|
163
142
|
display: inline;
|
|
164
143
|
}
|
|
165
144
|
`;
|
|
166
|
-
const
|
|
167
|
-
const
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
display: none;
|
|
174
|
-
}
|
|
175
|
-
`;
|
|
176
|
-
const BigScreenResetButton = ({ onClick }) => (_jsx(BigScreenReset, { children: _jsx(ResetButton, { onClick: onClick }) }));
|
|
177
|
-
const BigScreenReset = styled.div `
|
|
178
|
-
@media (width < ${Responsive.WIDTH_BREAKPOINTS.laptop}) {
|
|
179
|
-
display: none;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
@media (width >= ${Responsive.WIDTH_BREAKPOINTS.laptop}) {
|
|
183
|
-
display: inline;
|
|
184
|
-
}
|
|
185
|
-
`;
|
|
186
|
-
const ResetButton = ({ onClick }) => (_jsx(Button, { text: "Reset", onClick: onClick, color: Colors.typography.blackMedium, underline: true }));
|
|
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
|
+
};
|
|
187
152
|
const ActiveQueryRow = styled.div `
|
|
188
153
|
display: flex;
|
|
189
154
|
align-items: center;
|
|
190
155
|
justify-content: space-between;
|
|
191
156
|
`;
|
|
192
|
-
const ActiveQueryFiles = ({ activeQuery,
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
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
|
+
};
|
|
196
170
|
const BaseActiveQueryFiles = styled.div `
|
|
197
171
|
display: flex;
|
|
198
172
|
align-items: center;
|
package/core/organisms/index.js
CHANGED