@grantbii/design-system 1.0.69 → 1.0.70
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,12 +1,8 @@
|
|
|
1
|
-
import { GrantFilters } from "@grantbii/ui-base/grant/models";
|
|
2
1
|
import { GrantMatchQuery } from "@grantbii/ui-base/match/models";
|
|
3
2
|
type GrantMatchProps = {
|
|
4
3
|
activeQuery: GrantMatchQuery;
|
|
5
4
|
updateActiveQuery: (newQuery: GrantMatchQuery) => void;
|
|
6
|
-
removeActiveQueryFile: (fileName: string) => void;
|
|
7
|
-
removeActiveQueryText: () => void;
|
|
8
|
-
resetActiveQuery: () => void;
|
|
9
5
|
};
|
|
10
|
-
declare const GrantMatch: ({ activeQuery, updateActiveQuery
|
|
6
|
+
declare const GrantMatch: ({ activeQuery, updateActiveQuery }: GrantMatchProps) => import("react/jsx-runtime").JSX.Element;
|
|
11
7
|
export default GrantMatch;
|
|
12
|
-
export declare const useGrantMatchActiveQuery: (
|
|
8
|
+
export declare const useGrantMatchActiveQuery: (performGrantMatch: (newQuery: GrantMatchQuery) => void, resetGrantMatch: () => void) => GrantMatchProps;
|
|
@@ -1,35 +1,42 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
-
import {
|
|
3
|
+
import { checkGrantMatchActive } from "@grantbii/ui-base/match/mappings";
|
|
4
4
|
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
8
|
import { FileDrop, Modal, useFileDrop, useModal } from "../molecules";
|
|
9
|
-
const GrantMatch = ({ activeQuery, updateActiveQuery
|
|
9
|
+
const GrantMatch = ({ activeQuery, updateActiveQuery }) => {
|
|
10
|
+
// TODO: refactor into useGrantMatch
|
|
10
11
|
const { showModal, openModal, closeModal } = useModal();
|
|
11
12
|
const [queryText, setQueryText] = useState(activeQuery.text);
|
|
12
13
|
const updateQueryText = (newText) => setQueryText(newText);
|
|
13
|
-
const
|
|
14
|
+
const { removeActiveQueryFile, removeActiveQueryText, resetActiveQuery } = useGrantMatch(activeQuery, updateActiveQuery);
|
|
15
|
+
const onClickSearch = () => updateActiveQuery({ files: activeQuery.files, text: queryText });
|
|
14
16
|
const onClickReset = () => {
|
|
15
17
|
updateQueryText("");
|
|
16
18
|
resetActiveQuery();
|
|
17
19
|
};
|
|
18
|
-
return (_jsxs(BaseGrantMatch, { children: [_jsx(GrantMatchActions, { queryText: queryText, updateQueryText: updateQueryText, onClickSearch: onClickSearch, onClickFileDrop: () => openModal(), onClickReset: onClickReset, isActive: activeQuery
|
|
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, {}))] }));
|
|
19
21
|
};
|
|
20
22
|
export default GrantMatch;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
export const useGrantMatchActiveQuery = (performGrantMatch, resetGrantMatch) => {
|
|
24
|
+
const [activeQuery, setActiveQuery] = useState({
|
|
25
|
+
files: [],
|
|
26
|
+
text: "",
|
|
27
|
+
});
|
|
28
|
+
const updateActiveQuery = (newQuery) => {
|
|
29
|
+
setActiveQuery(Object.assign({}, newQuery));
|
|
30
|
+
if (checkGrantMatchActive(newQuery)) {
|
|
31
|
+
performGrantMatch(newQuery);
|
|
28
32
|
}
|
|
29
33
|
else {
|
|
30
34
|
resetGrantMatch();
|
|
31
35
|
}
|
|
32
36
|
};
|
|
37
|
+
return { activeQuery, updateActiveQuery };
|
|
38
|
+
};
|
|
39
|
+
const useGrantMatch = (activeQuery, updateActiveQuery) => {
|
|
33
40
|
const removeActiveQueryFile = (fileName) => {
|
|
34
41
|
const newQuery = {
|
|
35
42
|
files: activeQuery.files.filter((file) => file.name !== fileName),
|
|
@@ -41,16 +48,13 @@ export const useGrantMatchActiveQuery = (filters, performGrantMatch, resetGrantM
|
|
|
41
48
|
const newQuery = { files: activeQuery.files, text: "" };
|
|
42
49
|
updateActiveQuery(newQuery);
|
|
43
50
|
};
|
|
44
|
-
const resetActiveQuery = () => updateActiveQuery(
|
|
51
|
+
const resetActiveQuery = () => updateActiveQuery({ files: [], text: "" });
|
|
45
52
|
return {
|
|
46
|
-
activeQuery,
|
|
47
|
-
updateActiveQuery,
|
|
48
53
|
removeActiveQueryFile,
|
|
49
54
|
removeActiveQueryText,
|
|
50
55
|
resetActiveQuery,
|
|
51
56
|
};
|
|
52
57
|
};
|
|
53
|
-
const BLANK_GRANT_MATCH_QUERY = { files: [], text: "" };
|
|
54
58
|
const BaseGrantMatch = styled.div `
|
|
55
59
|
display: flex;
|
|
56
60
|
flex-direction: column;
|
|
@@ -59,7 +63,7 @@ const BaseGrantMatch = styled.div `
|
|
|
59
63
|
width: 100%;
|
|
60
64
|
max-width: 100vw;
|
|
61
65
|
`;
|
|
62
|
-
const GrantMatchActions = ({ queryText, updateQueryText, onClickSearch, onClickFileDrop, onClickReset, isActive, }) => (_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" }), _jsx(SearchButton, { onClick: onClickSearch }), _jsx(FileDropButton, { onClick: onClickFileDrop })] }), isActive ? _jsx(BigScreenResetButton, { onClick: onClickReset }) : _jsx(_Fragment, {})] }));
|
|
66
|
+
const GrantMatchActions = ({ queryText, updateQueryText, onClickSearch, onClickFileDrop, onClickReset, isActive, }) => (_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: onClickFileDrop })] })] }), isActive ? _jsx(BigScreenResetButton, { onClick: onClickReset }) : _jsx(_Fragment, {})] }));
|
|
63
67
|
const Actions = styled.div `
|
|
64
68
|
display: flex;
|
|
65
69
|
align-items: center;
|
|
@@ -68,6 +72,7 @@ const Actions = styled.div `
|
|
|
68
72
|
const SearchBar = styled.div `
|
|
69
73
|
display: flex;
|
|
70
74
|
align-items: center;
|
|
75
|
+
justify-content: space-between;
|
|
71
76
|
|
|
72
77
|
padding: 6px 16px;
|
|
73
78
|
|
|
@@ -89,10 +94,22 @@ const SearchBar = styled.div `
|
|
|
89
94
|
}
|
|
90
95
|
`;
|
|
91
96
|
const Input = styled.input `
|
|
92
|
-
width:
|
|
97
|
+
width: 280px;
|
|
93
98
|
border: none;
|
|
94
99
|
outline: none;
|
|
95
100
|
`;
|
|
101
|
+
const SearchButtons = styled.div `
|
|
102
|
+
display: flex;
|
|
103
|
+
align-items: center;
|
|
104
|
+
|
|
105
|
+
@media (width < ${Responsive.WIDTH_BREAKPOINTS.laptop}) {
|
|
106
|
+
gap: 8px;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
@media (width >= ${Responsive.WIDTH_BREAKPOINTS.laptop}) {
|
|
110
|
+
gap: 16px;
|
|
111
|
+
}
|
|
112
|
+
`;
|
|
96
113
|
const SearchButton = ({ onClick }) => (_jsx(BaseSearchButton, { type: "button", onClick: onClick, children: _jsx(Icons.MagnifyingGlassIcon, { size: 16, color: Colors.neutral.grey1 }) }));
|
|
97
114
|
const BaseSearchButton = styled.button `
|
|
98
115
|
display: flex;
|
|
@@ -134,6 +151,10 @@ const BaseFileDropButton = styled.button `
|
|
|
134
151
|
}
|
|
135
152
|
`;
|
|
136
153
|
const FileDropButtonText = styled.p `
|
|
154
|
+
overflow: hidden;
|
|
155
|
+
white-space: nowrap;
|
|
156
|
+
text-overflow: ellipsis;
|
|
157
|
+
|
|
137
158
|
@media (width < ${Responsive.WIDTH_BREAKPOINTS.laptop}) {
|
|
138
159
|
display: none;
|
|
139
160
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@grantbii/design-system",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.70",
|
|
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.19",
|
|
22
22
|
"@phosphor-icons/react": "^2.1.10",
|
|
23
23
|
"country-flag-icons": "^1.5.19",
|
|
24
24
|
"next": "^15.5.0",
|
|
@@ -12,7 +12,7 @@ const GrantMatchExample = () => {
|
|
|
12
12
|
setTimeout(() => setStatus(`found grants with ${printableQuery}`), 3000);
|
|
13
13
|
};
|
|
14
14
|
const resetGrantMatch = () => setStatus("pending query");
|
|
15
|
-
const grantMatchQueryProps = useGrantMatchActiveQuery(
|
|
15
|
+
const grantMatchQueryProps = useGrantMatchActiveQuery(performGrantMatch, resetGrantMatch);
|
|
16
16
|
return (_jsxs(Container, { children: [_jsx(GrantMatch, Object.assign({}, grantMatchQueryProps)), _jsxs("p", { children: ["Status: ", status] })] }));
|
|
17
17
|
};
|
|
18
18
|
const Container = styled.div `
|
|
@@ -22,17 +22,12 @@ const Container = styled.div `
|
|
|
22
22
|
|
|
23
23
|
padding: 16px;
|
|
24
24
|
`;
|
|
25
|
-
// width: ${({ $screenSize }) => ($screenSize === "small" ? "360px" : "90vw")};
|
|
26
|
-
// height: ${({ $screenSize }) => ($screenSize === "small" ? "600px" : "100vh")};
|
|
27
|
-
// border: ${({ $screenSize }) =>
|
|
28
|
-
// $screenSize === "small" ? `1px solid ${Colors.neutral.grey2}` : "none"};
|
|
29
|
-
// border-radius: 32px;
|
|
30
25
|
const meta = {
|
|
31
26
|
title: "Organisms/Grant Match",
|
|
32
27
|
component: GrantMatchExample,
|
|
33
28
|
tags: ["autodocs"],
|
|
34
29
|
parameters: {
|
|
35
|
-
layout: "
|
|
30
|
+
layout: "fullscreen",
|
|
36
31
|
},
|
|
37
32
|
};
|
|
38
33
|
export default meta;
|