Skip to content

Commit

Permalink
Standardize sanitizedHTML
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Mar 23, 2022
1 parent 31c1bc6 commit a40c0fc
Showing 1 changed file with 23 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,23 @@ import CallbackEditor from './CallbackEditor'
import ColorEditor from './ColorEditor'
import JsonEditor from './JsonEditor'

const MyTextField = props => {
return (
<TextField
{...props}
helperText={<SanitizedHTML html={props.helperText} />}
FormHelperTextProps={{
component: 'div',
}}
fullWidth
/>
)
}

const StringEditor = observer(({ slot }) => (
<TextField
<MyTextField
label={slot.name}
helperText={<SanitizedHTML html={slot.description} />}
fullWidth
helperText={slot.description}
value={slot.value}
onChange={evt => slot.set(evt.target.value)}
/>
Expand All @@ -50,8 +62,7 @@ const StringEditor = observer(({ slot }) => (
const TextEditor = observer(({ slot }) => (
<TextField
label={slot.name}
helperText={<SanitizedHTML html={slot.description} />}
fullWidth
helperText={slot.description}
multiline
value={slot.value}
onChange={evt => slot.set(evt.target.value)}
Expand Down Expand Up @@ -267,9 +278,9 @@ const NumberEditor = observer(({ slot }) => {
}
}, [slot, val])
return (
<TextField
<MyTextField
label={slot.name}
helperText={<SanitizedHTML html={slot.description} />}
helperText={slot.description}
value={val}
type="number"
onChange={evt => setVal(evt.target.value)}
Expand All @@ -286,9 +297,9 @@ const IntegerEditor = observer(({ slot }) => {
}
}, [slot, val])
return (
<TextField
<MyTextField
label={slot.name}
helperText={<SanitizedHTML html={slot.description} />}
helperText={slot.description}
value={val}
type="number"
onChange={evt => setVal(evt.target.value)}
Expand Down Expand Up @@ -318,20 +329,19 @@ const StringEnumEditor = observer(({ slot, slotSchema }) => {
).map(t => t.value)

return (
<TextField
<MyTextField
value={slot.value}
label={slot.name}
select
helperText={<SanitizedHTML html={slot.description} />}
fullWidth
helperText={slot.description}
onChange={evt => slot.set(evt.target.value)}
>
{choices.map(str => (
<MenuItem key={str} value={str}>
{str}
</MenuItem>
))}
</TextField>
</MyTextField>
)
})

Expand Down

0 comments on commit a40c0fc

Please sign in to comment.