@grantbii/design-system 1.0.69 → 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
+ `;
@@ -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, removeActiveQueryFile, removeActiveQueryText, resetActiveQuery, }: GrantMatchProps) => import("react/jsx-runtime").JSX.Element;
6
+ declare const GrantMatch: ({ activeQuery, updateActiveQuery }: GrantMatchProps) => import("react/jsx-runtime").JSX.Element;
11
7
  export default GrantMatch;
12
- export declare const useGrantMatchActiveQuery: (filters: GrantFilters, performGrantMatch: (newQuery: GrantMatchQuery, filters: GrantFilters) => void, resetGrantMatch: () => void) => GrantMatchProps;
8
+ export declare const useGrantMatchActiveQuery: (performGrantMatch: (newQuery: GrantMatchQuery) => void, resetGrantMatch: () => void) => GrantMatchProps;
@@ -1,56 +1,35 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
- import { isGrantMatchActive } from "@grantbii/ui-base/match/mappings";
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
+ import { BigScreenOnly, SmallScreenOnly } from "../foundations/responsive";
8
9
  import { FileDrop, Modal, useFileDrop, useModal } from "../molecules";
9
- const GrantMatch = ({ activeQuery, updateActiveQuery, removeActiveQueryFile, removeActiveQueryText, resetActiveQuery, }) => {
10
+ const GrantMatch = ({ activeQuery, updateActiveQuery }) => {
10
11
  const { showModal, openModal, closeModal } = useModal();
11
12
  const [queryText, setQueryText] = useState(activeQuery.text);
12
13
  const updateQueryText = (newText) => setQueryText(newText);
13
- const onClickSearch = () => updateActiveQuery(Object.assign(Object.assign({}, activeQuery), { text: queryText }));
14
- const onClickReset = () => {
15
- updateQueryText("");
16
- resetActiveQuery();
17
- };
18
- return (_jsxs(BaseGrantMatch, { children: [_jsx(GrantMatchActions, { queryText: queryText, updateQueryText: updateQueryText, onClickSearch: onClickSearch, onClickFileDrop: () => openModal(), onClickReset: onClickReset, isActive: activeQuery.text !== "" }), 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, {}))] }));
19
15
  };
20
16
  export default GrantMatch;
21
- // TODO: refactor
22
- export const useGrantMatchActiveQuery = (filters, performGrantMatch, resetGrantMatch) => {
23
- const [activeQuery, setActiveQuery] = useState(() => (Object.assign({}, BLANK_GRANT_MATCH_QUERY)));
24
- const updateActiveQuery = (query) => {
25
- setActiveQuery(Object.assign({}, query));
26
- if (isGrantMatchActive(query)) {
27
- performGrantMatch(query, filters);
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);
28
26
  }
29
27
  else {
30
28
  resetGrantMatch();
31
29
  }
32
30
  };
33
- const removeActiveQueryFile = (fileName) => {
34
- const newQuery = {
35
- files: activeQuery.files.filter((file) => file.name !== fileName),
36
- text: activeQuery.text,
37
- };
38
- updateActiveQuery(newQuery);
39
- };
40
- const removeActiveQueryText = () => {
41
- const newQuery = { files: activeQuery.files, text: "" };
42
- updateActiveQuery(newQuery);
43
- };
44
- const resetActiveQuery = () => updateActiveQuery(Object.assign({}, BLANK_GRANT_MATCH_QUERY));
45
- return {
46
- activeQuery,
47
- updateActiveQuery,
48
- removeActiveQueryFile,
49
- removeActiveQueryText,
50
- resetActiveQuery,
51
- };
31
+ return { activeQuery, updateActiveQuery };
52
32
  };
53
- const BLANK_GRANT_MATCH_QUERY = { files: [], text: "" };
54
33
  const BaseGrantMatch = styled.div `
55
34
  display: flex;
56
35
  flex-direction: column;
@@ -59,7 +38,11 @@ const BaseGrantMatch = styled.div `
59
38
  width: 100%;
60
39
  max-width: 100vw;
61
40
  `;
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, {})] }));
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
+ };
63
46
  const Actions = styled.div `
64
47
  display: flex;
65
48
  align-items: center;
@@ -68,6 +51,7 @@ const Actions = styled.div `
68
51
  const SearchBar = styled.div `
69
52
  display: flex;
70
53
  align-items: center;
54
+ justify-content: space-between;
71
55
 
72
56
  padding: 6px 16px;
73
57
 
@@ -89,10 +73,22 @@ const SearchBar = styled.div `
89
73
  }
90
74
  `;
91
75
  const Input = styled.input `
92
- width: 300px;
76
+ width: 280px;
93
77
  border: none;
94
78
  outline: none;
95
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
+ `;
96
92
  const SearchButton = ({ onClick }) => (_jsx(BaseSearchButton, { type: "button", onClick: onClick, children: _jsx(Icons.MagnifyingGlassIcon, { size: 16, color: Colors.neutral.grey1 }) }));
97
93
  const BaseSearchButton = styled.button `
98
94
  display: flex;
@@ -134,26 +130,10 @@ const BaseFileDropButton = styled.button `
134
130
  }
135
131
  `;
136
132
  const FileDropButtonText = styled.p `
137
- @media (width < ${Responsive.WIDTH_BREAKPOINTS.laptop}) {
138
- display: none;
139
- }
133
+ overflow: hidden;
134
+ white-space: nowrap;
135
+ text-overflow: ellipsis;
140
136
 
141
- @media (width >= ${Responsive.WIDTH_BREAKPOINTS.laptop}) {
142
- display: inline;
143
- }
144
- `;
145
- const SmallScreenResetButton = ({ onClick }) => (_jsx(SmallScreenReset, { children: _jsx(ResetButton, { onClick: onClick }) }));
146
- const SmallScreenReset = styled.div `
147
- @media (width < ${Responsive.WIDTH_BREAKPOINTS.laptop}) {
148
- display: inline;
149
- }
150
-
151
- @media (width >= ${Responsive.WIDTH_BREAKPOINTS.laptop}) {
152
- display: none;
153
- }
154
- `;
155
- const BigScreenResetButton = ({ onClick }) => (_jsx(BigScreenReset, { children: _jsx(ResetButton, { onClick: onClick }) }));
156
- const BigScreenReset = styled.div `
157
137
  @media (width < ${Responsive.WIDTH_BREAKPOINTS.laptop}) {
158
138
  display: none;
159
139
  }
@@ -162,16 +142,31 @@ const BigScreenReset = styled.div `
162
142
  display: inline;
163
143
  }
164
144
  `;
165
- 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
+ };
166
152
  const ActiveQueryRow = styled.div `
167
153
  display: flex;
168
154
  align-items: center;
169
155
  justify-content: space-between;
170
156
  `;
171
- const ActiveQueryFiles = ({ activeQuery, removeQueryFile, }) => (_jsx(BaseActiveQueryFiles, { children: activeQuery.files.map((file) => {
172
- var _a;
173
- return (_jsx(Badge, { text: file.name, Icon: (_a = FILE_TYPE_ICON_MAP[file.type]) !== null && _a !== void 0 ? _a : Icons.FileIcon, onClickClose: () => removeQueryFile(file.name), textWidthPixels: 160 }, file.name));
174
- }) }));
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
+ };
175
170
  const BaseActiveQueryFiles = styled.div `
176
171
  display: flex;
177
172
  align-items: center;
@@ -1,3 +1,3 @@
1
- export { default as GrantMatch } from "./GrantMatch";
1
+ export { default as GrantMatch, useGrantMatchActiveQuery } from "./GrantMatch";
2
2
  export { default as TallyModal } from "./TallyModal";
3
3
  export { default as YesNoOptions } from "./YesNoOptions";
@@ -1,3 +1,3 @@
1
- export { default as GrantMatch } from "./GrantMatch";
1
+ export { default as GrantMatch, useGrantMatchActiveQuery } from "./GrantMatch";
2
2
  export { default as TallyModal } from "./TallyModal";
3
3
  export { default as YesNoOptions } from "./YesNoOptions";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grantbii/design-system",
3
- "version": "1.0.69",
3
+ "version": "1.0.71",
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.18",
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({}, performGrantMatch, resetGrantMatch);
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: "centered",
30
+ layout: "fullscreen",
36
31
  },
37
32
  };
38
33
  export default meta;