Skip to content

Commit 99a6f2c

Browse files
committed
Test new component
1 parent ffa3431 commit 99a6f2c

File tree

4 files changed

+124
-56
lines changed

4 files changed

+124
-56
lines changed

package-lock.json

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

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jderobot-ide-interface",
3-
"version": "0.1.55",
3+
"version": "0.1.56",
44
"main": "dist/main.js",
55
"typings": "dist/index.d.ts",
66
"files": [
@@ -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.16",
26+
"@storybook/addon-docs": "^9.0.18",
2727
"@storybook/addon-webpack5-compiler-swc": "^3.0.0",
28-
"@storybook/react-webpack5": "^9.0.16",
28+
"@storybook/react-webpack5": "^9.0.18",
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.16",
37+
"storybook": "^9.0.18",
3838
"styled-components": "^6.1.19",
3939
"ts-loader": "^9.5.2",
4040
"tsconfig-paths-webpack-plugin": "^4.2.0",
@@ -56,4 +56,4 @@
5656
"react": "18.2.0",
5757
"react-dom": "18.2.0"
5858
}
59-
}
59+
}

src/components/Modals/Modal.styles.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,14 @@ export const StyledModalEditableList = styled.ul<StyledModalEditableListProps>`
368368
}
369369
`;
370370

371+
interface StyledModalActionListProps {
372+
bgColor?: string;
373+
}
374+
375+
export const StyledModalActionList = styled.div<StyledModalActionListProps>`
376+
background-color: ${(p) => p.bgColor ?? primaryColor} !important;
377+
`;
378+
371379
interface StyledModelDropAreaProps {
372380
text?: string;
373381
bgColor?: string;

src/components/Modals/Modal.tsx

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { useRef, useEffect, useState, ReactNode } from "react";
22
import {
33
StyledModal,
4+
StyledModalActionList,
45
StyledModalBackButton,
56
StyledModalButtonRow,
67
StyledModalCloseButton,
@@ -301,6 +302,65 @@ export const ModalEditableList = ({
301302
);
302303
};
303304

305+
export const ModalActionList = ({
306+
list,
307+
title,
308+
onSelect,
309+
}: {
310+
list: {name: string, component: JSX.Element}[];
311+
title?: string;
312+
onSelect: (event: any, entry: string) => void;
313+
}) => {
314+
const theme = useTheme();
315+
const [isOpen, open] = useState<string | undefined>(undefined);
316+
317+
const openActionModal = (entry: string) => {
318+
if (isOpen === entry) {
319+
open(undefined);
320+
} else {
321+
open(entry);
322+
}
323+
};
324+
325+
return (
326+
<>
327+
{title && (
328+
<StyledModalInputSelectorTitle>{title}</StyledModalInputSelectorTitle>
329+
)}
330+
<StyledModalEditableList
331+
bgColor={theme.palette.background}
332+
color={theme.palette.text}
333+
scrollBarColor={theme.palette.scrollbar}
334+
entryColor={theme.palette.primary}
335+
hoverColor={theme.palette.secondary}
336+
deleteColor={theme.palette.button.error}
337+
roundness={theme.roundness}
338+
>
339+
{list.map((entry) => {
340+
return (
341+
<>
342+
<div
343+
id={"list-" + entry.name}
344+
onClick={(e: any) => openActionModal(entry.name)}
345+
>
346+
<label>{entry.name}</label>
347+
</div>
348+
{isOpen === entry.name && (
349+
<StyledModalActionList
350+
id={"list-open-" + entry.name}
351+
bgColor={theme.palette.background}
352+
>
353+
{entry.component}
354+
</StyledModalActionList>
355+
)}
356+
</>
357+
);
358+
})}
359+
</StyledModalEditableList>
360+
</>
361+
);
362+
};
363+
304364
interface ModalInputDropdownProps extends ModalInputBoxProps {
305365
entries?: string[];
306366
}

0 commit comments

Comments
 (0)