Component settings section tabs (#9895)

* Added tabs to the component settings section in the builder

* Review updates

* Update setting tab buttons to be size M and use a lighter font color when selected

---------

Co-authored-by: Andrew Kingston <andrew@kingston.dev>
This commit is contained in:
deanhannigan 2023-03-08 14:40:13 +00:00 committed by GitHub
parent 998eea3a4d
commit d5f7a27d07
3 changed files with 77 additions and 21 deletions

View File

@ -113,6 +113,9 @@
.spectrum-ActionButton--quiet { .spectrum-ActionButton--quiet {
padding: 0 8px; padding: 0 8px;
} }
.spectrum-ActionButton--quiet.is-selected {
color: var(--spectrum-global-color-gray-900);
}
.is-selected:not(.emphasized) .spectrum-Icon { .is-selected:not(.emphasized) .spectrum-Icon {
color: var(--spectrum-global-color-gray-900); color: var(--spectrum-global-color-gray-900);
} }

View File

@ -14,10 +14,11 @@
export let borderRight = false export let borderRight = false
let wide = false let wide = false
$: customHeaderContent = $$slots["panel-header-content"]
</script> </script>
<div class="panel" class:wide class:borderLeft class:borderRight> <div class="panel" class:wide class:borderLeft class:borderRight>
<div class="header"> <div class="header" class:custom={customHeaderContent}>
{#if showBackButton} {#if showBackButton}
<Icon name="ArrowLeft" hoverable on:click={onClickBackButton} /> <Icon name="ArrowLeft" hoverable on:click={onClickBackButton} />
{/if} {/if}
@ -43,6 +44,13 @@
<Icon name="Close" hoverable on:click={onClickCloseButton} /> <Icon name="Close" hoverable on:click={onClickCloseButton} />
{/if} {/if}
</div> </div>
{#if customHeaderContent}
<span class="custom-content-wrap">
<slot name="panel-header-content" />
</span>
{/if}
<div class="body"> <div class="body">
<slot /> <slot />
</div> </div>
@ -116,4 +124,10 @@
justify-content: flex-start; justify-content: flex-start;
align-items: stretch; align-items: stretch;
} }
.header.custom {
border: none;
}
.custom-content-wrap {
border-bottom: var(--border-light);
}
</style> </style>

View File

@ -10,6 +10,8 @@
getBindableProperties, getBindableProperties,
getComponentBindableProperties, getComponentBindableProperties,
} from "builderStore/dataBinding" } from "builderStore/dataBinding"
import { ActionButton } from "@budibase/bbui"
import { capitalise } from "helpers"
$: componentInstance = $selectedComponent $: componentInstance = $selectedComponent
$: componentDefinition = store.actions.components.getDefinition( $: componentDefinition = store.actions.components.getDefinition(
@ -25,11 +27,34 @@
) )
$: isScreen = $selectedComponent?._id === $selectedScreen?.props._id $: isScreen = $selectedComponent?._id === $selectedScreen?.props._id
$: title = isScreen ? "Screen" : $selectedComponent?._instanceName $: title = isScreen ? "Screen" : $selectedComponent?._instanceName
let section = "settings"
const tabs = ["settings", "styles", "conditions"]
$: id = $selectedComponent?._id
$: id, (section = tabs[0])
</script> </script>
{#if $selectedComponent} {#if $selectedComponent}
{#key $selectedComponent._id} {#key $selectedComponent._id}
<Panel {title} icon={componentDefinition?.icon} borderLeft> <Panel {title} icon={componentDefinition?.icon} borderLeft>
<span slot="panel-header-content">
<div class="settings-tabs">
{#each tabs as tab}
<ActionButton
size="M"
quiet
selected={section === tab}
on:click={() => {
section = tab
}}
>
{capitalise(tab)}
</ActionButton>
{/each}
</div>
</span>
{#if section == "settings"}
{#if componentDefinition?.info} {#if componentDefinition?.info}
<ComponentInfoSection {componentDefinition} /> <ComponentInfoSection {componentDefinition} />
{/if} {/if}
@ -40,17 +65,31 @@
{componentBindings} {componentBindings}
{isScreen} {isScreen}
/> />
{/if}
{#if section == "styles"}
<DesignSection {componentInstance} {componentDefinition} {bindings} /> <DesignSection {componentInstance} {componentDefinition} {bindings} />
<CustomStylesSection <CustomStylesSection
{componentInstance} {componentInstance}
{componentDefinition} {componentDefinition}
{bindings} {bindings}
/> />
{/if}
{#if section == "conditions"}
<ConditionalUISection <ConditionalUISection
{componentInstance} {componentInstance}
{componentDefinition} {componentDefinition}
{bindings} {bindings}
/> />
{/if}
</Panel> </Panel>
{/key} {/key}
{/if} {/if}
<style>
.settings-tabs {
display: flex;
gap: var(--spacing-s);
padding: 0 var(--spacing-l);
padding-bottom: var(--spacing-l);
}
</style>