-
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
11d739b
commit 4b65d82
Showing
6 changed files
with
71 additions
and
82 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import React, {useState} from 'react' | ||
import {RadioGroup} from '@headlessui/react' | ||
import {COLORS, rgbToHex} from "../src/colors"; | ||
|
||
interface ColorsProps { | ||
initialValue: COLORS, | ||
onChange(value: COLORS): void; | ||
} | ||
|
||
function Colors(props: ColorsProps): JSX.Element { | ||
let [color, setColor] = useState(props.initialValue) | ||
|
||
return ( | ||
<RadioGroup<"div", COLORS> | ||
className="flex flex-wrap" value={color} | ||
onChange={function (value) { | ||
setColor(value); | ||
props.onChange(value); | ||
} | ||
}> | ||
{Object.values(COLORS).map((color) => { | ||
return ( | ||
<RadioGroup.Option value={color} key={color} className="outline-none"> | ||
{({checked}) => ( | ||
<div | ||
key={color} | ||
className={`${color !== COLORS.WHITE ? 'ring-white' : 'ring-black'} ring-2 shadow-xl cursor-pointer rounded-md w-10 h-10 flex items-center justify-center m-2`} | ||
style={{backgroundColor: rgbToHex(color), WebkitAppearance: 'none'}} | ||
> | ||
{checked && | ||
<svg className={`${color !== COLORS.WHITE ? 'text-white' : 'text-black'} h-6 w-6`} fill="none" | ||
viewBox="0 0 24 24" stroke="currentColor"> | ||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2.5" d="M5 13l4 4L19 7"/> | ||
</svg> | ||
} | ||
</div> | ||
)} | ||
</RadioGroup.Option> | ||
) | ||
})} | ||
</RadioGroup> | ||
) | ||
} | ||
|
||
export default Colors; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters