StyleInput: update style and use react-dropdown-select
This commit is contained in:
93
src/components/StyleInput/StyleInput.css
Normal file
93
src/components/StyleInput/StyleInput.css
Normal file
@@ -0,0 +1,93 @@
|
||||
/* .style-select {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.style-select {
|
||||
background-color: gold;
|
||||
border-radius: 24px;
|
||||
box-shadow: 4px 4px #ccc;
|
||||
display: none;
|
||||
}
|
||||
|
||||
.style-select option {
|
||||
background-color: gold;
|
||||
border-radius: 24px;
|
||||
display: none;
|
||||
} */
|
||||
|
||||
.react-dropdown-select {
|
||||
width: 176px !important;
|
||||
height: 48px !important;
|
||||
margin: 0 4px;
|
||||
padding: 0 24px !important;
|
||||
color: white;
|
||||
border-radius: 8px !important;
|
||||
background-color: #494650;
|
||||
font-size: 16px;
|
||||
border: none !important;
|
||||
}
|
||||
|
||||
.react-dropdown-select-content span {
|
||||
box-sizing: initial !important;
|
||||
}
|
||||
|
||||
.react-dropdown-select:focus-within {
|
||||
background-color: white;
|
||||
color: black;
|
||||
outline: none !important;
|
||||
box-shadow: none !important;
|
||||
}
|
||||
|
||||
.react-dropdown-select-type-single {
|
||||
/* height: 100% !important; */
|
||||
}
|
||||
|
||||
.react-dropdown-select-clear,
|
||||
.react-dropdown-select-dropdown-handle {
|
||||
/* color: #fff; */
|
||||
}
|
||||
.react-dropdown-select-option {
|
||||
/* border: 1px solid #000; */
|
||||
}
|
||||
.react-dropdown-select-item {
|
||||
color: #333;
|
||||
height: 100% !important;
|
||||
|
||||
}
|
||||
.react-dropdown-select-input {
|
||||
color: #fff;
|
||||
}
|
||||
.react-dropdown-select-dropdown {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
border: none;
|
||||
width: 500px;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
border-radius: 8px;
|
||||
max-height: 300px;
|
||||
overflow: auto;
|
||||
z-index: 9;
|
||||
/* background: rgb(29, 20, 20) !important; */
|
||||
box-shadow: none;
|
||||
}
|
||||
.react-dropdown-select-item {
|
||||
color: black;
|
||||
}
|
||||
.react-dropdown-select-item:hover {
|
||||
/* color: white; */
|
||||
background-color: #ffd171 !important;
|
||||
}
|
||||
|
||||
.react-dropdown-select-item.react-dropdown-select-item-selected,
|
||||
.react-dropdown-select-item.react-dropdown-select-item-active {
|
||||
color: black !important;
|
||||
background-color: #ffd171 !important;
|
||||
/* border-bottom: 1px solid #333; */
|
||||
font-weight: bold;
|
||||
}
|
||||
.react-dropdown-select-item.react-dropdown-select-item-disabled {
|
||||
background: #777;
|
||||
color: #ccc;
|
||||
}
|
||||
@@ -1,34 +1,57 @@
|
||||
import React from "react";
|
||||
import { useRecoilState } from "recoil";
|
||||
import Select from "react-dropdown-select";
|
||||
|
||||
import { styleQueryAtom } from "../../state/atoms";
|
||||
import { IconStyle } from "../../lib";
|
||||
import "./StyleInput.css";
|
||||
import { Heart } from "phosphor-react";
|
||||
|
||||
const options = [
|
||||
{ key: "Thin", value: IconStyle.THIN, icon: <Heart weight="thin" /> },
|
||||
{ key: "Light", value: IconStyle.LIGHT, icon: <Heart weight="light" /> },
|
||||
{
|
||||
key: "Regular",
|
||||
value: IconStyle.REGULAR,
|
||||
icon: <Heart weight="regular" />,
|
||||
},
|
||||
{ key: "Bold", value: IconStyle.BOLD, icon: <Heart weight="bold" /> },
|
||||
{ key: "Fill", value: IconStyle.FILL, icon: <Heart weight="fill" /> },
|
||||
{
|
||||
key: "Duotone",
|
||||
value: IconStyle.DUOTONE,
|
||||
icon: <Heart weight="duotone" />,
|
||||
},
|
||||
];
|
||||
|
||||
type StyleInputProps = {};
|
||||
|
||||
const StyleInput: React.FC<StyleInputProps> = () => {
|
||||
const [style, setStyle] = useRecoilState(styleQueryAtom);
|
||||
void style;
|
||||
|
||||
const handleStyleChange = (event: React.ChangeEvent<HTMLSelectElement>) => {
|
||||
setStyle(event.target.value as IconStyle);
|
||||
};
|
||||
// const handleStyleChange = (event: React.ChangeEvent<HTMLSelectElement>) => {
|
||||
// setStyle(event.target.value as IconStyle);
|
||||
// };
|
||||
|
||||
return (
|
||||
<div>
|
||||
<select
|
||||
id="style-input"
|
||||
aria-label="Icon Style"
|
||||
value={style?.toString()}
|
||||
onChange={handleStyleChange}
|
||||
>
|
||||
<option value={IconStyle.THIN}>Thin</option>
|
||||
<option value={IconStyle.LIGHT}>Light</option>
|
||||
<option value={IconStyle.REGULAR}>Regular</option>
|
||||
<option value={IconStyle.BOLD}>Bold</option>
|
||||
<option value={IconStyle.FILL}>Fill</option>
|
||||
<option value={IconStyle.DUOTONE}>Duotone</option>
|
||||
</select>
|
||||
</div>
|
||||
<Select
|
||||
style={{ height: 48 }}
|
||||
options={options}
|
||||
values={[options[2]]}
|
||||
searchable={false}
|
||||
labelField="key"
|
||||
onChange={(values) => setStyle(values[0].value as IconStyle)}
|
||||
// itemRenderer={({ item, methods }) => (
|
||||
// <div
|
||||
// className="react-dropdown-select-item"
|
||||
// onClick={() => methods.addItem(item)}
|
||||
// >
|
||||
// {item.icon}
|
||||
// {item.key}
|
||||
// </div>
|
||||
// )}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user