@grantbii/design-system 1.0.57 → 1.0.58
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/molecules/FileDrop.js +1 -4
- package/core/organisms/GrantMatch.d.ts +2 -2
- package/core/organisms/GrantMatch.js +28 -11
- package/package.json +1 -1
- package/stories/organisms/GrantMatch.stories.d.ts +4 -4
- package/stories/organisms/GrantMatch.stories.js +20 -16
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -107,10 +107,7 @@ export const useFileDrop = (initialFiles = [], maxFiles = DEFAULT_MAX_FILES, max
|
|
|
107
107
|
errorMessage,
|
|
108
108
|
};
|
|
109
109
|
};
|
|
110
|
-
const anyFileTooLarge = (files, maxSizeMB) => files.some((file) =>
|
|
111
|
-
console.log("file size:", file.size);
|
|
112
|
-
return file.size > convertMegabytesToBytes(maxSizeMB);
|
|
113
|
-
});
|
|
110
|
+
const anyFileTooLarge = (files, maxSizeMB) => files.some((file) => file.size > convertMegabytesToBytes(maxSizeMB));
|
|
114
111
|
const convertMegabytesToBytes = (megabytes) => megabytes * 1024 * 1024;
|
|
115
112
|
const combineFilesWithoutDuplicates = (oldFiles, newFiles) => {
|
|
116
113
|
const newFileNames = newFiles.map((file) => file.name);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { GrantMatchQuery } from "@grantbii/ui-base/match/models";
|
|
2
2
|
type GrantMatchProps = GrantMatchQueryProps & {
|
|
3
|
-
|
|
3
|
+
isSmallerThanLaptop?: boolean;
|
|
4
4
|
};
|
|
5
|
-
declare const GrantMatch: ({ query, updateQuery, removeQueryFile, removeQueryText, resetQuery,
|
|
5
|
+
declare const GrantMatch: ({ query, updateQuery, removeQueryFile, removeQueryText, resetQuery, isSmallerThanLaptop, }: GrantMatchProps) => import("react/jsx-runtime").JSX.Element;
|
|
6
6
|
export default GrantMatch;
|
|
7
7
|
type GrantMatchQueryProps = {
|
|
8
8
|
query: GrantMatchQuery;
|
|
@@ -5,14 +5,14 @@ import styled from "styled-components";
|
|
|
5
5
|
import { Badge, Button, Textarea } from "../atoms";
|
|
6
6
|
import { Colors, Icons } from "../foundations";
|
|
7
7
|
import { FileDrop, Modal, useFileDrop, useModal } from "../molecules";
|
|
8
|
-
const GrantMatch = ({ query, updateQuery, removeQueryFile, removeQueryText, resetQuery,
|
|
8
|
+
const GrantMatch = ({ query, updateQuery, removeQueryFile, removeQueryText, resetQuery, isSmallerThanLaptop, }) => {
|
|
9
9
|
const { showModal, openModal, closeModal } = useModal();
|
|
10
10
|
const isActive = isGrantMatchActive(query);
|
|
11
11
|
const updateActiveQuery = (newQuery) => {
|
|
12
12
|
updateQuery(newQuery);
|
|
13
13
|
closeModal();
|
|
14
14
|
};
|
|
15
|
-
return (_jsxs(BaseGrantMatch, { children: [_jsx(GrantMatchButtons, { isActive: isActive, onClickMatch: () => openModal(), onClickReset: () => resetQuery() }), isActive ? (_jsx(QueryItems, { activeQuery: query, removeQueryFile: removeQueryFile, removeQueryText: removeQueryText })) : (_jsx(_Fragment, {})), showModal ? (_jsx(GrantMatchModal, { activeQuery: query, updateActiveQuery: updateActiveQuery, onClickCancel: () => closeModal(), isFullScreen:
|
|
15
|
+
return (_jsxs(BaseGrantMatch, { children: [_jsx(GrantMatchButtons, { isActive: isActive, onClickMatch: () => openModal(), onClickReset: () => resetQuery(), isSmallerThanLaptop: isSmallerThanLaptop }), isActive ? (_jsxs(QueryItemsRow, { children: [_jsx(QueryItems, { activeQuery: query, removeQueryFile: removeQueryFile, removeQueryText: removeQueryText }), isSmallerThanLaptop ? (_jsx(ResetButton, { onClick: () => resetQuery() })) : (_jsx(_Fragment, {}))] })) : (_jsx(_Fragment, {})), showModal ? (_jsx(GrantMatchModal, { activeQuery: query, updateActiveQuery: updateActiveQuery, onClickCancel: () => closeModal(), isFullScreen: isSmallerThanLaptop })) : (_jsx(_Fragment, {}))] }));
|
|
16
16
|
};
|
|
17
17
|
export default GrantMatch;
|
|
18
18
|
export const useGrantMatchQueryItems = (performGrantMatch, resetGrantMatch) => {
|
|
@@ -67,34 +67,47 @@ const BaseGrantMatch = styled.div `
|
|
|
67
67
|
flex-direction: column;
|
|
68
68
|
gap: 8px;
|
|
69
69
|
|
|
70
|
-
padding: 16px 16px 0px 16px;
|
|
71
|
-
|
|
72
70
|
width: 100%;
|
|
73
71
|
max-width: 100vw;
|
|
74
72
|
`;
|
|
75
|
-
const GrantMatchButtons = ({ isActive, onClickMatch, onClickReset, }) => (_jsxs(Buttons, { children: [_jsx(GrantMatchButton, { isActive: isActive, onClick: onClickMatch }), isActive ? (_jsx(
|
|
73
|
+
const GrantMatchButtons = ({ isActive, onClickMatch, onClickReset, isSmallerThanLaptop, }) => (_jsxs(Buttons, { children: [_jsx(GrantMatchButton, { isActive: isActive, isSmallerThanLaptop: isSmallerThanLaptop, onClick: onClickMatch }), !isSmallerThanLaptop && isActive ? (_jsx(ResetButton, { onClick: onClickReset })) : (_jsx(_Fragment, {}))] }));
|
|
76
74
|
const Buttons = styled.div `
|
|
77
75
|
display: flex;
|
|
78
76
|
align-items: center;
|
|
79
77
|
gap: 8px;
|
|
80
78
|
`;
|
|
81
|
-
const GrantMatchButton = ({ isActive, onClick }) => (_jsxs(BaseGrantMatchButton, { type: "button", "$isActive": isActive, onClick: onClick, children: [_jsx(Icons.GrantMatchIcon, { size: 20 }), _jsx("p", { children: "Find grants that match your needs" }), _jsx(Icons.MagnifyingGlassIcon, { size: 20 })] }));
|
|
79
|
+
const GrantMatchButton = ({ isActive, onClick, isSmallerThanLaptop, }) => (_jsxs(BaseGrantMatchButton, { type: "button", "$isSmallerThanLaptop": isSmallerThanLaptop, "$isActive": isActive, onClick: onClick, children: [_jsxs(GrantMatchButtonContent, { children: [_jsx(Icons.GrantMatchIcon, { size: 20 }), _jsx("p", { children: "Find grants that match your needs" })] }), _jsx(Icons.MagnifyingGlassIcon, { size: 20 })] }));
|
|
82
80
|
const BaseGrantMatchButton = styled.button `
|
|
83
81
|
display: flex;
|
|
84
82
|
align-items: center;
|
|
85
|
-
|
|
83
|
+
justify-content: space-between;
|
|
84
|
+
gap: 16px;
|
|
86
85
|
|
|
87
|
-
height: 20px;
|
|
88
86
|
padding: 10px 16px;
|
|
89
|
-
|
|
87
|
+
|
|
88
|
+
height: 20px;
|
|
89
|
+
width: ${({ $isSmallerThanLaptop = false }) => $isSmallerThanLaptop ? "100%" : "auto"};
|
|
90
90
|
|
|
91
91
|
font-size: 14px;
|
|
92
92
|
font-weight: 500;
|
|
93
93
|
|
|
94
|
-
color: ${Colors.typography.blackMedium};
|
|
95
94
|
background-color: ${Colors.base.white};
|
|
95
|
+
color: ${Colors.typography.blackMedium};
|
|
96
|
+
|
|
96
97
|
border: 1px solid
|
|
97
98
|
${({ $isActive }) => $isActive ? Colors.accent.yellow1 : Colors.neutral.grey3};
|
|
99
|
+
border-radius: 200px;
|
|
100
|
+
`;
|
|
101
|
+
const GrantMatchButtonContent = styled.div `
|
|
102
|
+
display: flex;
|
|
103
|
+
align-items: center;
|
|
104
|
+
gap: 8px;
|
|
105
|
+
`;
|
|
106
|
+
const ResetButton = ({ onClick }) => (_jsx(Button, { text: "Reset", onClick: onClick, color: Colors.typography.blackMedium, underline: true }));
|
|
107
|
+
const QueryItemsRow = styled.div `
|
|
108
|
+
display: flex;
|
|
109
|
+
align-items: center;
|
|
110
|
+
justify-content: space-between;
|
|
98
111
|
`;
|
|
99
112
|
const QueryItems = ({ activeQuery, removeQueryFile, removeQueryText, }) => (_jsxs(BaseQueryItems, { children: [activeQuery.files.map((file) => {
|
|
100
113
|
var _a;
|
|
@@ -105,6 +118,8 @@ const BaseQueryItems = styled.div `
|
|
|
105
118
|
align-items: center;
|
|
106
119
|
gap: 8px;
|
|
107
120
|
|
|
121
|
+
width: 100%;
|
|
122
|
+
|
|
108
123
|
overflow-x: auto;
|
|
109
124
|
|
|
110
125
|
/* hide scrollbar but still allow for scrolling */
|
|
@@ -113,6 +128,8 @@ const BaseQueryItems = styled.div `
|
|
|
113
128
|
::-webkit-scrollbar {
|
|
114
129
|
display: none;
|
|
115
130
|
}
|
|
131
|
+
|
|
132
|
+
/* TODO: fade effect on overflow-x */
|
|
116
133
|
`;
|
|
117
134
|
const FILE_TYPE_ICON_MAP = {
|
|
118
135
|
"application/pdf": Icons.FilePdfIcon,
|
|
@@ -120,7 +137,7 @@ const FILE_TYPE_ICON_MAP = {
|
|
|
120
137
|
const GrantMatchModal = ({ activeQuery, updateActiveQuery, onClickCancel, isFullScreen, }) => {
|
|
121
138
|
const { files, uploadFiles, removeFile } = useFileDrop(activeQuery.files);
|
|
122
139
|
const [text, setText] = useState(activeQuery.text);
|
|
123
|
-
return (_jsx(Modal, { header: _jsx(Header, {}), content: _jsx(Content, { files: files, uploadFiles: uploadFiles, removeFile: removeFile, queryText: text, updateQueryText: (newText) => setText(newText) }), footer: _jsx(Button, { text: "Find My Grants", onClick: () => updateActiveQuery({ files, text }), backgroundColor: Colors.accent.yellow1 }), onClickCancel: onClickCancel, isFullScreen: isFullScreen }));
|
|
140
|
+
return (_jsx(Modal, { header: _jsx(Header, {}), content: _jsx(Content, { files: files, uploadFiles: uploadFiles, removeFile: removeFile, queryText: text, updateQueryText: (newText) => setText(newText) }), footer: _jsx(Button, { text: "Find My Grants", onClick: () => updateActiveQuery({ files, text }), backgroundColor: Colors.accent.yellow1 }), onClickCancel: onClickCancel, isFullScreen: isFullScreen, width: "480px" }));
|
|
124
141
|
};
|
|
125
142
|
const Header = () => (_jsxs(BaseHeader, { children: [_jsx(Icons.GrantMatchIcon, { size: 24 }), _jsx("div", { children: "Grant Match" })] }));
|
|
126
143
|
const BaseHeader = styled.div `
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Meta, StoryObj } from "@storybook/nextjs-vite";
|
|
2
2
|
type GrantMatchExampleProps = {
|
|
3
|
-
|
|
3
|
+
isMobile?: boolean;
|
|
4
4
|
};
|
|
5
|
-
declare const GrantMatchExample: ({
|
|
5
|
+
declare const GrantMatchExample: ({ isMobile }: GrantMatchExampleProps) => import("react/jsx-runtime").JSX.Element;
|
|
6
6
|
declare const meta: Meta<typeof GrantMatchExample>;
|
|
7
7
|
export default meta;
|
|
8
8
|
type Story = StoryObj<typeof meta>;
|
|
9
|
-
export declare const
|
|
10
|
-
export declare const
|
|
9
|
+
export declare const Desktop: Story;
|
|
10
|
+
export declare const Mobile: Story;
|
|
@@ -1,27 +1,31 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { GrantMatch } from "@/.";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Colors, GrantMatch } from "@/.";
|
|
3
3
|
import { useGrantMatchQueryItems } from "@/core/organisms/GrantMatch";
|
|
4
4
|
import { useState } from "react";
|
|
5
5
|
import styled from "styled-components";
|
|
6
|
-
const GrantMatchExample = ({
|
|
7
|
-
const [status, setStatus] = useState("
|
|
6
|
+
const GrantMatchExample = ({ isMobile }) => {
|
|
7
|
+
const [status, setStatus] = useState("pending query");
|
|
8
8
|
const performGrantMatch = (newQuery) => {
|
|
9
9
|
const fileNames = newQuery.files.map((file) => file.name).join(", ");
|
|
10
|
-
setStatus(`
|
|
11
|
-
setTimeout(() => setStatus("
|
|
10
|
+
setStatus(`finding grants using files [${fileNames}] and text [${newQuery.text}]`);
|
|
11
|
+
setTimeout(() => setStatus("found grants"), 3000);
|
|
12
12
|
};
|
|
13
|
-
const resetGrantMatch = () => setStatus("
|
|
13
|
+
const resetGrantMatch = () => setStatus("pending query");
|
|
14
14
|
const grantMatchQueryProps = useGrantMatchQueryItems(performGrantMatch, resetGrantMatch);
|
|
15
|
-
return (_jsxs(Container, {
|
|
15
|
+
return (_jsxs(Container, { "$isMobile": isMobile, children: [_jsx(GrantMatch, Object.assign({}, grantMatchQueryProps, { isSmallerThanLaptop: isMobile })), _jsxs("p", { children: ["Status: ", status] })] }));
|
|
16
16
|
};
|
|
17
|
-
const GrantMatchStatus = styled.p `
|
|
18
|
-
margin: 0px 16px;
|
|
19
|
-
`;
|
|
20
17
|
const Container = styled.div `
|
|
21
18
|
display: flex;
|
|
22
19
|
flex-direction: column;
|
|
20
|
+
gap: 8px;
|
|
21
|
+
|
|
22
|
+
padding: 16px;
|
|
23
|
+
|
|
24
|
+
width: ${({ $isMobile = false }) => ($isMobile ? "360px" : "90vw")};
|
|
25
|
+
height: ${({ $isMobile = false }) => ($isMobile ? "600px" : "100vh")};
|
|
23
26
|
|
|
24
|
-
|
|
27
|
+
border: ${({ $isMobile = false }) => $isMobile ? `1px solid ${Colors.neutral.grey2}` : "none"};
|
|
28
|
+
border-radius: 32px;
|
|
25
29
|
`;
|
|
26
30
|
const meta = {
|
|
27
31
|
title: "Organisms/Grant Match",
|
|
@@ -32,9 +36,9 @@ const meta = {
|
|
|
32
36
|
},
|
|
33
37
|
};
|
|
34
38
|
export default meta;
|
|
35
|
-
export const
|
|
36
|
-
args: {},
|
|
39
|
+
export const Desktop = {
|
|
40
|
+
args: { isMobile: false },
|
|
37
41
|
};
|
|
38
|
-
export const
|
|
39
|
-
args: {
|
|
42
|
+
export const Mobile = {
|
|
43
|
+
args: { isMobile: true },
|
|
40
44
|
};
|