first commit
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
.selectableServiceItem {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
border: none;
|
||||
border-radius: 7px;
|
||||
padding: 15px;
|
||||
cursor: pointer;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.selectableServiceItemActive {
|
||||
color: var(--white);
|
||||
animation: serviceItemActiveAnimation 0.2s ease forwards;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
@keyframes serviceItemActiveAnimation {
|
||||
0% {
|
||||
background: var(--white-dark);
|
||||
background: radial-gradient(circle, var(--wine-darkest) 0%, var(--white-dark) 0%);
|
||||
}
|
||||
25% {
|
||||
background: var(--white-dark);
|
||||
background: radial-gradient(circle, var(--wine-darkest) 10%, var(--white-dark) 25%);
|
||||
}
|
||||
50% {
|
||||
background: var(--white-dark);
|
||||
background: radial-gradient(circle, var(--wine-darkest) 20%, var(--white-dark) 50%);
|
||||
}
|
||||
|
||||
75% {
|
||||
background: var(--white-dark);
|
||||
background: radial-gradient(circle, var(--wine-darkest) 50%, var(--white-dark) 75%);
|
||||
}
|
||||
90% {
|
||||
background: var(--white-dark);
|
||||
background: radial-gradient(circle, var(--wine-darkest) 80%, var(--white-dark) 90%);
|
||||
}
|
||||
100% {
|
||||
background: var(--wine-darkest);
|
||||
background: linear-gradient(180deg, var(--wine-darkest) 0%, var(--wine-dark) 100%);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes serviceItemInActiveAnimation {
|
||||
0% {
|
||||
background: var(--white-dark);
|
||||
background: radial-gradient(circle, var(--wine-darkest) 0%, var(--white-dark) 100%);
|
||||
}
|
||||
100% {
|
||||
background: var(--white-dark);
|
||||
background: radial-gradient(circle, var(--white-dark) 100%, var(--white-dark) 100%);
|
||||
}
|
||||
}
|
||||
|
||||
.selectableServiceItemInactive {
|
||||
color: var(--black);
|
||||
animation: serviceItemInActiveAnimation 0.2s ease forwards;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.selectableServiceItem h1 {
|
||||
font-size: 16px;
|
||||
font-weight: 700;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.selectableServiceItem p {
|
||||
font-size: 14px;
|
||||
font-weight: 400;
|
||||
padding-top: 5px;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.selectableServiceItem span {
|
||||
padding-top: 10px;
|
||||
font-size: 14px;
|
||||
font-weight: 700;
|
||||
text-align: right;
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
"use client";
|
||||
import { CollaboratorServiceItems } from "@models/Collaborators.model";
|
||||
import style from "./SelectableServiceItem.module.css";
|
||||
import { formatPrice } from "@helpers/Numbers";
|
||||
import { useState } from "react";
|
||||
import classNames from "classnames";
|
||||
|
||||
export interface SelectableServiceItemProps {
|
||||
data: CollaboratorServiceItems;
|
||||
onChange?: (serviceId: string, active: boolean) => void;
|
||||
}
|
||||
|
||||
export default function SelectableServiceItem(
|
||||
props: SelectableServiceItemProps
|
||||
): React.ReactElement {
|
||||
const [active, setActive] = useState(props.data.active);
|
||||
|
||||
const getClassesNames = () => {
|
||||
const classList: classNames.ArgumentArray = [];
|
||||
|
||||
classList.push(style.selectableServiceItem);
|
||||
|
||||
if (active) {
|
||||
classList.push(style.selectableServiceItemActive);
|
||||
} else {
|
||||
classList.push(style.selectableServiceItemInactive);
|
||||
}
|
||||
return classNames(classList);
|
||||
};
|
||||
|
||||
const handleClick = () => {
|
||||
setActive(!active);
|
||||
if (!props.onChange) {
|
||||
return;
|
||||
}
|
||||
props.onChange(props.data.id, !active);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className={getClassesNames()} onClick={handleClick}>
|
||||
<h1>{props.data.name}</h1>
|
||||
<p>{props.data.description}</p>
|
||||
<span>{formatPrice(props.data.price)}</span>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user