Skip to content

Commit b25e32c

Browse files
committed
Test moving modals
1 parent f0475d3 commit b25e32c

19 files changed

+387
-301
lines changed

package-lock.json

Lines changed: 140 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 & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jderobot-ide-interface",
3-
"version": "0.1.48",
3+
"version": "0.1.49",
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.10",
26+
"@storybook/addon-docs": "^9.0.16",
2727
"@storybook/addon-webpack5-compiler-swc": "^3.0.0",
28-
"@storybook/react-webpack5": "^9.0.10",
28+
"@storybook/react-webpack5": "^9.0.16",
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.10",
37+
"storybook": "^9.0.16",
3838
"styled-components": "^6.1.19",
3939
"ts-loader": "^9.5.2",
4040
"tsconfig-paths-webpack-plugin": "^4.2.0",
@@ -45,7 +45,6 @@
4545
},
4646
"dependencies": {
4747
"@monaco-editor/react": "^4.7.0",
48-
"@storybook/react": "^9.0.12",
4948
"jderobot-commsmanager": "^1.0.3",
5049
"jszip": "^3.10.1",
5150
"lodash": "^4.17.21",
@@ -57,4 +56,4 @@
5756
"react": "18.2.0",
5857
"react-dom": "18.2.0"
5958
}
60-
}
59+
}

src/components/Button/Button.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Meta, StoryObj } from "@storybook/react";
1+
import type { Meta, StoryObj } from "@storybook/react-webpack5";
22
import Button, { MenuButtonStroke, MenuButton } from "./Button";
33
import {
44
ActionTeplateIcon,

src/components/Explorer/Explorer.tsx

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -430,13 +430,24 @@ const Explorer = ({
430430
onRename={handleRename}
431431
/>
432432
</StyledSidebarEntry>
433-
<NewFileModal
434-
isOpen={isNewFileModalOpen}
435-
onSubmit={handleNewActionSubmit}
436-
onClose={handleCloseNewFileModal}
437-
fileList={fileList}
438-
location={selectedLocation}
439-
/>
433+
{api.modals?.createFile ? (
434+
<api.modals.createFile.component
435+
isOpen={isNewFileModalOpen}
436+
onSubmit={api.modals.createFile.onCreate}
437+
onClose={handleCloseNewFileModal}
438+
fileList={fileList}
439+
location={selectedLocation}
440+
project={project}
441+
/>
442+
) : (
443+
<NewFileModal
444+
isOpen={isNewFileModalOpen}
445+
onSubmit={handleNewActionSubmit}
446+
onClose={handleCloseNewFileModal}
447+
fileList={fileList}
448+
location={selectedLocation}
449+
/>
450+
)}
440451
<NewFolderModal
441452
isOpen={isNewFolderModalOpen}
442453
onSubmit={handleCreateFolderSubmit}

src/components/IdeInterface/IdeInterface.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Meta, StoryObj } from "@storybook/react";
1+
import type { Meta, StoryObj } from "@storybook/react-webpack5";
22
import IdeInterface from "./IdeInterface";
33
import { VncViewer } from "Components";
44
import { SaveIcon } from "Assets";

src/components/Modals/DeleteModal.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Meta, StoryObj } from "@storybook/react";
1+
import type { Meta, StoryObj } from "@storybook/react-webpack5";
22
import DeleteModal from "./DeleteModal";
33

44
type Story = StoryObj<typeof DeleteModal>;

src/components/Modals/ErrorModal.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Meta, StoryObj } from "@storybook/react";
1+
import type { Meta, StoryObj } from "@storybook/react-webpack5";
22
import NewFileModal from "./NewFileModal";
33
import Modal, { ModalEditableList, ModalRow, ModalTitlebar } from "./Modal";
44
import ErrorModal from "./ErrorModal";

src/components/Modals/Modal.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Meta, StoryObj } from "@storybook/react";
1+
import type { Meta, StoryObj } from "@storybook/react-webpack5";
22
import NewFileModal from "./NewFileModal";
33
import Modal, { ModalEditableList, ModalRow, ModalTitlebar } from "./Modal";
44

src/components/Modals/Modal.styles.ts

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,3 +447,86 @@ export const StyledModalDropArea = styled.label<StyledModelDropAreaProps>`
447447
448448
${handleActive}
449449
`;
450+
451+
export const StyledModalInputSelectorTitle = styled.label`
452+
width: 100%;
453+
display: block;
454+
border: none;
455+
font-size: large;
456+
font-weight: bold;
457+
text-align: center;
458+
margin: 10px 0px;
459+
`;
460+
461+
export const StyledModalInputSelector = styled.div`
462+
display: flex;
463+
width: 100%;
464+
flex-direction: row;
465+
align-items: center;
466+
justify-content: space-evenly;
467+
`;
468+
469+
interface StyledModalSelectIconProps {
470+
hoverColor?: string;
471+
selectedColor?: string;
472+
color?: string;
473+
roundness?: number;
474+
icon: "fill" | "stroke";
475+
active?: boolean;
476+
}
477+
478+
const handleActiveSelectIcon = (p: StyledModalSelectIconProps) => {
479+
if (p.active) {
480+
return `
481+
background-color: ${p.selectedColor ?? primaryColor} !important;
482+
`;
483+
}
484+
};
485+
486+
const handleIconType = (p: StyledModalSelectIconProps) => {
487+
switch (p.icon) {
488+
case "fill":
489+
return `
490+
fill: ${p.color ?? primaryColor};
491+
`;
492+
case "stroke":
493+
return `
494+
stroke: ${p.color ?? primaryColor};
495+
`;
496+
}
497+
};
498+
499+
export const StyledModalSelectIcon = styled.div<StyledModalSelectIconProps>`
500+
float: left;
501+
width: 30%;
502+
border-radius: ${(p) => p.roundness ?? 1}px;
503+
504+
& div {
505+
border-radius: ${(p) => p.roundness ?? 1}px;
506+
cursor: pointer;
507+
text-align: center;
508+
margin: 3px;
509+
padding: 5px;
510+
${handleActiveSelectIcon}
511+
512+
& svg {
513+
height: 90px;
514+
width: 100%;
515+
${handleIconType}
516+
}
517+
}
518+
519+
&:hover div {
520+
background-color: ${(p) => p.hoverColor ?? primaryColor};
521+
}
522+
523+
& p {
524+
margin: 3px !important;
525+
color: ${(p) => p.color ?? primaryColor};
526+
}
527+
528+
& input[type="radio"] {
529+
display: none;
530+
z-index: 100;
531+
}
532+
`;

src/components/Modals/Modal.tsx

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,14 @@ import {
1010
StyledModalEditableList,
1111
StyledModalInput,
1212
StyledModalInputRowContainer,
13+
StyledModalInputSelector,
14+
StyledModalInputSelectorTitle,
1315
StyledModalRow,
16+
StyledModalSelectIcon,
1417
StyledModalTitlebar,
1518
} from "./Modal.styles";
1619
import { useTheme } from "Utils";
17-
import { ModelRowTypes } from "Types";
20+
import { ModalInputSelectIconEntry, ModelRowTypes } from "Types";
1821

1922
const Modal = ({
2023
id = "modal",
@@ -386,3 +389,56 @@ export const ModalInputDropArea = ({
386389
</StyledModalDropArea>
387390
);
388391
};
392+
393+
interface ModalInputSelectIconProps {
394+
id: string;
395+
title: string;
396+
onChange: (event: any) => void;
397+
selected: string;
398+
entries: ModalInputSelectIconEntry[];
399+
}
400+
401+
export const ModalInputSelectIcon = ({
402+
title,
403+
id,
404+
onChange,
405+
selected,
406+
entries,
407+
}: ModalInputSelectIconProps) => {
408+
const theme = useTheme();
409+
410+
return (
411+
<>
412+
<StyledModalInputSelectorTitle htmlFor={id}>
413+
{title}
414+
</StyledModalInputSelectorTitle>
415+
<StyledModalInputSelector>
416+
{entries.map((entry) => (
417+
<StyledModalSelectIcon
418+
hoverColor={theme.palette.secondary}
419+
selectedColor={theme.palette.primary}
420+
color={theme.palette.text}
421+
roundness={theme.roundness}
422+
icon={entry.iconType}
423+
active={selected === entry.id}
424+
>
425+
<label>
426+
<input
427+
type="radio"
428+
name={id}
429+
value={entry.id}
430+
id={entry.id}
431+
checked={selected === entry.id}
432+
onChange={onChange}
433+
/>
434+
<div id={"button-" + entry.id}>
435+
{entry.icon}
436+
<p> {entry.title} </p>
437+
</div>
438+
</label>
439+
</StyledModalSelectIcon>
440+
))}
441+
</StyledModalInputSelector>
442+
</>
443+
);
444+
};

0 commit comments

Comments
 (0)