Improve SwitchTableField
* Add support for passing in classes * Add support for passing a disabled prop * Pass description to TableField * Right-align switch * Add support for Extra color switch
This commit is contained in:
parent
6fb41a40ef
commit
b6e1bfbcb9
2 changed files with 23 additions and 2 deletions
|
|
@ -0,0 +1,9 @@
|
||||||
|
.TableField.SwitchTableField {
|
||||||
|
&.Extra .Switch[data-state='checked'] {
|
||||||
|
background: var(--extra-purple-secondary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.Right {
|
||||||
|
justify-content: end;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,13 +1,15 @@
|
||||||
import { useEffect, useState } from 'react'
|
import { useEffect, useState } from 'react'
|
||||||
|
import classNames from 'classnames'
|
||||||
import Switch from '~components/common/Switch'
|
import Switch from '~components/common/Switch'
|
||||||
import TableField from '~components/common/TableField'
|
import TableField from '~components/common/TableField'
|
||||||
|
|
||||||
import './index.scss'
|
import './index.scss'
|
||||||
|
|
||||||
interface Props {
|
interface Props extends React.HTMLAttributes<HTMLDivElement> {
|
||||||
name: string
|
name: string
|
||||||
label: string
|
label: string
|
||||||
description?: string
|
description?: string
|
||||||
|
disabled?: boolean
|
||||||
value?: boolean
|
value?: boolean
|
||||||
className?: string
|
className?: string
|
||||||
tabIndex?: number
|
tabIndex?: number
|
||||||
|
|
@ -32,10 +34,19 @@ const SwitchTableField = (props: Props) => {
|
||||||
setValue(value)
|
setValue(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const classes = classNames(
|
||||||
|
{
|
||||||
|
SwitchTableField: true,
|
||||||
|
Disabled: props.disabled,
|
||||||
|
},
|
||||||
|
props.className
|
||||||
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TableField
|
<TableField
|
||||||
name={props.name}
|
name={props.name}
|
||||||
className="SwitchField"
|
description={props.description}
|
||||||
|
className={classes}
|
||||||
imageAlt={props.imageAlt}
|
imageAlt={props.imageAlt}
|
||||||
imageClass={props.imageClass}
|
imageClass={props.imageClass}
|
||||||
imageSrc={props.imageSrc}
|
imageSrc={props.imageSrc}
|
||||||
|
|
@ -44,6 +55,7 @@ const SwitchTableField = (props: Props) => {
|
||||||
<Switch
|
<Switch
|
||||||
name={props.name}
|
name={props.name}
|
||||||
checked={value}
|
checked={value}
|
||||||
|
disabled={props.disabled}
|
||||||
tabIndex={props.tabIndex}
|
tabIndex={props.tabIndex}
|
||||||
onCheckedChange={onValueChange}
|
onCheckedChange={onValueChange}
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue