Merge branch 'master' of github.com:Budibase/budibase into couchdb-api

This commit is contained in:
Martin McKeaveney 2020-04-28 16:07:22 +01:00
commit ff73cfba48
8 changed files with 96 additions and 17 deletions

View File

@ -22,6 +22,7 @@
value={prop_value} value={prop_value}
type={prop_definition.type} type={prop_definition.type}
options={prop_definition.options} options={prop_definition.options}
styleBindingProperty={prop_definition.styleBindingProperty}
onChanged={v => setProp(prop_name, v)} /> onChanged={v => setProp(prop_name, v)} />
{/if} {/if}
</div> </div>

View File

@ -8,6 +8,9 @@
export let onChanged = () => {} export let onChanged = () => {}
export let type = "" export let type = ""
export let options = [] export let options = []
export let styleBindingProperty = ""
$: bindOptionToStyle = !!styleBindingProperty
</script> </script>
<div class="unbound-container"> <div class="unbound-container">
@ -24,7 +27,13 @@
{value} {value}
on:change={ev => onChanged(ev.target.value)}> on:change={ev => onChanged(ev.target.value)}>
{#each options || [] as option} {#each options || [] as option}
{#if bindOptionToStyle}
<option style={`${styleBindingProperty}: ${option};`} value={option}>
{option}
</option>
{:else}
<option value={option}>{option}</option> <option value={option}>{option}</option>
{/if}
{/each} {/each}
</select> </select>
{:else} {:else}

View File

@ -36,7 +36,22 @@
"padding": "string", "padding": "string",
"hoverColor": "string", "hoverColor": "string",
"hoverBackground": "string", "hoverBackground": "string",
"hoverBorder": "string" "hoverBorder": "string",
"fontFamily": {
"type": "options",
"default": "initial",
"styleBindingProperty": "font-family",
"options": [
"initial",
"Times New Roman",
"Georgia",
"Arial",
"Arial Black",
"Comic Sans MS",
"Impact",
"Lucida Sans Unicode"
]
}
}, },
"tags": [ "tags": [
"layout" "layout"
@ -152,7 +167,21 @@
"children": false, "children": false,
"props": { "props": {
"text": "string", "text": "string",
"font": "string", "fontFamily": {
"type": "options",
"default": "initial",
"styleBindingProperty": "font-family",
"options": [
"initial",
"Times New Roman",
"Georgia",
"Arial",
"Arial Black",
"Comic Sans MS",
"Impact",
"Lucida Sans Unicode"
]
},
"fontSize": "string", "fontSize": "string",
"color": "string", "color": "string",
"textAlign": { "textAlign": {
@ -241,7 +270,22 @@
"color": "string", "color": "string",
"hoverColor": "string", "hoverColor": "string",
"underline": "bool", "underline": "bool",
"fontSize": "string" "fontSize": "string",
"fontFamily": {
"type": "options",
"default": "initial",
"styleBindingProperty": "font-family",
"options": [
"initial",
"Times New Roman",
"Georgia",
"Arial",
"Arial Black",
"Comic Sans MS",
"Impact",
"Lucida Sans Unicode"
]
}
} }
}, },
"image": { "image": {
@ -323,6 +367,21 @@
"h5", "h5",
"h6" "h6"
] ]
},
"fontFamily": {
"type": "options",
"default": "initial",
"styleBindingProperty": "font-family",
"options": [
"initial",
"Times New Roman",
"Georgia",
"Arial",
"Arial Black",
"Comic Sans MS",
"Impact",
"Lucida Sans Unicode"
]
} }
}, },
"tags": [] "tags": []

View File

@ -12,6 +12,7 @@
export let hoverColor export let hoverColor
export let hoverBackground export let hoverBackground
export let hoverBorder export let hoverBorder
export let fontFamily
export let _bb export let _bb
let theButton let theButton
@ -39,6 +40,7 @@
buttonStyles = buildStyle({ buttonStyles = buildStyle({
padding, padding,
"font-family": fontFamily,
}) })
customClasses = createClasses({ customClasses = createClasses({

View File

@ -1,23 +1,27 @@
<script> <script>
import { buildStyle } from "./buildStyle.js"
export let className = "" export let className = ""
export let type export let type
export let _bb export let _bb
export let text = "" export let text = ""
export let fontFamily = ""
let containerElement let containerElement
$: containerElement && !text && _bb.attachChildren(containerElement) $: containerElement && !text && _bb.attachChildren(containerElement)
$: style = buildStyle({ "font-family": fontFamily })
</script> </script>
{#if type === 'h1'} {#if type === 'h1'}
<h1 class={className} bind:this={containerElement}>{text}</h1> <h1 class={className} {style} bind:this={containerElement}>{text}</h1>
{:else if type === 'h2'} {:else if type === 'h2'}
<h2 class={className} bind:this={containerElement}>{text}</h2> <h2 class={className} {style} bind:this={containerElement}>{text}</h2>
{:else if type === 'h3'} {:else if type === 'h3'}
<h3 class={className} bind:this={containerElement}>{text}</h3> <h3 class={className} {style} bind:this={containerElement}>{text}</h3>
{:else if type === 'h4'} {:else if type === 'h4'}
<h4 class={className} bind:this={containerElement}>{text}</h4> <h4 class={className} {style} bind:this={containerElement}>{text}</h4>
{:else if type === 'h5'} {:else if type === 'h5'}
<h5 class={className} bind:this={containerElement}>{text}</h5> <h5 class={className} {style} bind:this={containerElement}>{text}</h5>
{:else if type === 'h6'} {:else if type === 'h6'}
<h6 class={className} bind:this={containerElement}>{text}</h6> <h6 class={className} {style} bind:this={containerElement}>{text}</h6>
{/if} {/if}

View File

@ -7,6 +7,7 @@
export let color export let color
export let hoverColor export let hoverColor
export let underline = false export let underline = false
export let fontFamily
export let fontSize export let fontSize
export let _bb export let _bb
@ -20,6 +21,7 @@
color, color,
textDecoration: underline ? "underline" : "none", textDecoration: underline ? "underline" : "none",
fontSize, fontSize,
fontFamily,
} }
$: classes = createClasses(cssVariables) $: classes = createClasses(cssVariables)
</script> </script>
@ -49,4 +51,8 @@
.fontSize { .fontSize {
font-size: var(--fontSize); font-size: var(--fontSize);
} }
.fontFamily {
font-family: var(--fontFamily);
}
</style> </style>

View File

@ -6,7 +6,7 @@
export let formattingTag = "" export let formattingTag = ""
export let font = "" export let fontFamily = ""
export let fontSize = "1em" export let fontSize = "1em"
export let textAlign = "" export let textAlign = ""
export let verticalAlign = "" export let verticalAlign = ""
@ -17,11 +17,9 @@
const isTag = tag => (formattingTag || "").indexOf(tag) > -1 const isTag = tag => (formattingTag || "").indexOf(tag) > -1
$: style = buildStyle({ $: style = buildStyle({
font: `${fontSize} ${font}`, "font-size": fontSize,
verticalAlign, "font-family": fontFamily,
color, color,
"text-align": textAlign,
"vertical-align": verticalAlign,
}) })
</script> </script>