add sizes to boolean field and checkbox component

This commit is contained in:
Maurits Lourens 2021-08-03 20:54:32 +02:00
parent 92b415d109
commit 9fb73b4eba
4 changed files with 31 additions and 4 deletions

View File

@ -9,6 +9,7 @@
export let text = null export let text = null
export let disabled = false export let disabled = false
export let error = null export let error = null
export let size = "M"
const dispatch = createEventDispatcher() const dispatch = createEventDispatcher()
const onChange = e => { const onChange = e => {
@ -18,5 +19,5 @@
</script> </script>
<Field {label} {labelPosition} {error}> <Field {label} {labelPosition} {error}>
<Checkbox {error} {disabled} {text} {value} on:change={onChange} /> <Checkbox {error} {disabled} {text} {value} {size} on:change={onChange} />
</Field> </Field>

View File

@ -8,6 +8,7 @@
export let id = null export let id = null
export let text = null export let text = null
export let disabled = false export let disabled = false
export let size = null
const dispatch = createEventDispatcher() const dispatch = createEventDispatcher()
const onChange = event => { const onChange = event => {
@ -16,7 +17,7 @@
</script> </script>
<label <label
class="spectrum-Checkbox spectrum-Checkbox--sizeM spectrum-Checkbox--emphasized" class="spectrum-Checkbox spectrum-Checkbox--size{size} spectrum-Checkbox--emphasized"
class:is-invalid={!!error} class:is-invalid={!!error}
> >
<input <input

View File

@ -1852,7 +1852,6 @@
"booleanfield": { "booleanfield": {
"name": "Checkbox", "name": "Checkbox",
"icon": "Checkmark", "icon": "Checkmark",
"styles": ["size"],
"illegalChildren": ["section"], "illegalChildren": ["section"],
"settings": [ "settings": [
{ {
@ -1870,6 +1869,30 @@
"label": "Text", "label": "Text",
"key": "text" "key": "text"
}, },
{
"type": "select",
"label": "Size",
"key": "size",
"options": [
{
"label": "Small",
"value": "S"
},
{
"label": "Medium",
"value": "M"
},
{
"label": "Large",
"value": "L"
},
{
"label": "Extra large",
"value": "XL"
}
],
"defaultValue": "M"
},
{ {
"type": "boolean", "type": "boolean",
"label": "Disabled", "label": "Disabled",

View File

@ -6,9 +6,10 @@
export let label export let label
export let text export let text
export let disabled = false export let disabled = false
export let size
let fieldState let fieldState
let fieldApi let fieldApi
</script> </script>
<Field <Field
@ -26,6 +27,7 @@
disabled={$fieldState.disabled} disabled={$fieldState.disabled}
error={$fieldState.error} error={$fieldState.error}
id={$fieldState.fieldId} id={$fieldState.fieldId}
size={size}
on:change={e => fieldApi.setValue(e.detail)} on:change={e => fieldApi.setValue(e.detail)}
{text} {text}
/> />