Skip to content

Commit

Permalink
change reload to restart
Browse files Browse the repository at this point in the history
  • Loading branch information
Rachel Braverman committed Feb 26, 2024
1 parent ac02ed7 commit d767a68
Show file tree
Hide file tree
Showing 13 changed files with 51 additions and 66 deletions.

This file was deleted.

4 changes: 2 additions & 2 deletions library/math/numbersLine/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Toolbar from "./components/Toolbar";
import ShowElements from "./components/ShowElements";
import { useNumbersLineContext } from "./context/numbersLineContext";
import { useEffect } from "react";
import Reload from "./components/Reload";
import Restart from "./components/Restart";

const App = () => {
const { setIdDraggElementClick } = useNumbersLineContext();
Expand All @@ -24,7 +24,7 @@ const App = () => {
return (
<>
<ShowElements />
<Reload />
<Restart />
<div className="flex flex-col h-full justify-between">
<Toolbar />
<div>
Expand Down
34 changes: 0 additions & 34 deletions library/math/numbersLine/src/components/Reload.tsx

This file was deleted.

32 changes: 32 additions & 0 deletions library/math/numbersLine/src/components/Restart.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
} from "./ui/alert-dialog";
import { useNumbersLineContext } from "../context/numbersLineContext";
import { useAction } from "../hooks/useAction";

const Restart = () => {
const { typeRuler, openRestartDialog, setOpenRestartDialog, setTypeRulerChange } = useNumbersLineContext();
const { initialization } = useAction();

return (
<AlertDialog open={openRestartDialog} onOpenChange={setOpenRestartDialog}>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>?אתם רוצים להתחיל מחדש</AlertDialogTitle>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel onClick={() => setTypeRulerChange(typeRuler)}>הישארו</AlertDialogCancel>
<AlertDialogAction onClick={initialization}>מחק הכל</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
);
};

export default Restart;
10 changes: 5 additions & 5 deletions library/math/numbersLine/src/components/toolbar/IconsToolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ const IconsToolbar = ({ typeAction, iconUrl, isDragged }: IProps) => {
dragElements,
setDragElements,
idDraggElementClick,
openReloadDialog,
setOpenReloadDialog,
openRestartDialog,
setOpenRestartDialog,
visitableDisplayButton,
} = useNumbersLineContext();
const wrapperRef = useRef<HTMLDivElement>(null);
Expand All @@ -45,8 +45,8 @@ const IconsToolbar = ({ typeAction, iconUrl, isDragged }: IProps) => {
}, [idDraggElementClick]);

const getSrc = () => {
const isClicked = typeAction === ActionTypes.reload ? openReloadDialog : isOpen;
const isDisabled = typeAction === ActionTypes.reload && dragElements.length == 0 && visitableDisplayButton == TypeCover.allDiscover;
const isClicked = typeAction === ActionTypes.restart ? openRestartDialog : isOpen;
const isDisabled = typeAction === ActionTypes.restart && dragElements.length == 0 && visitableDisplayButton == TypeCover.allDiscover;
const dotIndex = iconUrl.indexOf(".");
const beforeDot = iconUrl.substring(0, dotIndex);
return isClicked ? beforeDot + "Open.svg" : isHovered ? beforeDot + "Hover.svg" : isDisabled ? beforeDot + "Disable.svg" : iconUrl;
Expand Down Expand Up @@ -80,7 +80,7 @@ const IconsToolbar = ({ typeAction, iconUrl, isDragged }: IProps) => {
addDraggableElement();
return;
}
typeAction == ActionTypes.reload ? setOpenReloadDialog(true) : setIsOpen((prevOpen) => !prevOpen);
typeAction == ActionTypes.restart ? setOpenRestartDialog(true) : setIsOpen((prevOpen) => !prevOpen);
};

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const LineDefinition = () => {
setLeftPosition,
dragElements,
visitableDisplayButton,
setOpenReloadDialog,
setOpenRestartDialog,
setTypeRulerChange,
} = useNumbersLineContext();
const wrapperRef = useRef<HTMLDivElement>(null);
Expand Down Expand Up @@ -48,7 +48,7 @@ const LineDefinition = () => {
setLeftPosition(0);
} else {
setTypeRulerChange(type);
setOpenReloadDialog(true);
setOpenRestartDialog(true);
}
};

Expand Down
4 changes: 2 additions & 2 deletions library/math/numbersLine/src/consts/elementConsts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import text from "/assets/icons/toolbar/text.svg";
import writing from "/assets/icons/toolbar/writing.svg";
import eye from "/assets/icons/toolbar/eye.svg";
import naviAndKani from "/assets/icons/toolbar/naviAndKani.svg";
import reload from "/assets/icons/toolbar/reload.svg";
import restart from "/assets/icons/toolbar/restart.svg";
import { LineRange } from "@/type/ruler";

export const actionIconsDetials: IActionIcon[] = [
{ type: ActionTypes.naviAndKani, url: naviAndKani, isDragged: true },
{ type: ActionTypes.displayNumbersLine, url: eye },
{ type: ActionTypes.reload, url: reload },
{ type: ActionTypes.restart, url: restart },
{ type: ActionTypes.writing, url: writing },
{ type: ActionTypes.text, url: text, isDragged: true },
{ type: ActionTypes.jump, url: jump, isDragged: true },
Expand Down
14 changes: 7 additions & 7 deletions library/math/numbersLine/src/context/numbersLineContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ interface INumbersLineContextProps {
setCoverSituation: (v: TypeCover) => void;
visitableDisplayButton: TypeCover;
setVisitableDisplayButton: (v: TypeCover) => void;
openReloadDialog: boolean;
setOpenReloadDialog: (v: boolean) => void;
openRestartDialog: boolean;
setOpenRestartDialog: (v: boolean) => void;
}

export const NumbersLineContext = React.createContext({
Expand All @@ -43,8 +43,8 @@ export const NumbersLineContext = React.createContext({
setCoverSituation: () => null,
visitableDisplayButton: {} as TypeCover,
setVisitableDisplayButton: () => null,
openReloadDialog: {} as boolean,
setOpenReloadDialog: () => null,
openRestartDialog: {} as boolean,
setOpenRestartDialog: () => null,
} as INumbersLineContextProps);

export const NumbersLineContexProvider = (props: any) => {
Expand All @@ -56,7 +56,7 @@ export const NumbersLineContexProvider = (props: any) => {
const [idDraggElementClick, setIdDraggElementClick] = useState("");
const [coverSituation, setCoverSituation] = useState(TypeCover.allDiscover);
const [visitableDisplayButton, setVisitableDisplayButton] = useState(TypeCover.allDiscover);
const [openReloadDialog, setOpenReloadDialog] = useState(false);
const [openRestartDialog, setOpenRestartDialog] = useState(false);
const [rulerPaddingSides, setRulerPaddingSides] = useState(RulerPaddingSides);

const Resize = () => {
Expand Down Expand Up @@ -91,8 +91,8 @@ export const NumbersLineContexProvider = (props: any) => {
setCoverSituation,
visitableDisplayButton,
setVisitableDisplayButton,
openReloadDialog,
setOpenReloadDialog,
openRestartDialog,
setOpenRestartDialog,
}}
>
{props.children}
Expand Down
5 changes: 0 additions & 5 deletions library/math/numbersLine/src/lib/stylesUtils.ts

This file was deleted.

2 changes: 1 addition & 1 deletion library/math/numbersLine/src/type/elements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export enum ActionTypes {
writing = "writing",
displayNumbersLine = "displayNumbersLine",
naviAndKani = "naviAndKani",
reload = "reload",
restart = "restart",
}

export interface IActionIcon {
Expand Down

1 comment on commit d767a68

@RachelBra
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

d

Please sign in to comment.