✨ clean repo eady for api backend
This commit is contained in:
parent
910a5820b0
commit
908963aa5a
1
.gitignore
vendored
1
.gitignore
vendored
@ -35,3 +35,4 @@ yarn-error.log*
|
|||||||
# typescript
|
# typescript
|
||||||
*.tsbuildinfo
|
*.tsbuildinfo
|
||||||
next-env.d.ts
|
next-env.d.ts
|
||||||
|
node_modules
|
||||||
|
@ -20,6 +20,5 @@ export default class LogOutButton extends React.Component<IProps, IState> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private disconnect() {
|
private disconnect() {
|
||||||
console.log("disconnected");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,26 @@
|
|||||||
import Modal, { IModalProps } from "..";
|
import React from "react";
|
||||||
|
import Modal, { IProps as IPropsModal } from "..";
|
||||||
import Button, { EButtonVariant } from "../../Button";
|
import Button, { EButtonVariant } from "../../Button";
|
||||||
import classes from "./classes.module.scss";
|
import classes from "./classes.module.scss";
|
||||||
|
|
||||||
type IProps = IModalProps & {
|
type IProps = IPropsModal & {
|
||||||
closeText: string | JSX.Element;
|
closeText: string | JSX.Element;
|
||||||
};
|
};
|
||||||
export default class Alert extends Modal<IProps> {
|
|
||||||
|
type IState = {
|
||||||
|
isOpen: boolean;
|
||||||
|
};
|
||||||
|
export default class Alert extends React.Component<IProps, IState> {
|
||||||
static defaultProps = {
|
static defaultProps = {
|
||||||
closeText: "Ok",
|
closeText: "Ok",
|
||||||
|
...Modal.defaultProps
|
||||||
};
|
};
|
||||||
|
|
||||||
constructor(props: IProps) {
|
constructor(props: IProps) {
|
||||||
super(props);
|
super(props);
|
||||||
|
this.state = {
|
||||||
|
isOpen: this.props.isOpen ?? true,
|
||||||
|
}
|
||||||
this.onClose = this.onClose.bind(this);
|
this.onClose = this.onClose.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -21,7 +29,7 @@ export default class Alert extends Modal<IProps> {
|
|||||||
<Modal
|
<Modal
|
||||||
closeBtn={this.props.closeBtn}
|
closeBtn={this.props.closeBtn}
|
||||||
isOpen={this.state.isOpen}
|
isOpen={this.state.isOpen}
|
||||||
onClose={this.props.onClose}
|
onClose={this.onClose}
|
||||||
header={this.props.header}
|
header={this.props.header}
|
||||||
footer={this.footer()}>
|
footer={this.footer()}>
|
||||||
{this.props.children}
|
{this.props.children}
|
||||||
@ -40,7 +48,7 @@ export default class Alert extends Modal<IProps> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private onClose() {
|
private onClose() {
|
||||||
this.close();
|
this.setState({ isOpen: false });
|
||||||
this.props.onClose?.();
|
this.props.onClose?.();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,40 +1,37 @@
|
|||||||
import Button, { EButtonVariant } from "../../Button";
|
import Button, { EButtonVariant } from "../../Button";
|
||||||
import Modal, { IModalProps } from "..";
|
import Modal, { IProps as IPropsModal } from "..";
|
||||||
import classes from "./classes.module.scss";
|
import classes from "./classes.module.scss";
|
||||||
|
import React from "react";
|
||||||
|
|
||||||
type IProps = IModalProps & {
|
type IProps = IPropsModal & {
|
||||||
onAccept?: () => void;
|
onAccept?: () => void;
|
||||||
onCancel?: () => void;
|
|
||||||
cancelText: string | JSX.Element;
|
cancelText: string | JSX.Element;
|
||||||
confirmText: string | JSX.Element;
|
confirmText: string | JSX.Element;
|
||||||
showCancelButton: boolean;
|
showCancelButton: boolean;
|
||||||
isConfirmButtonDisabled: boolean;
|
isConfirmButtonDisabled: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
type IState = {
|
type IState = {};
|
||||||
isOpen: boolean;
|
|
||||||
};
|
export default class Confirm extends React.Component<IProps, IState> {
|
||||||
export default class Confirm extends Modal<IProps, IState> {
|
static defaultProps = {
|
||||||
static defaultProps: Partial<IProps> = {
|
|
||||||
showCancelButton: true,
|
showCancelButton: true,
|
||||||
cancelText: "Cancel",
|
cancelText: "Cancel",
|
||||||
confirmText: "Confirm",
|
confirmText: "Confirm",
|
||||||
isConfirmButtonDisabled: false,
|
isConfirmButtonDisabled: false,
|
||||||
|
...Modal.defaultProps
|
||||||
};
|
};
|
||||||
|
|
||||||
constructor(props: IProps) {
|
|
||||||
super(props);
|
|
||||||
this.onCancel = this.onCancel.bind(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override render(): JSX.Element | null {
|
public override render(): JSX.Element | null {
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
closeBtn={this.props.closeBtn}
|
closeBtn={this.props.closeBtn}
|
||||||
isOpen={this.state.isOpen}
|
isOpen={this.props.isOpen}
|
||||||
onClose={this.props.onClose}
|
onClose={this.props.onClose}
|
||||||
header={this.props.header}
|
header={this.props.header}
|
||||||
footer={this.footer()}>
|
footer={this.footer()}
|
||||||
|
animationDelay={this.props.animationDelay}
|
||||||
|
>
|
||||||
{this.props.children}
|
{this.props.children}
|
||||||
</Modal>
|
</Modal>
|
||||||
);
|
);
|
||||||
@ -43,8 +40,9 @@ export default class Confirm extends Modal<IProps, IState> {
|
|||||||
private footer(): JSX.Element {
|
private footer(): JSX.Element {
|
||||||
return (
|
return (
|
||||||
<div className={classes["buttons-container"]}>
|
<div className={classes["buttons-container"]}>
|
||||||
|
|
||||||
{this.props.showCancelButton && (
|
{this.props.showCancelButton && (
|
||||||
<Button variant={EButtonVariant.GHOST} onClick={this.onCancel}>
|
<Button variant={EButtonVariant.GHOST} onClick={this.props.onClose}>
|
||||||
{this.props.cancelText}
|
{this.props.cancelText}
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
@ -55,9 +53,4 @@ export default class Confirm extends Modal<IProps, IState> {
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private onCancel() {
|
|
||||||
this.close();
|
|
||||||
this.props.onCancel?.();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,27 @@
|
|||||||
@import "@Themes/constants.scss";
|
@import "@Themes/constants.scss";
|
||||||
|
|
||||||
|
@keyframes smooth-appear {
|
||||||
|
from {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
to {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes smooth-disappear {
|
||||||
|
from {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
to {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.root {
|
.root {
|
||||||
|
--animation-delay: 1ms;
|
||||||
position: fixed;
|
position: fixed;
|
||||||
z-index: 6;
|
z-index: 6;
|
||||||
top: 0;
|
top: 0;
|
||||||
@ -10,6 +31,11 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
animation: smooth-appear var(--animation-delay) $custom-easing;
|
||||||
|
|
||||||
|
&[data-will-close="true"] {
|
||||||
|
animation: smooth-disappear var(--animation-delay) $custom-easing;
|
||||||
|
}
|
||||||
|
|
||||||
.background {
|
.background {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
@ -18,16 +44,6 @@
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
background-color: $modal-background;
|
background-color: $modal-background;
|
||||||
animation: smooth-appear 1s ease forwards;
|
|
||||||
|
|
||||||
@keyframes smooth-appear {
|
|
||||||
from {
|
|
||||||
opacity: 0;
|
|
||||||
}
|
|
||||||
to {
|
|
||||||
opacity: 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.container {
|
.container {
|
||||||
@ -38,16 +54,6 @@
|
|||||||
box-shadow: 0px 6px 12px rgba(255, 255, 255, 0.11);
|
box-shadow: 0px 6px 12px rgba(255, 255, 255, 0.11);
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
padding: 32px;
|
padding: 32px;
|
||||||
animation: smooth-appear 1s ease forwards;
|
|
||||||
|
|
||||||
@keyframes smooth-appear {
|
|
||||||
from {
|
|
||||||
opacity: 0;
|
|
||||||
}
|
|
||||||
to {
|
|
||||||
opacity: 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (max-width: $screen-s) {
|
@media (max-width: $screen-s) {
|
||||||
width: 90%;
|
width: 90%;
|
||||||
@ -115,4 +121,4 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -8,42 +8,47 @@ import Typography, { ITypo } from "../Typography";
|
|||||||
import CrossIcon from "@Assets/icons/cross.svg";
|
import CrossIcon from "@Assets/icons/cross.svg";
|
||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
|
|
||||||
export type IModalProps = {
|
export type IProps = {
|
||||||
closeBtn?: boolean;
|
closeBtn?: boolean;
|
||||||
header?: string | JSX.Element;
|
header?: string | JSX.Element;
|
||||||
footer?: JSX.Element;
|
footer?: JSX.Element;
|
||||||
textLoader?: string | JSX.Element;
|
textLoader?: string | JSX.Element;
|
||||||
isOpen: boolean;
|
isOpen: boolean;
|
||||||
onClose?: () => void;
|
onClose: () => void;
|
||||||
hasTransparentBackground?: boolean;
|
hasTransparentBackground?: boolean;
|
||||||
hasContainerClosable?: boolean;
|
hasContainerClosable?: boolean;
|
||||||
withSideBackground?: boolean;
|
withSideBackground?: boolean;
|
||||||
children?: React.ReactNode;
|
children?: React.ReactNode;
|
||||||
|
animationDelay?: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
type IState = {
|
type IState = {
|
||||||
isOpen: boolean;
|
willClose: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default class Modal<P extends IModalProps, S extends IState = IState> extends React.Component<P, S> {
|
export default class Modal extends React.Component<IProps, IState> {
|
||||||
constructor(props: P) {
|
static defaultProps = {
|
||||||
|
animationDelay: 170
|
||||||
|
};
|
||||||
|
public rootRefElement = React.createRef<HTMLDivElement>();
|
||||||
|
constructor(props: IProps) {
|
||||||
super(props);
|
super(props);
|
||||||
this.close = this.close.bind(this);
|
this.close = this.close.bind(this);
|
||||||
|
|
||||||
(this.state as any) = {
|
this.state = {
|
||||||
isOpen: props.isOpen ?? true,
|
willClose: false
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public override render(): JSX.Element | null {
|
public override render(): JSX.Element | null {
|
||||||
if (!this.state.isOpen) return null;
|
if (!this.props.isOpen) return null;
|
||||||
|
const onClick = (this.props.hasContainerClosable && this.close) || (() => { });
|
||||||
return (
|
return (
|
||||||
<div className={classes["root"]} data-side-background={this.props.withSideBackground}>
|
<div ref={this.rootRefElement} className={classes["root"]} data-side-background={this.props.withSideBackground} data-will-close={this.state.willClose.toString()}>
|
||||||
<div className={classes["background"]} onClick={this.close} />
|
<div className={classes["background"]} onClick={this.close} />
|
||||||
<div
|
<div
|
||||||
className={[classes["container"], this.props.hasTransparentBackground && classes["transparant-background"]].join(" ")}
|
className={[classes["container"], this.props.hasTransparentBackground && classes["transparant-background"]].join(" ")}
|
||||||
onClick={this.props.hasContainerClosable && this.close}>
|
onClick={onClick} >
|
||||||
{this.props.closeBtn && (
|
{this.props.closeBtn && (
|
||||||
<div className={classes["cross"]}>
|
<div className={classes["cross"]}>
|
||||||
<Image alt="Unplugged" src={CrossIcon} className={classes["close-icon"]} onClick={this.close} />
|
<Image alt="Unplugged" src={CrossIcon} className={classes["close-icon"]} onClick={this.close} />
|
||||||
@ -62,18 +67,18 @@ export default class Modal<P extends IModalProps, S extends IState = IState> ext
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override componentDidUpdate(prevProps: Readonly<P>): void {
|
public override componentDidUpdate(): void {
|
||||||
if (prevProps.isOpen !== this.props.isOpen) {
|
this.rootRefElement.current?.style.setProperty("--animation-delay", this.props.animationDelay!.toString().concat("ms"));
|
||||||
this.setState({
|
|
||||||
isOpen: this.props.isOpen,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected close() {
|
protected close() {
|
||||||
this.setState({
|
if (this.state.willClose) return;
|
||||||
isOpen: false,
|
this.setState({ willClose: true })
|
||||||
});
|
window.setTimeout(() => {
|
||||||
this.props.onClose?.();
|
this.setState({
|
||||||
|
willClose: false
|
||||||
|
})
|
||||||
|
this.props.onClose()
|
||||||
|
}, this.props.animationDelay)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user