Skip to content

Commit 748b112

Browse files
committed
Add new row entry for modals
1 parent 8532924 commit 748b112

File tree

9 files changed

+232
-77
lines changed

9 files changed

+232
-77
lines changed

package-lock.json

Lines changed: 107 additions & 69 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
"@babel/preset-env": "^7.27.2",
2424
"@babel/preset-react": "^7.27.1",
2525
"@babel/preset-typescript": "^7.27.1",
26-
"@storybook/addon-docs": "^9.0.18",
26+
"@storybook/addon-docs": "^9.1.3",
2727
"@storybook/addon-webpack5-compiler-swc": "^3.0.0",
28-
"@storybook/react-webpack5": "^9.0.18",
28+
"@storybook/react-webpack5": "^9.1.3",
2929
"@svgr/webpack": "^8.1.0",
3030
"@types/lodash": "^4.17.17",
3131
"@types/react": "18.2.0",
@@ -34,7 +34,7 @@
3434
"babel-loader": "^10.0.0",
3535
"file-loader": "^6.2.0",
3636
"prettier": "^3.5.3",
37-
"storybook": "^9.0.18",
37+
"storybook": "^9.1.3",
3838
"styled-components": "^6.1.19",
3939
"ts-loader": "^9.5.2",
4040
"tsconfig-paths-webpack-plugin": "^4.2.0",

src/components/Explorer/Explorer.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ const Explorer = ({
5555
const [deleteEntry, setDeleteEntry] = useState<Entry | undefined>(undefined);
5656
const [renameEntry, setRenameEntry] = useState<Entry | undefined>(undefined);
5757
const [selectedEntry, setSelectedEntry] = useState<Entry | undefined>(
58-
undefined
58+
undefined,
5959
);
6060
const [selectedLocation, setSelectedLocation] = useState("");
6161

@@ -256,7 +256,7 @@ const Explorer = ({
256256

257257
const handleCreateFolderSubmit = async (
258258
location: string,
259-
folder_name: string
259+
folder_name: string,
260260
) => {
261261
if (folder_name !== "") {
262262
try {

src/components/Modals/Modal.stories.tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import Modal, {
44
ModalActionList,
55
ModalEditableList,
66
ModalRow,
7+
ModalRowDataText,
78
ModalTitlebar,
89
} from "./Modal";
910

@@ -57,6 +58,27 @@ export const Main: Story = {
5758
onSelect={() => {}}
5859
/>
5960
</ModalRow>
61+
<ModalRow>
62+
<ModalRowDataText
63+
title="Subtrees"
64+
data={[
65+
"a",
66+
"sfayguh",
67+
"stavyjb",
68+
"ycavybun",
69+
"cavshbjn",
70+
"acvsbhnj",
71+
"acvsbhnj",
72+
"acvsbhnj",
73+
"acvsbhnj",
74+
"acvsbhnj",
75+
"acvsbhnj",
76+
"acvsbhnj",
77+
"acvsbhnj",
78+
"acvsbhnj",
79+
]}
80+
/>
81+
</ModalRow>
6082
<ModalRow type="buttons">
6183
<button type="button" onClick={() => {}}>
6284
New custom universe

src/components/Modals/Modal.styles.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,33 @@ export const StyledModalRow = styled.div<StyledModalRowProps>`
136136
}
137137
`;
138138

139+
export const StyledModalRowDataText = styled.div`
140+
display: flex;
141+
flex-direction: row;
142+
align-items: flex-start;
143+
background: none;
144+
width: 100%;
145+
`;
146+
147+
interface StyledModalRowDataTextTitleProps {
148+
color?: string;
149+
buttonColor?: string;
150+
roundness?: number;
151+
}
152+
153+
export const StyledModalRowDataTextTitle = styled.li<StyledModalRowDataTextTitleProps>`
154+
color: ${(p) => p.color ?? primaryColor};
155+
`;
156+
157+
export const StyledModalRowDataTextEntries = styled.div`
158+
display: flex;
159+
flex-direction: column;
160+
align-items: flex-end;
161+
background: none;
162+
margin-left: auto;
163+
opacity: 80%;
164+
`;
165+
139166
interface StyledModalButtonRowProps {
140167
color?: string;
141168
buttonColor?: string;
@@ -168,6 +195,18 @@ export const StyledModalButtonRow = styled.div<StyledModalButtonRowProps>`
168195
}
169196
`;
170197

198+
interface StyledModalImageRowProps {
199+
color?: string;
200+
roundness?: number;
201+
}
202+
203+
export const StyledModalImageRow = styled.div<StyledModalImageRowProps>`
204+
width: 100%;
205+
margin: 10px;
206+
background-color: ${(p) => p.color ?? primaryColor};
207+
border-radius: ${(p) => p.roundness ?? 1}px;
208+
`;
209+
171210
interface StyledModalButtonDeleteProps {
172211
bgColor?: string;
173212
}

src/components/Modals/Modal.tsx

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,15 @@ import {
1010
StyledModalDropArea,
1111
StyledModalEditableList,
1212
StyledModalEntryList,
13+
StyledModalImageRow,
1314
StyledModalInput,
1415
StyledModalInputRowContainer,
1516
StyledModalInputSelector,
1617
StyledModalInputSelectorTitle,
1718
StyledModalRow,
19+
StyledModalRowDataText,
20+
StyledModalRowDataTextEntries,
21+
StyledModalRowDataTextTitle,
1822
StyledModalSelectIcon,
1923
StyledModalTitlebar,
2024
} from "./Modal.styles";
@@ -187,7 +191,16 @@ export const ModalRow = ({
187191
return (
188192
<StyledModalEditableList id={id}>{children}</StyledModalEditableList>
189193
);
190-
194+
case "img":
195+
return (
196+
<StyledModalImageRow
197+
color={theme.palette.text}
198+
roundness={theme.roundness}
199+
id={id}
200+
>
201+
{children}
202+
</StyledModalImageRow>
203+
);
191204
default:
192205
return (
193206
<StyledModalRow
@@ -206,6 +219,41 @@ ModalRow.defaultProps = {
206219
type: "all",
207220
};
208221

222+
export const ModalRowDataText = ({
223+
id,
224+
title,
225+
data,
226+
}: {
227+
id?: string;
228+
title: string;
229+
data: string[];
230+
}) => {
231+
const theme = useTheme();
232+
233+
if (data.length == 0) {
234+
return (
235+
<StyledModalRowDataText>
236+
<StyledModalRowDataTextTitle color={theme.palette.text}>
237+
{`${title}:`}
238+
</StyledModalRowDataTextTitle>
239+
</StyledModalRowDataText>
240+
);
241+
}
242+
243+
return (
244+
<StyledModalRowDataText>
245+
<StyledModalRowDataTextTitle color={theme.palette.text}>
246+
{`${title}:`}
247+
</StyledModalRowDataTextTitle>
248+
<StyledModalRowDataTextEntries>
249+
{data.map((entry) => {
250+
return <label>{entry}</label>;
251+
})}
252+
</StyledModalRowDataTextEntries>
253+
</StyledModalRowDataText>
254+
);
255+
};
256+
209257
interface ModalInputBoxProps
210258
extends React.InputHTMLAttributes<HTMLInputElement> {
211259
ref: React.RefObject<HTMLInputElement>;

src/components/Modals/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export {
88
ModalInputDropArea,
99
ModalInputSelectIcon,
1010
ModalActionList,
11+
ModalRowDataText,
1112
} from "./Modal";
1213
export { default as DeleteModal } from "./DeleteModal";
1314
export { default as NewFileModal } from "./NewFileModal";

src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ export {
1919
ModalEditableList,
2020
ModalInputDropArea,
2121
ModalInputSelectIcon,
22-
ModalActionList
22+
ModalActionList,
23+
ModalRowDataText,
2324
} from "./components";
2425
export {
2526
ThemeProvider,

src/types/modal.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
export type ModelRowTypes = "all" | "buttons" | "input" | "list";
1+
export type ModelRowTypes =
2+
| "all"
3+
| "buttons"
4+
| "input"
5+
| "list"
6+
| "img"
7+
| "text";
28

39
export interface ModalInputSelectIconEntry {
410
id: string;

0 commit comments

Comments
 (0)