first commit
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
.buttonSave {
|
||||
position: fixed;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
bottom: 75px;
|
||||
right: 15px;
|
||||
background-color: var(--wine-dark);
|
||||
color: var(--white);
|
||||
border-radius: 50%;
|
||||
z-index: 2000;
|
||||
cursor: pointer;
|
||||
transition: width 0.25s ease-in-out, height 0.25s ease-in-out;
|
||||
animation: buttonSabePulseShadow 1.5s ease-in-out infinite;
|
||||
}
|
||||
|
||||
.buttonSaveVisible {
|
||||
width: 64px;
|
||||
height: 64px;
|
||||
}
|
||||
|
||||
.buttonSaveVisible svg {
|
||||
display: flex;
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.buttonSaveHidden {
|
||||
width: 0px;
|
||||
height: 0px;
|
||||
}
|
||||
|
||||
.buttonSaveHidden svg {
|
||||
display: none;
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
@keyframes buttonSabePulseShadow {
|
||||
0%,
|
||||
100% {
|
||||
box-shadow: 0px 2px 12px -4px var(--wine-red);
|
||||
}
|
||||
50% {
|
||||
box-shadow: 0px 2px 20px -2px var(--wine-red);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
"use client";
|
||||
import { ReactNode, useEffect, useState } from "react";
|
||||
import style from "./Saveable.module.css";
|
||||
import { EVENT_TYPES, useEventHandlerStore } from "@store/EventHandler.Store";
|
||||
import SaveIcon from "@mui/icons-material/Save";
|
||||
import classNames from "classnames";
|
||||
|
||||
interface SaveableProps {
|
||||
children?: ReactNode;
|
||||
onClick?: () => void;
|
||||
}
|
||||
|
||||
export default function Saveable(props: SaveableProps): React.ReactElement {
|
||||
const eventHandler = useEventHandlerStore();
|
||||
const [buttonClassNames, setButtonClassNames] = useState(
|
||||
classNames(style.buttonSave, style.buttonSaveHidden)
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (eventHandler.eventType === EVENT_TYPES.NEED_SAVE) {
|
||||
setButtonClassNames(classNames(style.buttonSave, style.buttonSaveVisible));
|
||||
} else {
|
||||
setButtonClassNames(classNames(style.buttonSave, style.buttonSaveHidden));
|
||||
}
|
||||
}, [eventHandler.eventType]);
|
||||
|
||||
return (
|
||||
<>
|
||||
{props.children}
|
||||
<div
|
||||
className={buttonClassNames}
|
||||
onClick={() => {
|
||||
if (props.onClick) {
|
||||
props.onClick();
|
||||
return;
|
||||
}
|
||||
eventHandler.setEventType(EVENT_TYPES.SAVE);
|
||||
}}
|
||||
>
|
||||
<SaveIcon />
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user