Skip to content

Commit

Permalink
feat(form): switch widget
Browse files Browse the repository at this point in the history
  • Loading branch information
eoaksnes committed Oct 24, 2023
1 parent 8aa9153 commit afc16b7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
19 changes: 19 additions & 0 deletions packages/dm-core-plugins/src/form/widgets/SwitchWidget.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from 'react'

import { Switch } from '@equinor/eds-core-react'
import { TWidget } from '../types'

const SwitchWidget = (props: TWidget) => {
const { value, readOnly } = props

return (
<Switch
{...props}
disabled={readOnly}
defaultChecked={typeof value === 'undefined' ? false : value}
data-testid="form-switch"
/>
)
}

export default SwitchWidget
2 changes: 2 additions & 0 deletions packages/dm-core-plugins/src/form/widgets/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ import CheckboxWidget from './CheckboxWidget'
import TextWidget from './TextWidget'
import TextareaWidget from './TextareaWidget'
import TypeWidget from './TypeWidget'
import SwitchWidget from './SwitchWidget'

const widgets: TWidgets = {
CheckboxWidget,
TextWidget,
TextareaWidget,
BlueprintPickerWidget,
TypeWidget,
SwitchWidget,
}

export default widgets

0 comments on commit afc16b7

Please sign in to comment.