From ef06168c088a408669c05439f584a0d2b58607d3 Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Sun, 25 Dec 2022 19:32:26 -0800 Subject: [PATCH] Add SelectTableField --- components/SelectTableField/index.scss | 69 ++++++++++++++++++++++++++ components/SelectTableField/index.tsx | 68 +++++++++++++++++++++++++ 2 files changed, 137 insertions(+) create mode 100644 components/SelectTableField/index.scss create mode 100644 components/SelectTableField/index.tsx diff --git a/components/SelectTableField/index.scss b/components/SelectTableField/index.scss new file mode 100644 index 00000000..85e2777f --- /dev/null +++ b/components/SelectTableField/index.scss @@ -0,0 +1,69 @@ +.TableField { + align-items: center; + display: grid; + gap: $unit * 2; + grid-template-columns: 1fr auto; + + &.Image { + grid-template-columns: 1fr auto 1fr; + } + + .Left { + display: flex; + flex-direction: column; + gap: calc($unit / 2); + + label { + color: var(--text-tertiary); + font-size: $font-regular; + } + + p { + color: var(--text-secondary); + font-size: $font-small; + line-height: 1.1; + max-width: 300px; + + &.jp { + max-width: 270px; + } + } + } + + .preview { + $diameter: $unit * 6; + background-color: $grey-90; + border-radius: 999px; + height: $diameter; + width: $diameter; + + img { + height: $diameter; + width: $diameter; + } + + &.fire { + background: $fire-bg-20; + } + + &.water { + background: $water-bg-20; + } + + &.wind { + background: $wind-bg-20; + } + + &.earth { + background: $earth-bg-20; + } + + &.dark { + background: $dark-bg-10; + } + + &.light { + background: $light-bg-20; + } + } +} diff --git a/components/SelectTableField/index.tsx b/components/SelectTableField/index.tsx new file mode 100644 index 00000000..6ee80dd9 --- /dev/null +++ b/components/SelectTableField/index.tsx @@ -0,0 +1,68 @@ +import classNames from 'classnames' +import { useEffect, useState } from 'react' +import Select from '~components/Select' + +import './index.scss' + +interface Props { + name: string + label: string + description?: string + open: boolean + value?: string + className?: string + imageAlt?: string + imageClass?: string + imageSrc?: string[] + children: React.ReactNode + onClick: () => void + onChange: (value: string) => void +} + +const SelectTableField = (props: Props) => { + const [value, setValue] = useState('') + + useEffect(() => { + if (props.value) setValue(props.value) + }, [props.value]) + + const image = () => { + return props.imageSrc && props.imageSrc.length > 0 ? ( +
+ {props.imageAlt} +
+ ) : ( + '' + ) + } + + return ( +
+
+

{props.label}

+

{props.description}

+
+ + {image()} + +
+ +
+
+ ) +} + +export default SelectTableField