added height and width as positioning options
This commit is contained in:
parent
004d839966
commit
1d2f079914
|
@ -4,22 +4,29 @@ import { pipe } from "../common/core"
|
||||||
const self = n => n
|
const self = n => n
|
||||||
const join_with = delimiter => a => a.join(delimiter)
|
const join_with = delimiter => a => a.join(delimiter)
|
||||||
const empty_string_to_unset = s => (s.length ? s : "0")
|
const empty_string_to_unset = s => (s.length ? s : "0")
|
||||||
const add_suffix = suffix => s => s + suffix
|
const add_suffix_if_number = suffix => s => {
|
||||||
|
try {
|
||||||
|
if (isNaN(s) || isNaN(parseFloat(s))) return s
|
||||||
|
} catch (_) {
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
return s + suffix
|
||||||
|
}
|
||||||
|
|
||||||
export const make_margin = values =>
|
export const make_margin = values =>
|
||||||
pipe(values, [
|
pipe(values, [
|
||||||
map(empty_string_to_unset),
|
map(empty_string_to_unset),
|
||||||
map(add_suffix("px")),
|
map(add_suffix_if_number("px")),
|
||||||
join_with(" "),
|
join_with(" "),
|
||||||
])
|
])
|
||||||
|
|
||||||
const css_map = {
|
const css_map = {
|
||||||
templaterows: {
|
templaterows: {
|
||||||
name: "grid-template-columns",
|
name: "grid-template-rows",
|
||||||
generate: self,
|
generate: self,
|
||||||
},
|
},
|
||||||
templatecolumns: {
|
templatecolumns: {
|
||||||
name: "grid-template-rows",
|
name: "grid-template-columns",
|
||||||
generate: self,
|
generate: self,
|
||||||
},
|
},
|
||||||
gridarea: {
|
gridarea: {
|
||||||
|
@ -58,6 +65,14 @@ const css_map = {
|
||||||
name: "z-index",
|
name: "z-index",
|
||||||
generate: self,
|
generate: self,
|
||||||
},
|
},
|
||||||
|
height: {
|
||||||
|
name: "height",
|
||||||
|
generate: self,
|
||||||
|
},
|
||||||
|
width: {
|
||||||
|
name: "width",
|
||||||
|
generate: self,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
export const generate_rule = ([name, values]) =>
|
export const generate_rule = ([name, values]) =>
|
||||||
|
@ -97,10 +112,11 @@ const apply_class = (id, name, styles) => `.${name}-${id} {\n${styles}\n}`
|
||||||
|
|
||||||
export const generate_screen_css = component_array => {
|
export const generate_screen_css = component_array => {
|
||||||
let styles = ""
|
let styles = ""
|
||||||
|
let emptyStyles = { layout: {}, position: {} }
|
||||||
|
|
||||||
for (let i = 0; i < component_array.length; i += 1) {
|
for (let i = 0; i < component_array.length; i += 1) {
|
||||||
const { _styles, _id, _children } = component_array[i]
|
const { _styles, _id, _children } = component_array[i]
|
||||||
const { layout, position } = generate_css(_styles)
|
const { layout, position } = generate_css(_styles || emptyStyles)
|
||||||
|
|
||||||
styles += apply_class(_id, "pos", position) + "\n"
|
styles += apply_class(_id, "pos", position) + "\n"
|
||||||
styles += apply_class(_id, "lay", layout) + "\n"
|
styles += apply_class(_id, "lay", layout) + "\n"
|
||||||
|
|
|
@ -35,6 +35,11 @@
|
||||||
padding: ["Padding", tbrl, "small"],
|
padding: ["Padding", tbrl, "small"],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$: size = {
|
||||||
|
height: ["Height", single],
|
||||||
|
width: ["Width", single],
|
||||||
|
}
|
||||||
|
|
||||||
$: zindex = {
|
$: zindex = {
|
||||||
zindex: ["Z-Index", single],
|
zindex: ["Z-Index", single],
|
||||||
}
|
}
|
||||||
|
@ -82,6 +87,22 @@
|
||||||
onStyleChanged={_value => onStyleChanged('position', key, _value)}
|
onStyleChanged={_value => onStyleChanged('position', key, _value)}
|
||||||
values={layout[key] || newValue(meta.length)}
|
values={layout[key] || newValue(meta.length)}
|
||||||
{meta}
|
{meta}
|
||||||
|
{size}
|
||||||
|
type="text" />
|
||||||
|
</div>
|
||||||
|
{/each}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<h4>Size</h4>
|
||||||
|
<div class="layout-layer">
|
||||||
|
{#each Object.entries(size) as [key, [name, meta, size]] (component._id + key)}
|
||||||
|
<div class="grid">
|
||||||
|
<h5>{name}:</h5>
|
||||||
|
<InputGroup
|
||||||
|
onStyleChanged={_value => onStyleChanged('position', key, _value)}
|
||||||
|
values={layout[key] || newValue(meta.length)}
|
||||||
|
type="text"
|
||||||
|
{meta}
|
||||||
{size} />
|
{size} />
|
||||||
</div>
|
</div>
|
||||||
{/each}
|
{/each}
|
||||||
|
|
Loading…
Reference in New Issue