Updated TableField and SelectTableField
This commit is contained in:
parent
93007f48f6
commit
9d6fec0a56
3 changed files with 56 additions and 35 deletions
|
|
@ -12,9 +12,11 @@ interface Props {
|
||||||
open: boolean
|
open: boolean
|
||||||
value?: string
|
value?: string
|
||||||
className?: string
|
className?: string
|
||||||
imageAlt?: string
|
image?: {
|
||||||
imageClass?: string
|
className?: String
|
||||||
imageSrc?: string[]
|
alt?: string
|
||||||
|
src: string[]
|
||||||
|
}
|
||||||
children: React.ReactNode
|
children: React.ReactNode
|
||||||
onOpenChange: () => void
|
onOpenChange: () => void
|
||||||
onChange: (value: string) => void
|
onChange: (value: string) => void
|
||||||
|
|
@ -31,10 +33,8 @@ const SelectTableField = (props: Props) => {
|
||||||
return (
|
return (
|
||||||
<TableField
|
<TableField
|
||||||
name={props.name}
|
name={props.name}
|
||||||
className="SelectField"
|
image={props.image}
|
||||||
imageAlt={props.imageAlt}
|
className="select"
|
||||||
imageClass={props.imageClass}
|
|
||||||
imageSrc={props.imageSrc}
|
|
||||||
label={props.label}
|
label={props.label}
|
||||||
>
|
>
|
||||||
<Select
|
<Select
|
||||||
|
|
@ -43,9 +43,12 @@ const SelectTableField = (props: Props) => {
|
||||||
onOpenChange={props.onOpenChange}
|
onOpenChange={props.onOpenChange}
|
||||||
onValueChange={props.onChange}
|
onValueChange={props.onChange}
|
||||||
onClose={props.onClose}
|
onClose={props.onClose}
|
||||||
triggerClass={classNames({ Bound: true, Table: true })}
|
|
||||||
value={value}
|
value={value}
|
||||||
overlayVisible={false}
|
overlayVisible={false}
|
||||||
|
trigger={{
|
||||||
|
bound: true,
|
||||||
|
className: 'table',
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
{props.children}
|
{props.children}
|
||||||
</Select>
|
</Select>
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
.TableField {
|
.field {
|
||||||
align-items: center;
|
align-items: center;
|
||||||
display: grid;
|
display: grid;
|
||||||
gap: $unit-2x;
|
gap: $unit-2x;
|
||||||
|
|
@ -18,36 +18,36 @@
|
||||||
color: var(--accent-blue);
|
color: var(--accent-blue);
|
||||||
}
|
}
|
||||||
|
|
||||||
&.Numeric .Right > .Input,
|
&.numeric .right > .input,
|
||||||
&.Numeric .Right > .Duration {
|
&.numeric .right > .duration {
|
||||||
text-align: right;
|
text-align: right;
|
||||||
max-width: $unit-12x;
|
max-width: $unit-12x;
|
||||||
width: $unit-12x;
|
width: $unit-12x;
|
||||||
}
|
}
|
||||||
|
|
||||||
&.Numeric .Right > .Duration {
|
&.numeric .right > .Duration {
|
||||||
justify-content: flex-end;
|
justify-content: flex-end;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
&.Disabled {
|
&.disabled {
|
||||||
&:hover .Left .Info h3 {
|
&:hover .left .info h3 {
|
||||||
color: var(--text-tertiary);
|
color: var(--text-tertiary);
|
||||||
}
|
}
|
||||||
|
|
||||||
.Left .Info h3 {
|
.left .info h3 {
|
||||||
color: var(--text-tertiary);
|
color: var(--text-tertiary);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.Left {
|
.left {
|
||||||
align-items: center;
|
align-items: center;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
gap: $unit;
|
gap: $unit;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
||||||
.Info {
|
.info {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
|
|
@ -55,7 +55,7 @@
|
||||||
gap: $unit-half;
|
gap: $unit-half;
|
||||||
}
|
}
|
||||||
|
|
||||||
.Image {
|
.image {
|
||||||
display: none;
|
display: none;
|
||||||
|
|
||||||
.preview {
|
.preview {
|
||||||
|
|
@ -90,7 +90,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.Right {
|
.right {
|
||||||
align-items: center;
|
align-items: center;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
|
|
@ -99,12 +99,12 @@
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
||||||
@include breakpoint(phone) {
|
@include breakpoint(phone) {
|
||||||
.Image {
|
.image {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.SelectTrigger {
|
.trigger {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,21 +5,39 @@ interface Props {
|
||||||
name: string
|
name: string
|
||||||
label: string
|
label: string
|
||||||
description?: string
|
description?: string
|
||||||
|
image?: {
|
||||||
|
className?: String
|
||||||
|
alt?: string
|
||||||
|
src: string[]
|
||||||
|
}
|
||||||
className?: string
|
className?: string
|
||||||
imageAlt?: string
|
|
||||||
imageClass?: string
|
|
||||||
imageSrc?: string[]
|
|
||||||
children: React.ReactNode
|
children: React.ReactNode
|
||||||
}
|
}
|
||||||
|
|
||||||
const TableField = (props: Props) => {
|
const TableField = (props: Props) => {
|
||||||
|
const classes = classNames(
|
||||||
|
{
|
||||||
|
[styles.field]: true,
|
||||||
|
},
|
||||||
|
props.className?.split(' ').map((className) => styles[className])
|
||||||
|
)
|
||||||
|
|
||||||
const image = () => {
|
const image = () => {
|
||||||
return props.imageSrc && props.imageSrc.length > 0 ? (
|
return props.image && props.image.src.length > 0 ? (
|
||||||
<div className={`preview ${props.imageClass}`}>
|
<div
|
||||||
|
className={classNames(
|
||||||
|
{
|
||||||
|
[styles.preview]: true,
|
||||||
|
},
|
||||||
|
props.image.className
|
||||||
|
?.split(' ')
|
||||||
|
.map((className) => styles[className])
|
||||||
|
)}
|
||||||
|
>
|
||||||
<img
|
<img
|
||||||
alt={props.imageAlt}
|
alt={props.image.alt}
|
||||||
srcSet={props.imageSrc.join(', ')}
|
srcSet={props.image.src.join(', ')}
|
||||||
src={props.imageSrc[0]}
|
src={props.image.src[0]}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
|
|
@ -28,17 +46,17 @@ const TableField = (props: Props) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classNames({ TableField: true }, props.className)}>
|
<div className={classes}>
|
||||||
<div className="Left">
|
<div className={styles.left}>
|
||||||
<div className="Info">
|
<div className={styles.info}>
|
||||||
<h3>{props.label}</h3>
|
<h3>{props.label}</h3>
|
||||||
{props.description && <p>{props.description}</p>}
|
{props.description && <p>{props.description}</p>}
|
||||||
</div>
|
</div>
|
||||||
<div className="Image">{image()}</div>
|
<div className={styles.image}>{image()}</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="Right">
|
<div className={styles.right}>
|
||||||
<div className="Image">{image()}</div>
|
<div className={styles.image}>{image()}</div>
|
||||||
{props.children}
|
{props.children}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue