feat: add /trainings page
- list of trainings - add button (taken from github: vojtechmares/website) - add currency formatter
This commit is contained in:
parent
40b68902f7
commit
623b018a1b
3 changed files with 201 additions and 0 deletions
78
src/components/Button.tsx
Normal file
78
src/components/Button.tsx
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
import Link from "next/link";
|
||||
import { ReactNode } from "react";
|
||||
|
||||
function classNames(...classes: any) {
|
||||
return classes.filter(Boolean).join(' ')
|
||||
}
|
||||
|
||||
const baseStyles = {
|
||||
solid:
|
||||
"group inline-flex items-center justify-center rounded-md font-semibold focus:outline-none focus-visible:outline-2 focus-visible:outline-offset-2",
|
||||
outline:
|
||||
"group inline-flex ring-1 items-center justify-center rounded-md focus:outline-none",
|
||||
};
|
||||
|
||||
const variantStyles = {
|
||||
solid: {
|
||||
black:
|
||||
"bg-black text-white hover:bg-gray-700 active:bg-gray-800 focus-visible:outline-gray-900",
|
||||
amber:
|
||||
"bg-amber-500 text-white hover:bg-amber-600 active:bg-amber-800 focus-visible:outline-amber-500",
|
||||
white:
|
||||
"bg-white text-black hover:bg-amber-50 active:bg-amber-200 focus-visible:outline-white",
|
||||
},
|
||||
outline: {
|
||||
black:
|
||||
"ring-gray-200 text-black hover:ring-gray-300 active:bg-gray-100 focus-visible:outline-amber-500 focus-visible:ring-gray-300",
|
||||
white:
|
||||
"ring-gray-700 text-white hover:ring-gray-500 active:ring-gray-700 focus-visible:outline-white",
|
||||
amber: "", // Outline buttons cannot be amber
|
||||
},
|
||||
};
|
||||
|
||||
const transitionStyle = "transition duration-150 ease-in-out";
|
||||
|
||||
const sizeStyles = {
|
||||
medium: "px-4 py-2 text-sm",
|
||||
large: "px-8 py-4 text-base",
|
||||
};
|
||||
|
||||
type Props = {
|
||||
variant?: "solid" | "outline";
|
||||
color?: "black" | "white" | "amber";
|
||||
size?: "medium" | "large";
|
||||
className?: string;
|
||||
href?: string;
|
||||
children?: ReactNode;
|
||||
};
|
||||
|
||||
export function Button({
|
||||
variant = "solid",
|
||||
color = "black",
|
||||
size = "medium",
|
||||
className,
|
||||
href,
|
||||
children,
|
||||
}: Props) {
|
||||
if (variant === "outline" && color === "amber") {
|
||||
throw new Error("Outline buttons cannot be amber");
|
||||
}
|
||||
|
||||
className = classNames(
|
||||
baseStyles[variant],
|
||||
variantStyles[variant][color],
|
||||
sizeStyles[size],
|
||||
transitionStyle,
|
||||
className
|
||||
);
|
||||
|
||||
if (href !== undefined) {
|
||||
return (
|
||||
<Link href={href} className={className}>
|
||||
{children}
|
||||
</Link>
|
||||
);
|
||||
} else {
|
||||
return <button className={className}>{children}</button>;
|
||||
}
|
||||
}
|
||||
Reference in a new issue