Style binding options and property categories

This commit is contained in:
Conor_Mack 2020-05-08 09:57:41 +01:00
parent 8d8caa9ff5
commit 6b7a3d1d7e
2 changed files with 75 additions and 13 deletions

View File

@ -4,6 +4,9 @@
export let onChange = value => {} export let onChange = value => {}
export let options = [] export let options = []
export let initialValue = "" export let initialValue = ""
export let styleBindingProperty = ""
$: bindOptionToStyle = !!styleBindingProperty
onMount(() => { onMount(() => {
if (!value && !!initialValue) { if (!value && !!initialValue) {
@ -17,6 +20,14 @@
{value} {value}
on:change={ev => onChange(ev.target.value)}> on:change={ev => onChange(ev.target.value)}>
{#each options as { value, label }} {#each options as { value, label }}
{#if bindOptionToStyle}
<option
style={`${styleBindingProperty}: ${value || label};`}
value={value || label}>
{label}
</option>
{:else}
<option value={value || label}>{label}</option> <option value={value || label}>{label}</option>
{/if}
{/each} {/each}
</select> </select>

View File

@ -41,25 +41,76 @@ export const size = {
minHeight: { label: "Min H", control: Input }, minHeight: { label: "Min H", control: Input },
maxWidth: { label: "Max W", control: Input }, maxWidth: { label: "Max W", control: Input },
maxHeight: { label: "Max H", control: Input }, maxHeight: { label: "Max H", control: Input },
overflow: { control: Input }, //custom overflow: {
control: OptionSelect,
options: [
{ label: "visible" },
{ label: "auto" },
{ label: "hidden" },
{ label: "auto" },
{ label: "scroll" },
],
}, //custom
} }
export const position = { export const position = {
position: { control: Input }, position: {
control: OptionSelect,
options: [
{ label: "static" },
{ label: "relative" },
{ label: "fixed" },
{ label: "absolute" },
{ label: "sticky" },
],
},
} }
export const typography = { export const typography = {
font: { control: Input }, fontFamily: {
weight: { control: Input }, label: "Font",
size: { control: Input }, control: OptionSelect,
options: [
{ label: "initial" },
{ label: "Times New Roman" },
{ label: "Georgia" },
{ label: "Arial" },
{ label: "Arial Black" },
{ label: "Comic Sans MS" },
{ label: "Impact" },
{ label: "Lucida Sans Unicode" },
],
styleBindingProperty: "font-family",
},
fontWeight: {
label: "weight",
control: OptionSelect,
options: [
{ label: "normal" },
{ label: "bold" },
{ label: "bolder" },
{ label: "lighter" },
],
},
fontSize: { label: "size", control: Input },
lineHeight: { label: "Line H", control: Input }, lineHeight: { label: "Line H", control: Input },
color: { color: {
control: OptionSelect, control: OptionSelect,
options: [{ label: "red" }, { label: "blue" }, { label: "green" }], options: [{ label: "red" }, { label: "blue" }, { label: "green" }],
}, },
align: { control: Input }, //custom textAlign: {
transform: { control: Input }, //custom label: "align",
style: { control: Input }, //custom control: OptionSelect,
options: [
{ label: "initial" },
{ label: "left" },
{ label: "right" },
{ label: "center" },
{ label: "justify" },
],
}, //custom
textTransform: { label: "transform", control: Input }, //custom
fontStyle: { label: "style", control: Input }, //custom
} }
export const background = { export const background = {
@ -68,10 +119,10 @@ export const background = {
} }
export const border = { export const border = {
radius: { control: Input }, borderRadius: { label: "radius", control: Input },
width: { control: Input }, //custom borderWidth: { label: "width", control: Input }, //custom
color: { control: Input }, borderColor: { label: "color", control: Input },
style: { control: Input }, borderStyle: { label: "style", control: Input },
} }
export const effects = { export const effects = {