Added highlight color

This commit is contained in:
DrMint 2022-05-21 06:42:07 +02:00
parent 58bd46f25d
commit 9a5f4e5576
2 changed files with 19 additions and 12 deletions

View File

@ -11,27 +11,28 @@ interface Props {
} }
export function Select(props: Immutable<Props>): JSX.Element { export function Select(props: Immutable<Props>): JSX.Element {
const { className, state, options, allowEmpty, setState } = props;
const [opened, setOpened] = useState(false); const [opened, setOpened] = useState(false);
return ( return (
<div <div
className={`relative text-center transition-[filter] ${ className={`relative text-center transition-[filter] ${
opened && "drop-shadow-shade-lg z-10" opened && "drop-shadow-shade-lg z-10"
} ${props.className}`} } ${className}`}
> >
<div <div
className={`outline outline-mid outline-2 outline-offset-[-2px] hover:outline-[transparent] className={`outline outline-mid outline-2 outline-offset-[-2px] hover:outline-[transparent]
bg-light rounded-[1em] p-1 grid grid-flow-col grid-cols-[1fr_auto_auto] place-items-center bg-light rounded-[1em] p-1 grid grid-flow-col grid-cols-[1fr_auto_auto] place-items-center
cursor-pointer hover:bg-mid transition-all ${ cursor-pointer hover:bg-mid transition-all ${
opened && "outline-[transparent] rounded-b-none" opened && "outline-[transparent] rounded-b-none bg-highlight"
}`} }`}
> >
<p onClick={() => setOpened(!opened)} className="w-full"> <p onClick={() => setOpened(!opened)} className="w-full">
{props.state === -1 ? "—" : props.options[props.state]} {state === -1 ? "—" : options[state]}
</p> </p>
{props.state >= 0 && props.allowEmpty && ( {state >= 0 && allowEmpty && (
<span <span
onClick={() => props.setState(-1)} onClick={() => setState(-1)}
className="material-icons !text-xs" className="material-icons !text-xs"
> >
close close
@ -46,17 +47,18 @@ export function Select(props: Immutable<Props>): JSX.Element {
opened ? "absolute" : "hidden" opened ? "absolute" : "hidden"
}`} }`}
> >
{props.options.map((option, index) => ( {options.map((option, index) => (
<Fragment key={index}> <Fragment key={index}>
{index !== props.state && ( {index !== state && (
<div <div
className="bg-light hover:bg-mid transition-colors className={` ${
cursor-pointer p-1 last-of-type:rounded-b-[1em]" opened ? "bg-highlight" : "bg-light"
} hover:bg-mid transition-colors
cursor-pointer p-1 last-of-type:rounded-b-[1em]`}
id={option} id={option}
onClick={() => { onClick={() => {
setOpened(false); setOpened(false);
props.setState(index); setState(index);
}} }}
> >
{option} {option}

View File

@ -2,16 +2,18 @@ const plugin = require("tailwindcss/plugin");
/* CONFIG */ /* CONFIG */
const hightlight = { r: 255, g: 241, b: 224 };
const light = { r: 255, g: 237, b: 216 }; const light = { r: 255, g: 237, b: 216 };
const mid = { r: 240, g: 209, b: 179 }; const mid = { r: 240, g: 209, b: 179 };
const dark = { r: 156, g: 102, b: 68 }; const dark = { r: 156, g: 102, b: 68 };
const shade = { r: 156, g: 102, b: 68 }; const shade = { r: 156, g: 102, b: 68 };
const black = { r: 27, g: 24, b: 17 }; const black = { r: 27, g: 24, b: 17 };
const dark_highlight = { r: 44, g: 40, b: 37 };
const dark_light = { r: 38, g: 34, b: 30 }; const dark_light = { r: 38, g: 34, b: 30 };
const dark_mid = { r: 57, g: 45, b: 34 }; const dark_mid = { r: 57, g: 45, b: 34 };
const dark_dark = { r: 192, g: 132, b: 94 }; const dark_dark = { r: 192, g: 132, b: 94 };
const dark_shade = { r: 12, g: 6, b: 4 }; const dark_shade = { r: 0, g: 0, b: 0 };
const dark_black = { r: 235, g: 234, b: 231 }; const dark_black = { r: 235, g: 234, b: 231 };
const breakDektop = { min: "60rem" }; const breakDektop = { min: "60rem" };
@ -45,6 +47,7 @@ module.exports = {
content: ["./src/**/*.{tsx,ts}"], content: ["./src/**/*.{tsx,ts}"],
theme: { theme: {
colors: { colors: {
highlight: withOpacity("--theme-color-highlight"),
light: withOpacity("--theme-color-light"), light: withOpacity("--theme-color-light"),
mid: withOpacity("--theme-color-mid"), mid: withOpacity("--theme-color-mid"),
dark: withOpacity("--theme-color-dark"), dark: withOpacity("--theme-color-dark"),
@ -75,6 +78,7 @@ module.exports = {
plugin(function ({ addUtilities }) { plugin(function ({ addUtilities }) {
addUtilities({ addUtilities({
".set-theme-light": { ".set-theme-light": {
"--theme-color-highlight": `${hightlight.r}, ${hightlight.g}, ${hightlight.b}`,
"--theme-color-light": `${light.r}, ${light.g}, ${light.b}`, "--theme-color-light": `${light.r}, ${light.g}, ${light.b}`,
"--theme-color-mid": `${mid.r}, ${mid.g}, ${mid.b}`, "--theme-color-mid": `${mid.r}, ${mid.g}, ${mid.b}`,
"--theme-color-dark": `${dark.r}, ${dark.g}, ${dark.b}`, "--theme-color-dark": `${dark.r}, ${dark.g}, ${dark.b}`,
@ -84,6 +88,7 @@ module.exports = {
"--theme-texture-dots-blend": `multiply`, "--theme-texture-dots-blend": `multiply`,
}, },
".set-theme-dark": { ".set-theme-dark": {
"--theme-color-highlight": `${dark_highlight.r}, ${dark_highlight.g}, ${dark_highlight.b}`,
"--theme-color-light": `${dark_light.r}, ${dark_light.g}, ${dark_light.b}`, "--theme-color-light": `${dark_light.r}, ${dark_light.g}, ${dark_light.b}`,
"--theme-color-mid": `${dark_mid.r}, ${dark_mid.g}, ${dark_mid.b}`, "--theme-color-mid": `${dark_mid.r}, ${dark_mid.g}, ${dark_mid.b}`,
"--theme-color-dark": `${dark_dark.r}, ${dark_dark.g}, ${dark_dark.b}`, "--theme-color-dark": `${dark_dark.r}, ${dark_dark.g}, ${dark_dark.b}`,