icons instead of text

This commit is contained in:
Martin McKeaveney 2020-03-06 17:00:54 +00:00
parent f69c992e7a
commit 660872abc0
6 changed files with 123 additions and 13 deletions

View File

@ -29,6 +29,18 @@ const css_map = {
name: "grid-template-columns", name: "grid-template-columns",
generate: self, generate: self,
}, },
align: {
name: "align-items",
generate: self,
},
justify: {
name: "justify-content",
generate: self,
},
direction: {
name: "flex-direction",
generate: self
},
gridarea: { gridarea: {
name: "grid-area", name: "grid-area",
generate: make_margin, generate: make_margin,
@ -90,6 +102,12 @@ const handle_grid = (acc, [name, value]) => {
return acc.concat([[name, value]]) return acc.concat([[name, value]])
} }
// const handleFlex = (acc, [name, value]) => {
// if (name === "align-items" || name === "justify-content") {
// return acc.concat([name, value])
// }
// };
const object_to_css_string = [ const object_to_css_string = [
toPairs, toPairs,
reduce(handle_grid, []), reduce(handle_grid, []),
@ -100,7 +118,9 @@ const object_to_css_string = [
export const generate_css = ({ layout, position }) => { export const generate_css = ({ layout, position }) => {
let _layout = pipe(layout, object_to_css_string) let _layout = pipe(layout, object_to_css_string)
_layout = _layout.length ? _layout + "\ndisplay: grid;" : _layout if (_layout.length) {
_layout += `\ndisplay: ${_layout.includes("flex") ? "flex" : "grid"};`;
}
return { return {
layout: _layout, layout: _layout,

View File

@ -5,7 +5,6 @@ export const store = getStore()
export const initialise = async () => { export const initialise = async () => {
try { try {
console.log(process.env.NODE_ENV);
if (process.env.NODE_ENV === "production") { if (process.env.NODE_ENV === "production") {
LogRocket.init("knlald/budibase"); LogRocket.init("knlald/budibase");
} }

View File

@ -6,6 +6,7 @@
<title>Budibase Builder</title> <title>Budibase Builder</title>
<link href="https://cdn.jsdelivr.net/npm/remixicon@2.3.0/fonts/remixicon.css" rel="stylesheet">
<link rel='icon' type='image/png' href='/_builder/favicon.png'> <link rel='icon' type='image/png' href='/_builder/favicon.png'>
<link rel='stylesheet' href='/_builder/global.css'> <link rel='stylesheet' href='/_builder/global.css'>
<link rel='stylesheet' href='/_builder/codemirror.css'> <link rel='stylesheet' href='/_builder/codemirror.css'>

View File

@ -29,7 +29,7 @@
$store.currentFrontEndType === "page" $store.currentFrontEndType === "page"
? getProps($store.currentPreviewItem, ["name", "favicon"]) ? getProps($store.currentPreviewItem, ["name", "favicon"])
: getProps($store.currentPreviewItem, ["name", "description", "route"]) : getProps($store.currentPreviewItem, ["name", "description", "route"])
$: console.log(screen_props)
const onPropChanged = store.setComponentProp const onPropChanged = store.setComponentProp
const onStyleChanged = store.setComponentStyle const onStyleChanged = store.setComponentStyle

View File

@ -1,5 +1,6 @@
<script> <script>
import InputGroup from "../common/Inputs/InputGroup.svelte" import InputGroup from "../common/Inputs/InputGroup.svelte"
import LayoutTemplateControls from "./LayoutTemplateControls.svelte";
export let onStyleChanged = () => {} export let onStyleChanged = () => {}
export let component export let component
@ -25,6 +26,12 @@
templatecolumns: ["Grid Columns", single], templatecolumns: ["Grid Columns", single],
} }
$: display = {
direction: ["Direction", single],
align: ["Align", single],
justify: ["Justify", single],
}
$: positions = { $: positions = {
column: ["Column", se], column: ["Column", se],
row: ["Row", se], row: ["Row", se],
@ -49,22 +56,24 @@
<h3>Styles</h3> <h3>Styles</h3>
<h4>Positioning</h4> <h4>Display</h4>
<div class="layout-pos"> <div class="layout-pos">
{#each Object.entries(layouts) as [key, [name, meta, size]] (component._id + key)} {#each Object.entries(display) as [key, [name, meta, size]] (component._id + key)}
<div class="grid"> <div class="grid">
<h5>{name}:</h5> <h5>{name}:</h5>
<InputGroup <LayoutTemplateControls
onStyleChanged={_value => onStyleChanged('layout', key, _value)} onStyleChanged={_value => onStyleChanged('layout', key, _value)}
values={layout[key] || newValue(meta.length)} values={layout[key] || newValue(meta.length)}
{meta} propertyName={name}
{size} {meta}
type="text" /> {size}
type="text"
/>
</div> </div>
{/each} {/each}
</div> </div>
<h4>Positioning</h4> <!-- <h4>Positioning</h4>
<div class="layout-pos"> <div class="layout-pos">
{#each Object.entries(positions) as [key, [name, meta, size]] (component._id + key)} {#each Object.entries(positions) as [key, [name, meta, size]] (component._id + key)}
<div class="grid"> <div class="grid">
@ -76,7 +85,7 @@
{size} /> {size} />
</div> </div>
{/each} {/each}
</div> </div> -->
<h4>Spacing</h4> <h4>Spacing</h4>
<div class="layout-spacing"> <div class="layout-spacing">

View File

@ -0,0 +1,81 @@
<script>
import PlusButton from "../common/PlusButton.svelte"
export let meta = []
export let size = ""
export let values = []
export let propertyName
export let onStyleChanged = () => {}
let _values = values.map(v => v)
$: onStyleChanged(_values)
const PROPERTY_OPTIONS = {
Direction: {
vertical: ["column", "ri-layout-column-line"],
horizontal: ["row", "ri-layout-row-line"],
},
Align: {
left: ["flex-start", "ri-align-left"],
center: ["center", "ri-align-center"],
right: ["flex-end", "ri-align-right"],
space: ["space-between", "ri-space"],
},
Justify: {
left: ["flex-start", "ri-align-left"],
center: ["center", "ri-align-center"],
right: ["flex-end", "ri-align-right"],
space: ["space-between", "ri-space"],
},
}
$: propertyChoices = Object.entries(PROPERTY_OPTIONS[propertyName])
</script>
<div class="inputs {size}">
{#each meta as { placeholder }, i}
{#each propertyChoices as [displayName, [cssPropValue, icon]]}
<button
class:selected={cssPropValue === _values[i]}
on:click={() => {
const newPropertyValue = cssPropValue === _values[i] ? '' : cssPropValue
_values[i] = newPropertyValue
}}>
<i class={icon} />
</button>
{/each}
{/each}
</div>
<style>
.selected {
color: var(--button-text);
background: var(--background-button);
}
button {
cursor: pointer;
outline: none;
border: none;
border-radius: 5px;
background: rgba(249, 249, 249, 1);
min-width: 1.8rem;
min-height: 1.8rem;
padding-bottom: 10px;
display: flex;
justify-content: center;
align-items: center;
font-size: 1.2rem;
font-weight: 700;
color: rgba(22, 48, 87, 1);
}
.inputs {
display: flex;
justify-content: space-between;
}
</style>