@grantbii/design-system 1.19.6 → 1.20.0
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/organisms/SearchBar.d.ts +10 -0
- package/core/organisms/SearchBar.js +86 -0
- package/core/organisms/SearchBar.js.map +1 -0
- package/core/organisms/index.d.ts +1 -0
- package/core/organisms/index.js +1 -0
- package/core/organisms/index.js.map +1 -1
- package/core/templates/GrantMatch/OpenModalButton.d.ts +5 -0
- package/core/templates/GrantMatch/OpenModalButton.js +62 -0
- package/core/templates/GrantMatch/OpenModalButton.js.map +1 -0
- package/core/templates/GrantMatch/index.js +31 -4
- package/core/templates/GrantMatch/index.js.map +1 -1
- package/package.json +1 -1
- package/stories/organisms/SearchBar.stories.d.ts +6 -0
- package/stories/organisms/SearchBar.stories.js +27 -0
- package/stories/organisms/SearchBar.stories.js.map +1 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/core/templates/GrantMatch/SearchBar.d.ts +0 -6
- package/core/templates/GrantMatch/SearchBar.js +0 -165
- package/core/templates/GrantMatch/SearchBar.js.map +0 -1
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { GrantMatchQuery } from "@grantbii/ui-core/match/entities";
|
|
2
|
+
type SearchBarProps = {
|
|
3
|
+
activeQuery: GrantMatchQuery;
|
|
4
|
+
updateActiveQuery: (query: GrantMatchQuery) => void;
|
|
5
|
+
queryText: string;
|
|
6
|
+
updateQueryText: (newText: string) => void;
|
|
7
|
+
textSearchCallback?: () => void;
|
|
8
|
+
};
|
|
9
|
+
declare const SearchBar: ({ activeQuery, updateActiveQuery, queryText, updateQueryText, textSearchCallback, }: SearchBarProps) => import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export default SearchBar;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import styled from "styled-components";
|
|
3
|
+
import { Color, Responsive, SystemIcon } from "../atoms";
|
|
4
|
+
import { Button } from "../molecules";
|
|
5
|
+
const SearchBar = ({ activeQuery, updateActiveQuery, queryText, updateQueryText, textSearchCallback, }) => {
|
|
6
|
+
const resetSearch = () => {
|
|
7
|
+
updateQueryText("");
|
|
8
|
+
updateActiveQuery({ files: activeQuery.files, text: "" });
|
|
9
|
+
};
|
|
10
|
+
const executeSearch = () => {
|
|
11
|
+
textSearchCallback?.();
|
|
12
|
+
updateActiveQuery({ files: activeQuery.files, text: queryText });
|
|
13
|
+
};
|
|
14
|
+
return (_jsxs(BaseSearchBar, { children: [_jsxs(TextSearchArea, { "$showBorder": activeQuery.text !== "", children: [_jsx(TextInput, { queryText: queryText, updateQueryText: updateQueryText, executeSearch: executeSearch }), queryText === "" ? (_jsx(ResetButtonPlaceholder, {})) : (_jsx(ResetButton, { resetSearch: resetSearch }))] }), _jsx(Button, { Icon: SystemIcon.MagnifyingGlassIcon, onClick: executeSearch, size: "small" })] }));
|
|
15
|
+
};
|
|
16
|
+
export default SearchBar;
|
|
17
|
+
const BaseSearchBar = styled.div `
|
|
18
|
+
display: flex;
|
|
19
|
+
align-items: center;
|
|
20
|
+
justify-content: space-between;
|
|
21
|
+
gap: 8px;
|
|
22
|
+
|
|
23
|
+
width: 100%;
|
|
24
|
+
|
|
25
|
+
@media (width < ${Responsive.WIDTH_BREAKPOINTS.laptop}) {
|
|
26
|
+
border-radius: 0px;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
@media (width >= ${Responsive.WIDTH_BREAKPOINTS.laptop}) {
|
|
30
|
+
border-radius: 12px;
|
|
31
|
+
}
|
|
32
|
+
`;
|
|
33
|
+
const TextSearchArea = styled.div `
|
|
34
|
+
display: flex;
|
|
35
|
+
align-items: center;
|
|
36
|
+
|
|
37
|
+
height: 40px;
|
|
38
|
+
width: 100%;
|
|
39
|
+
|
|
40
|
+
background-color: ${Color.neutral.grey4};
|
|
41
|
+
border: 1px solid ${Color.neutral.grey2};
|
|
42
|
+
border-radius: 8px;
|
|
43
|
+
|
|
44
|
+
&:focus-within {
|
|
45
|
+
background-color: ${Color.neutral.white};
|
|
46
|
+
border: 1px solid ${Color.accent.yellow1};
|
|
47
|
+
}
|
|
48
|
+
`;
|
|
49
|
+
const TextInput = ({ queryText, updateQueryText, executeSearch, }) => {
|
|
50
|
+
const onKeyDown = (event) => {
|
|
51
|
+
if (event.key === "Enter" && !event.repeat) {
|
|
52
|
+
event.preventDefault();
|
|
53
|
+
executeSearch();
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
return (_jsx(BaseTextInput, { value: queryText, onChange: (event) => updateQueryText(event.target.value), onKeyDown: onKeyDown, placeholder: "Search grant or describe your project" }));
|
|
57
|
+
};
|
|
58
|
+
const BaseTextInput = styled.input `
|
|
59
|
+
width: 100%;
|
|
60
|
+
margin-left: 16px;
|
|
61
|
+
|
|
62
|
+
text-overflow: ellipsis;
|
|
63
|
+
|
|
64
|
+
background-color: transparent;
|
|
65
|
+
outline: none;
|
|
66
|
+
border: none;
|
|
67
|
+
`;
|
|
68
|
+
const ResetButton = ({ resetSearch }) => (_jsx(BaseResetButton, { type: "button", onClick: resetSearch, children: _jsx(SystemIcon.XIcon, { size: 14, color: Color.neutral.black }) }));
|
|
69
|
+
const BaseResetButton = styled.button `
|
|
70
|
+
display: flex;
|
|
71
|
+
align-items: center;
|
|
72
|
+
justify-content: center;
|
|
73
|
+
|
|
74
|
+
width: 38px;
|
|
75
|
+
min-width: 38px;
|
|
76
|
+
height: 38px;
|
|
77
|
+
|
|
78
|
+
border-radius: 8px;
|
|
79
|
+
`;
|
|
80
|
+
const ResetButtonPlaceholder = styled.div `
|
|
81
|
+
width: 38px;
|
|
82
|
+
height: 38px;
|
|
83
|
+
|
|
84
|
+
border-radius: 8px;
|
|
85
|
+
`;
|
|
86
|
+
//# sourceMappingURL=SearchBar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SearchBar.js","sourceRoot":"","sources":["../../../core/organisms/S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,MAAM,CAAA;;;;;;;;;;CAUpC,CAAC;AAEF,MAAM,sBAAsB,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;CAKxC,CAAC","sourcesContent":["import type { GrantMatchQuery } from \"@grantbii/ui-core/match/entities\";\nimport type { KeyboardEvent } from \"react\";\nimport styled from \"styled-components\";\nimport { Color, Responsive, SystemIcon } from \"../atoms\";\nimport { Button } from \"../molecules\";\n\ntype SearchBarProps = {\n activeQuery: GrantMatchQuery;\n updateActiveQuery: (query: GrantMatchQuery) => void;\n queryText: string;\n updateQueryText: (newText: string) => void;\n textSearchCallback?: () => void;\n};\n\nconst SearchBar = ({\n activeQuery,\n updateActiveQuery,\n queryText,\n updateQueryText,\n textSearchCallback,\n}: SearchBarProps) => {\n const resetSearch = () => {\n updateQueryText(\"\");\n updateActiveQuery({ files: activeQuery.files, text: \"\" });\n };\n\n const executeSearch = () => {\n textSearchCallback?.();\n updateActiveQuery({ files: activeQuery.files, text: queryText });\n };\n\n return (\n <BaseSearchBar>\n <TextSearchArea $showBorder={activeQuery.text !== \"\"}>\n <TextInput\n queryText={queryText}\n updateQueryText={updateQueryText}\n executeSearch={executeSearch}\n />\n\n {queryText === \"\" ? (\n <ResetButtonPlaceholder />\n ) : (\n <ResetButton resetSearch={resetSearch} />\n )}\n </TextSearchArea>\n\n <Button\n Icon={SystemIcon.MagnifyingGlassIcon}\n onClick={executeSearch}\n size=\"small\"\n />\n </BaseSearchBar>\n );\n};\n\nexport default SearchBar;\n\nconst BaseSearchBar = styled.div`\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 8px;\n\n width: 100%;\n\n @media (width < ${Responsive.WIDTH_BREAKPOINTS.laptop}) {\n border-radius: 0px;\n }\n\n @media (width >= ${Responsive.WIDTH_BREAKPOINTS.laptop}) {\n border-radius: 12px;\n }\n`;\n\nconst TextSearchArea = styled.div<{ $showBorder: boolean }>`\n display: flex;\n align-items: center;\n\n height: 40px;\n width: 100%;\n\n background-color: ${Color.neutral.grey4};\n border: 1px solid ${Color.neutral.grey2};\n border-radius: 8px;\n\n &:focus-within {\n background-color: ${Color.neutral.white};\n border: 1px solid ${Color.accent.yellow1};\n }\n`;\n\ntype TextInputProps = {\n queryText: string;\n updateQueryText: (newText: string) => void;\n executeSearch: () => void;\n};\n\nconst TextInput = ({\n queryText,\n updateQueryText,\n executeSearch,\n}: TextInputProps) => {\n const onKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {\n if (event.key === \"Enter\" && !event.repeat) {\n event.preventDefault();\n executeSearch();\n }\n };\n\n return (\n <BaseTextInput\n value={queryText}\n onChange={(event) => updateQueryText(event.target.value)}\n onKeyDown={onKeyDown}\n placeholder=\"Search grant or describe your project\"\n />\n );\n};\n\nconst BaseTextInput = styled.input`\n width: 100%;\n margin-left: 16px;\n\n text-overflow: ellipsis;\n\n background-color: transparent;\n outline: none;\n border: none;\n`;\n\ntype ResetButtonProps = {\n resetSearch: () => void;\n};\n\nconst ResetButton = ({ resetSearch }: ResetButtonProps) => (\n <BaseResetButton type=\"button\" onClick={resetSearch}>\n <SystemIcon.XIcon size={14} color={Color.neutral.black} />\n </BaseResetButton>\n);\n\nconst BaseResetButton = styled.button`\n display: flex;\n align-items: center;\n justify-content: center;\n\n width: 38px;\n min-width: 38px;\n height: 38px;\n\n border-radius: 8px;\n`;\n\nconst ResetButtonPlaceholder = styled.div`\n width: 38px;\n height: 38px;\n\n border-radius: 8px;\n`;\n"]}
|
package/core/organisms/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../core/organisms/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAsB,MAAM,YAAY,CAAC;AACrE,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9D,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC","sourcesContent":["export { default as Dropdown, type DropdownProps } from \"./Dropdown\";\nexport { default as FileDrop, useFileDrop } from \"./FileDrop\";\nexport { default as Modal, useModal } from \"./Modal\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../core/organisms/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAsB,MAAM,YAAY,CAAC;AACrE,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9D,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACrD,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC","sourcesContent":["export { default as Dropdown, type DropdownProps } from \"./Dropdown\";\nexport { default as FileDrop, useFileDrop } from \"./FileDrop\";\nexport { default as Modal, useModal } from \"./Modal\";\nexport { default as SearchBar } from \"./SearchBar\";\n"]}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import styled from "styled-components";
|
|
3
|
+
import { Color, Responsive, SystemIcon, Typography } from "../../atoms";
|
|
4
|
+
import { applyTypography } from "../../integrations";
|
|
5
|
+
import { useGrantMatchContext } from "./context";
|
|
6
|
+
const OpenModalButton = ({ openModalCallback }) => {
|
|
7
|
+
const { openModal } = useGrantMatchContext();
|
|
8
|
+
const onClickOpen = () => {
|
|
9
|
+
if (openModalCallback) {
|
|
10
|
+
openModalCallback();
|
|
11
|
+
}
|
|
12
|
+
openModal();
|
|
13
|
+
};
|
|
14
|
+
return (_jsxs(BaseOpenModalButton, { onClick: onClickOpen, children: [_jsx(SystemIcon.FileArrowUpIcon, { size: 20 }), _jsx(OpenModalButtonText, { children: "File Drop" })] }));
|
|
15
|
+
};
|
|
16
|
+
export default OpenModalButton;
|
|
17
|
+
const BaseOpenModalButton = styled.button `
|
|
18
|
+
display: flex;
|
|
19
|
+
align-items: center;
|
|
20
|
+
justify-content: center;
|
|
21
|
+
gap: 10px;
|
|
22
|
+
|
|
23
|
+
height: 40px;
|
|
24
|
+
|
|
25
|
+
border-radius: 8px;
|
|
26
|
+
|
|
27
|
+
background-color: ${Color.neutral.grey3};
|
|
28
|
+
color: ${Color.typography.blackHigh};
|
|
29
|
+
|
|
30
|
+
${applyTypography(Typography.bodySecondaryRegular)}
|
|
31
|
+
|
|
32
|
+
&:hover {
|
|
33
|
+
background-color: ${Color.accent.blue3};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
@media (width < ${Responsive.WIDTH_BREAKPOINTS.laptop}) {
|
|
37
|
+
width: 40px;
|
|
38
|
+
min-width: 40px;
|
|
39
|
+
padding: 0px;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
@media (width >= ${Responsive.WIDTH_BREAKPOINTS.laptop}) {
|
|
43
|
+
width: auto;
|
|
44
|
+
min-width: 90px;
|
|
45
|
+
padding: 2px 16px;
|
|
46
|
+
}
|
|
47
|
+
`;
|
|
48
|
+
const OpenModalButtonText = styled.p `
|
|
49
|
+
font-weight: 500;
|
|
50
|
+
overflow: hidden;
|
|
51
|
+
white-space: nowrap;
|
|
52
|
+
text-overflow: ellipsis;
|
|
53
|
+
|
|
54
|
+
@media (width < ${Responsive.WIDTH_BREAKPOINTS.laptop}) {
|
|
55
|
+
display: none;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
@media (width >= ${Responsive.WIDTH_BREAKPOINTS.laptop}) {
|
|
59
|
+
display: inline;
|
|
60
|
+
}
|
|
61
|
+
`;
|
|
62
|
+
//# sourceMappingURL=OpenModalButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OpenModalButton.js","sourceRoot":"","sources":["../../../../core/templates/GrantMatch/OpenModalButton.tsx"],"names":[],"mappings":";AAAA,OAAO,MAAM,MAAM,mBAAmB,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAMjD,MAAM,eAAe,GAAG,CAAC,EAAE,iBAAiB,EAAwB,EAAE,EAAE;IACtE,MAAM,EAAE,SAAS,EAAE,GAAG,oBAAoB,EAAE,CAAC;IAE7C,MAAM,WAAW,GAAG,GAAG,EAAE;QACvB,IAAI,iBAAiB,EAAE,CAAC;YACtB,iBAAiB,EAAE,CAAC;QACtB,CAAC;QAED,SAAS,EAAE,CAAC;IACd,CAAC,CAAC;IAEF,OAAO,CACL,MAAC,mBAAmB,IAAC,OAAO,EAAE,WAAW,aACvC,KAAC,UAAU,CAAC,eAAe,IAAC,IAAI,EAAE,EAAE,GAAI,EACxC,KAAC,mBAAmB,4BAAgC,IAChC,CACvB,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,eAAe,CAAC;AAE/B,MAAM,mBAAmB,GAAG,MAAM,CAAC,MAAM,CAAA;;;;;;;;;;sBAUnB,KAAK,CAAC,OAAO,CAAC,KAAK;WAC9B,KAAK,CAAC,UAAU,CAAC,SAAS;;IAEjC,eAAe,CAAC,UAAU,CAAC,oBAAoB,CAAC;;;wBAG5B,KAAK,CAAC,MAAM,CAAC,KAAK;;;oBAGtB,UAAU,CAAC,iBAAiB,CAAC,MAAM;;;;;;qBAMlC,UAAU,CAAC,iBAAiB,CAAC,MAAM;;;;;CAKvD,CAAC;AAEF,MAAM,mBAAmB,GAAG,MAAM,CAAC,CAAC,CAAA;;;;;;oBAMhB,UAAU,CAAC,iBAAiB,CAAC,MAAM;;;;qBAIlC,UAAU,CAAC,iBAAiB,CAAC,MAAM;;;CAGvD,CAAC","sourcesContent":["import styled from \"styled-components\";\nimport { Color, Responsive, SystemIcon, Typography } from \"../../atoms\";\nimport { applyTypography } from \"../../integrations\";\nimport { useGrantMatchContext } from \"./context\";\n\ntype OpenModalButtonProps = {\n openModalCallback?: () => void;\n};\n\nconst OpenModalButton = ({ openModalCallback }: OpenModalButtonProps) => {\n const { openModal } = useGrantMatchContext();\n\n const onClickOpen = () => {\n if (openModalCallback) {\n openModalCallback();\n }\n\n openModal();\n };\n\n return (\n <BaseOpenModalButton onClick={onClickOpen}>\n <SystemIcon.FileArrowUpIcon size={20} />\n <OpenModalButtonText>File Drop</OpenModalButtonText>\n </BaseOpenModalButton>\n );\n};\n\nexport default OpenModalButton;\n\nconst BaseOpenModalButton = styled.button`\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 10px;\n\n height: 40px;\n\n border-radius: 8px;\n\n background-color: ${Color.neutral.grey3};\n color: ${Color.typography.blackHigh};\n\n ${applyTypography(Typography.bodySecondaryRegular)}\n\n &:hover {\n background-color: ${Color.accent.blue3};\n }\n\n @media (width < ${Responsive.WIDTH_BREAKPOINTS.laptop}) {\n width: 40px;\n min-width: 40px;\n padding: 0px;\n }\n\n @media (width >= ${Responsive.WIDTH_BREAKPOINTS.laptop}) {\n width: auto;\n min-width: 90px;\n padding: 2px 16px;\n }\n`;\n\nconst OpenModalButtonText = styled.p`\n font-weight: 500;\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n\n @media (width < ${Responsive.WIDTH_BREAKPOINTS.laptop}) {\n display: none;\n }\n\n @media (width >= ${Responsive.WIDTH_BREAKPOINTS.laptop}) {\n display: inline;\n }\n`;\n"]}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { jsx as _jsx,
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { checkGrantMatchActive } from "@grantbii/ui-core/match/validations";
|
|
3
3
|
import { useMemo, useState } from "react";
|
|
4
4
|
import styled from "styled-components";
|
|
5
|
-
import {
|
|
5
|
+
import { Color, Responsive } from "../../atoms";
|
|
6
|
+
import { SearchBar, useModal } from "../../organisms";
|
|
6
7
|
import ActiveQueryFiles from "./ActiveQueryFiles";
|
|
7
8
|
import GrantMatchModal from "./GrantMatchModal";
|
|
8
|
-
import
|
|
9
|
+
import OpenModalButton from "./OpenModalButton";
|
|
9
10
|
import { GrantMatchContext } from "./context";
|
|
10
11
|
const GrantMatch = ({ activeQuery, updateActiveQuery, textSearchCallback, findGrantsCallback, closeModalCallback, openModalCallback, }) => {
|
|
11
12
|
const { showModal, openModal, closeModal } = useModal();
|
|
@@ -26,7 +27,7 @@ const GrantMatch = ({ activeQuery, updateActiveQuery, textSearchCallback, findGr
|
|
|
26
27
|
openModal,
|
|
27
28
|
closeModal,
|
|
28
29
|
]);
|
|
29
|
-
return (_jsx(GrantMatchContext.Provider, { value: commonProps, children: _jsxs(BaseGrantMatch, { children: [_jsx(SearchBar, { textSearchCallback: textSearchCallback, openModalCallback: openModalCallback }), activeQuery.files.length > 0 ? _jsx(ActiveQueryFiles, {}) : _jsx(_Fragment, {}), showModal ? (_jsx(GrantMatchModal, { findGrantsCallback: findGrantsCallback, closeModalCallback: closeModalCallback })) : (_jsx(_Fragment, {}))] }) }));
|
|
30
|
+
return (_jsx(GrantMatchContext.Provider, { value: commonProps, children: _jsxs(BaseGrantMatch, { children: [_jsxs(SearchBarContainer, { children: [_jsx(SearchBar, { activeQuery: activeQuery, updateActiveQuery: updateActiveQuery, queryText: queryText, updateQueryText: updateQueryText, textSearchCallback: textSearchCallback }), _jsx(OpenModalButton, { openModalCallback: openModalCallback })] }), activeQuery.files.length > 0 ? _jsx(ActiveQueryFiles, {}) : _jsx(_Fragment, {}), showModal ? (_jsx(GrantMatchModal, { findGrantsCallback: findGrantsCallback, closeModalCallback: closeModalCallback })) : (_jsx(_Fragment, {}))] }) }));
|
|
30
31
|
};
|
|
31
32
|
export default GrantMatch;
|
|
32
33
|
const BaseGrantMatch = styled.div `
|
|
@@ -37,6 +38,32 @@ const BaseGrantMatch = styled.div `
|
|
|
37
38
|
width: 100%;
|
|
38
39
|
max-width: 100vw;
|
|
39
40
|
`;
|
|
41
|
+
const SearchBarContainer = styled.div `
|
|
42
|
+
display: flex;
|
|
43
|
+
align-items: center;
|
|
44
|
+
justify-content: space-between;
|
|
45
|
+
|
|
46
|
+
width: 100%;
|
|
47
|
+
|
|
48
|
+
color: ${Color.typography.blackHigh};
|
|
49
|
+
background-color: ${Color.neutral.white};
|
|
50
|
+
|
|
51
|
+
@media (width < ${Responsive.WIDTH_BREAKPOINTS.laptop}) {
|
|
52
|
+
gap: 8px;
|
|
53
|
+
padding: 0px;
|
|
54
|
+
|
|
55
|
+
box-shadow: none;
|
|
56
|
+
border-radius: 0px;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
@media (width >= ${Responsive.WIDTH_BREAKPOINTS.laptop}) {
|
|
60
|
+
gap: 16px;
|
|
61
|
+
padding: 12px 16px;
|
|
62
|
+
|
|
63
|
+
box-shadow: 0px 0px 40px 0px #00000008;
|
|
64
|
+
border-radius: 12px;
|
|
65
|
+
}
|
|
66
|
+
`;
|
|
40
67
|
export const useGrantMatchActiveQuery = (performGrantMatch, resetGrantMatch) => {
|
|
41
68
|
const [activeQuery, setActiveQuery] = useState({
|
|
42
69
|
files: [],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../core/templates/GrantMatch/index.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAC5E,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,MAAM,MAAM,mBAAmB,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../core/templates/GrantMatch/index.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAC5E,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC1C,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GrantMatchQuery } from \"@grantbii/ui-core/match/entities\";\nimport { checkGrantMatchActive } from \"@grantbii/ui-core/match/validations\";\nimport { useMemo, useState } from \"react\";\nimport styled from \"styled-components\";\nimport { Color, Responsive } from \"../../atoms\";\nimport { SearchBar, useModal } from \"../../organisms\";\nimport ActiveQueryFiles from \"./ActiveQueryFiles\";\nimport GrantMatchModal from \"./GrantMatchModal\";\nimport OpenModalButton from \"./OpenModalButton\";\nimport { GrantMatchContext } from \"./context\";\n\ntype GrantMatchProps = {\n activeQuery: GrantMatchQuery;\n updateActiveQuery: (newQuery: GrantMatchQuery) => void;\n textSearchCallback?: () => void;\n findGrantsCallback?: () => void;\n closeModalCallback?: () => void;\n openModalCallback?: () => void;\n};\n\nconst GrantMatch = ({\n activeQuery,\n updateActiveQuery,\n textSearchCallback,\n findGrantsCallback,\n closeModalCallback,\n openModalCallback,\n}: GrantMatchProps) => {\n const { showModal, openModal, closeModal } = useModal();\n const [queryText, setQueryText] = useState(activeQuery.text);\n const updateQueryText = (newText: string) => setQueryText(newText);\n\n const commonProps = useMemo(\n () => ({\n activeQuery,\n updateActiveQuery,\n queryText,\n updateQueryText,\n openModal,\n closeModal,\n }),\n [\n activeQuery,\n updateActiveQuery,\n queryText,\n updateQueryText,\n openModal,\n closeModal,\n ],\n );\n\n return (\n <GrantMatchContext.Provider value={commonProps}>\n <BaseGrantMatch>\n <SearchBarContainer>\n <SearchBar\n activeQuery={activeQuery}\n updateActiveQuery={updateActiveQuery}\n queryText={queryText}\n updateQueryText={updateQueryText}\n textSearchCallback={textSearchCallback}\n />\n <OpenModalButton openModalCallback={openModalCallback} />\n </SearchBarContainer>\n\n {activeQuery.files.length > 0 ? <ActiveQueryFiles /> : <></>}\n\n {showModal ? (\n <GrantMatchModal\n findGrantsCallback={findGrantsCallback}\n closeModalCallback={closeModalCallback}\n />\n ) : (\n <></>\n )}\n </BaseGrantMatch>\n </GrantMatchContext.Provider>\n );\n};\n\nexport default GrantMatch;\n\nconst BaseGrantMatch = styled.div`\n display: flex;\n flex-direction: column;\n gap: 8px;\n\n width: 100%;\n max-width: 100vw;\n`;\n\nconst SearchBarContainer = styled.div`\n display: flex;\n align-items: center;\n justify-content: space-between;\n\n width: 100%;\n\n color: ${Color.typography.blackHigh};\n background-color: ${Color.neutral.white};\n\n @media (width < ${Responsive.WIDTH_BREAKPOINTS.laptop}) {\n gap: 8px;\n padding: 0px;\n\n box-shadow: none;\n border-radius: 0px;\n }\n\n @media (width >= ${Responsive.WIDTH_BREAKPOINTS.laptop}) {\n gap: 16px;\n padding: 12px 16px;\n\n box-shadow: 0px 0px 40px 0px #00000008;\n border-radius: 12px;\n }\n`;\n\nexport const useGrantMatchActiveQuery = (\n performGrantMatch: (newQuery: GrantMatchQuery) => void,\n resetGrantMatch: () => void,\n): GrantMatchProps => {\n const [activeQuery, setActiveQuery] = useState<GrantMatchQuery>({\n files: [],\n text: \"\",\n });\n\n const updateActiveQuery = (newQuery: GrantMatchQuery) => {\n setActiveQuery({ ...newQuery });\n\n if (checkGrantMatchActive(newQuery)) {\n performGrantMatch(newQuery);\n } else {\n resetGrantMatch();\n }\n };\n\n return { activeQuery, updateActiveQuery };\n};\n"]}
|
package/package.json
CHANGED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { SearchBar } from "@/.";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
const SearchBarExample = () => {
|
|
5
|
+
const [activeQuery, setActiveQuery] = useState(emptyQuery);
|
|
6
|
+
const updateActiveQuery = (newQuery) => setActiveQuery(newQuery);
|
|
7
|
+
const [queryText, setQueryText] = useState("");
|
|
8
|
+
const updateQueryText = (newText) => setQueryText(newText);
|
|
9
|
+
return (_jsx(SearchBar, { activeQuery: activeQuery, updateActiveQuery: updateActiveQuery, queryText: queryText, updateQueryText: updateQueryText }));
|
|
10
|
+
};
|
|
11
|
+
const emptyQuery = {
|
|
12
|
+
text: "",
|
|
13
|
+
files: [],
|
|
14
|
+
};
|
|
15
|
+
const meta = {
|
|
16
|
+
title: "Organisms/SearchBar",
|
|
17
|
+
component: SearchBarExample,
|
|
18
|
+
tags: ["autodocs"],
|
|
19
|
+
parameters: {
|
|
20
|
+
layout: "fullscreen",
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
export default meta;
|
|
24
|
+
export const Default = {
|
|
25
|
+
args: {},
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=SearchBar.stories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SearchBar.stories.js","sourceRoot":"","sources":["../../../stories/organisms/SearchBar.stories.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AAGhC,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEjC,MAAM,gBAAgB,GAAG,GAAG,EAAE;IAC5B,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAkB,UAAU,CAAC,CAAC;IAC5E,MAAM,iBAAiB,GAAG,CAAC,QAAyB,EAAE,EAAE,CACtD,cAAc,CAAC,QAAQ,CAAC,CAAC;IAE3B,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC;IAC/C,MAAM,eAAe,GAAG,CAAC,OAAe,EAAE,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;IAEnE,OAAO,CACL,KAAC,SAAS,IACR,WAAW,EAAE,WAAW,EACxB,iBAAiB,EAAE,iBAAiB,EACpC,SAAS,EAAE,SAAS,EACpB,eAAe,EAAE,eAAe,GAChC,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,UAAU,GAAG;IACjB,IAAI,EAAE,EAAE;IACR,KAAK,EAAE,EAAE;CACV,CAAC;AAEF,MAAM,IAAI,GAA2B;IACnC,KAAK,EAAE,qBAAqB;IAC5B,SAAS,EAAE,gBAAgB;IAC3B,IAAI,EAAE,CAAC,UAAU,CAAC;IAClB,UAAU,EAAE;QACV,MAAM,EAAE,YAAY;KACrB;CACF,CAAC;AAEF,eAAe,IAAI,CAAC;AAIpB,MAAM,CAAC,MAAM,OAAO,GAAU;IAC5B,IAAI,EAAE,EAAE;CACT,CAAC","sourcesContent":["import { SearchBar } from \"@/.\";\nimport type { GrantMatchQuery } from \"@grantbii/ui-core/match/entities\";\nimport type { Meta, StoryObj } from \"@storybook/nextjs-vite\";\nimport { useState } from \"react\";\n\nconst SearchBarExample = () => {\n const [activeQuery, setActiveQuery] = useState<GrantMatchQuery>(emptyQuery);\n const updateActiveQuery = (newQuery: GrantMatchQuery) =>\n setActiveQuery(newQuery);\n\n const [queryText, setQueryText] = useState(\"\");\n const updateQueryText = (newText: string) => setQueryText(newText);\n\n return (\n <SearchBar\n activeQuery={activeQuery}\n updateActiveQuery={updateActiveQuery}\n queryText={queryText}\n updateQueryText={updateQueryText}\n />\n );\n};\n\nconst emptyQuery = {\n text: \"\",\n files: [],\n};\n\nconst meta: Meta<typeof SearchBar> = {\n title: \"Organisms/SearchBar\",\n component: SearchBarExample,\n tags: [\"autodocs\"],\n parameters: {\n layout: \"fullscreen\",\n },\n};\n\nexport default meta;\n\ntype Story = StoryObj<typeof meta>;\n\nexport const Default: Story = {\n args: {},\n};\n"]}
|