forked from tsai/budibase
7 changed files with 288 additions and 97 deletions
@ -0,0 +1,43 @@ |
|||||
|
<script> |
||||
|
export let categories = [] |
||||
|
export let selectedCategory = {} |
||||
|
export let onClick = category => {} |
||||
|
</script> |
||||
|
|
||||
|
<ul class="tabs"> |
||||
|
{#each categories as category} |
||||
|
<li |
||||
|
on:click={() => onClick(category)} |
||||
|
class:active={selectedCategory === category}> |
||||
|
{category.name} |
||||
|
</li> |
||||
|
{/each} |
||||
|
|
||||
|
</ul> |
||||
|
|
||||
|
<style> |
||||
|
.tabs { |
||||
|
display: flex; |
||||
|
justify-content: center; |
||||
|
list-style: none; |
||||
|
margin: 0 auto; |
||||
|
padding: 0 30px; |
||||
|
border-bottom: 1px solid #d8d8d8; |
||||
|
|
||||
|
font-size: 14px; |
||||
|
font-weight: 500; |
||||
|
letter-spacing: 0.14px; |
||||
|
} |
||||
|
|
||||
|
li { |
||||
|
color: #808192; |
||||
|
margin: 0 5px; |
||||
|
padding: 0 8px; |
||||
|
cursor: pointer; |
||||
|
} |
||||
|
|
||||
|
.active { |
||||
|
border-bottom: solid 3px #0055ff; |
||||
|
color: #393c44; |
||||
|
} |
||||
|
</style> |
||||
@ -0,0 +1,17 @@ |
|||||
|
<script> |
||||
|
import PropertyGroup from "./PropertyGroup.svelte" |
||||
|
export let panelDefinition = {} |
||||
|
export let componentInstance = {} |
||||
|
export let componentDefinition = {} |
||||
|
const getProperties = prop => panelDefinition.props[prop] |
||||
|
|
||||
|
$: props = !!panelDefinition.props && Object.keys(panelDefinition.props) |
||||
|
</script> |
||||
|
|
||||
|
{#each props as prop} |
||||
|
<PropertyGroup |
||||
|
title={prop} |
||||
|
content={getProperties(prop)} |
||||
|
{componentDefinition} |
||||
|
{componentInstance} /> |
||||
|
{/each} |
||||
@ -0,0 +1,72 @@ |
|||||
|
<script> |
||||
|
export let title = "" |
||||
|
export let content = {} |
||||
|
export let componentInstance = {} |
||||
|
export let componentDefinition = {} |
||||
|
|
||||
|
let show = false |
||||
|
|
||||
|
const propExistsOnComponentDef = prop => prop in componentDefinition.props |
||||
|
|
||||
|
const capitalize = title => title[0].toUpperCase() + title.slice(1) |
||||
|
|
||||
|
$: propertyKeys = Object.keys(content) |
||||
|
$: icon = show ? "ri-arrow-down-s-fill" : "ri-arrow-right-s-fill" |
||||
|
</script> |
||||
|
|
||||
|
<div class="property-group-container" on:click={() => (show = !show)}> |
||||
|
<div class="property-group-title"> |
||||
|
<div class="icon"> |
||||
|
<i class={icon} /> |
||||
|
</div> |
||||
|
<div class="title">{capitalize(title)}</div> |
||||
|
</div> |
||||
|
<div class="property-panel" class:show> |
||||
|
<ul> |
||||
|
{#each propertyKeys as key} |
||||
|
<!-- {#if propExistsOnComponentDef(key)} --> |
||||
|
<li>{content[key].displayName || capitalize(key)}</li> |
||||
|
<!-- {/if} --> |
||||
|
{/each} |
||||
|
</ul> |
||||
|
</div> |
||||
|
</div> |
||||
|
|
||||
|
<style> |
||||
|
.property-group-container { |
||||
|
display: flex; |
||||
|
flex-direction: column; |
||||
|
height: auto; |
||||
|
background: #fbfbfb; |
||||
|
margin: 5px; |
||||
|
padding: 5px; |
||||
|
} |
||||
|
|
||||
|
.property-group-title { |
||||
|
cursor: pointer; |
||||
|
flex: 0 0 20px; |
||||
|
display: flex; |
||||
|
flex-flow: row nowrap; |
||||
|
} |
||||
|
|
||||
|
.icon { |
||||
|
flex: 0 0 20px; |
||||
|
text-align: center; |
||||
|
} |
||||
|
|
||||
|
.title { |
||||
|
flex: 1; |
||||
|
text-align: left; |
||||
|
} |
||||
|
|
||||
|
.property-panel { |
||||
|
height: 0px; |
||||
|
overflow: hidden; |
||||
|
/* transition: height 2s ease-in-out; */ |
||||
|
} |
||||
|
|
||||
|
.show { |
||||
|
overflow: auto; |
||||
|
height: auto; |
||||
|
} |
||||
|
</style> |
||||
@ -0,0 +1,77 @@ |
|||||
|
|
||||
|
/* |
||||
|
TODO: all strings types are really inputs and could be typed as such |
||||
|
TODO: Options types need option items |
||||
|
TODO: Allow for default values for all properties |
||||
|
*/ |
||||
|
|
||||
|
export const layout = { |
||||
|
flexDirection: { displayName: "Direction", type: "string" }, |
||||
|
justifyContent: { displayName: "Justify", type: "string" }, |
||||
|
alignItems: { displayName: "Align", type: "string" }, |
||||
|
flexWrap: { displayName: "Wrap", type: "options" }, |
||||
|
} |
||||
|
|
||||
|
export const spacing = { |
||||
|
padding: { type: "string" }, |
||||
|
margin: { type: "string" }, |
||||
|
} |
||||
|
|
||||
|
export const size = { |
||||
|
width: { type: "string" }, |
||||
|
height: { type: "string" }, |
||||
|
minWidth: { displayName: "Min W", type: "string" }, |
||||
|
minHeight: { displayName: "Min H", type: "string" }, |
||||
|
maxWidth: { displayName: "Max W", type: "string" }, |
||||
|
maxHeight: { displayName: "Max H", type: "string" }, |
||||
|
overflow: { type: "string" }, //custom
|
||||
|
} |
||||
|
|
||||
|
export const position = { |
||||
|
position: { type: "options" }, |
||||
|
} |
||||
|
|
||||
|
export const typography = { |
||||
|
font: { type: "options" }, |
||||
|
weight: { type: "options" }, |
||||
|
size: { type: "string" }, |
||||
|
lineHeight: { displayName: "Line H", type: "string" }, |
||||
|
color: { type: "colour" }, |
||||
|
align: { type: "string" }, //custom
|
||||
|
transform: { type: "string" }, //custom
|
||||
|
style: { type: "string" }, //custom
|
||||
|
} |
||||
|
|
||||
|
export const background = { |
||||
|
backgroundColor: { displayName: "Background Color", type: "colour" }, |
||||
|
image: { type: "string" }, //custom
|
||||
|
} |
||||
|
|
||||
|
export const border = { |
||||
|
radius: { type: "string" }, |
||||
|
width: { type: "string" }, //custom
|
||||
|
color: { type: "colour" }, |
||||
|
style: { type: "options" }, |
||||
|
} |
||||
|
|
||||
|
export const effects = { |
||||
|
opacity: "string", |
||||
|
rotate: "string", |
||||
|
shadow: "string", |
||||
|
} |
||||
|
|
||||
|
export const transitions = { |
||||
|
property: { type: "options" }, |
||||
|
duration: { type: "string" }, |
||||
|
ease: { type: "options" }, |
||||
|
} |
||||
|
|
||||
|
export function excludeProps(props, propsToExclude) { |
||||
|
const modifiedProps = {} |
||||
|
for (const prop in props) { |
||||
|
if (!propsToExclude.includes(prop)) { |
||||
|
modifiedProps[prop] = props[prop] |
||||
|
} |
||||
|
} |
||||
|
return modifiedProps |
||||
|
} |
||||
Loading…
Reference in new issue