component name tooltips

This commit is contained in:
Gerard Burns 2023-11-21 14:51:01 +00:00
parent 217ac49628
commit 96046dab3d
5 changed files with 33 additions and 6 deletions

View File

@ -1,4 +1,5 @@
import { store } from "./index" import { store } from "./index"
import { get } from "svelte/store"
import { Helpers } from "@budibase/bbui" import { Helpers } from "@budibase/bbui"
import { import {
decodeJSBinding, decodeJSBinding,
@ -238,6 +239,10 @@ export const makeComponentUnique = component => {
} }
export const getComponentText = component => { export const getComponentText = component => {
if (component == null) {
return ""
}
if (component?._instanceName) { if (component?._instanceName) {
return component._instanceName return component._instanceName
} }
@ -246,3 +251,15 @@ export const getComponentText = component => {
"component" "component"
return capitalise(type) return capitalise(type)
} }
export const getComponentName = component => {
if (component == null) {
return ""
}
const components = get(store)?.components || {};
const componentDefinition = components[component._component] || {};
const name = componentDefinition.friendlyName || componentDefinition.name || "";
return name;
}

View File

@ -1,10 +1,11 @@
<script> <script>
import { Icon } from "@budibase/bbui" import { AbsTooltip, Icon } from "@budibase/bbui"
import { createEventDispatcher, getContext } from "svelte" import { createEventDispatcher, getContext } from "svelte"
import { helpers } from "@budibase/shared-core" import { helpers } from "@budibase/shared-core"
import { UserAvatars } from "@budibase/frontend-core" import { UserAvatars } from "@budibase/frontend-core"
export let icon export let icon
export let iconTooltip
export let withArrow = false export let withArrow = false
export let withActions = true export let withActions = true
export let indentLevel = 0 export let indentLevel = 0
@ -98,7 +99,9 @@
</div> </div>
{:else if icon} {:else if icon}
<div class="icon" class:right={rightAlignIcon}> <div class="icon" class:right={rightAlignIcon}>
<AbsTooltip type="info" position="right" text={iconTooltip}>
<Icon color={iconColor} size="S" name={icon} /> <Icon color={iconColor} size="S" name={icon} />
</AbsTooltip>
</div> </div>
{/if} {/if}
<div class="text" title={showTooltip ? text : null}> <div class="text" title={showTooltip ? text : null}>

View File

@ -1,8 +1,9 @@
<script> <script>
import { Icon, Body } from "@budibase/bbui" import { AbsTooltip, Icon, Body } from "@budibase/bbui"
export let title export let title
export let icon export let icon
export let iconTooltip
export let showAddButton = false export let showAddButton = false
export let showBackButton = false export let showBackButton = false
export let showCloseButton = false export let showCloseButton = false
@ -31,7 +32,9 @@
<Icon name="ArrowLeft" hoverable on:click={onClickBackButton} /> <Icon name="ArrowLeft" hoverable on:click={onClickBackButton} />
{/if} {/if}
{#if icon} {#if icon}
<Icon name={icon} /> <AbsTooltip type="info" text={iconTooltip}>
<Icon name={icon} />
</AbsTooltip>
{/if} {/if}
<div class="title"> <div class="title">
{#if customTitleContent} {#if customTitleContent}

View File

@ -1,7 +1,7 @@
<script> <script>
import Panel from "components/design/Panel.svelte" import Panel from "components/design/Panel.svelte"
import { store, selectedComponent, selectedScreen } from "builderStore" import { store, selectedComponent, selectedScreen } from "builderStore"
import { getComponentText } from "builderStore/componentUtils" import { getComponentName } from "builderStore/componentUtils"
import ComponentSettingsSection from "./ComponentSettingsSection.svelte" import ComponentSettingsSection from "./ComponentSettingsSection.svelte"
import DesignSection from "./DesignSection.svelte" import DesignSection from "./DesignSection.svelte"
import CustomStylesSection from "./CustomStylesSection.svelte" import CustomStylesSection from "./CustomStylesSection.svelte"
@ -44,17 +44,19 @@
$: id = $selectedComponent?._id $: id = $selectedComponent?._id
$: id, (section = tabs[0]) $: id, (section = tabs[0])
$: componentName = getComponentName(componentInstance);
</script> </script>
{#if $selectedComponent} {#if $selectedComponent}
{#key $selectedComponent._id} {#key $selectedComponent._id}
<Panel {title} icon={componentDefinition?.icon} borderLeft wide> <Panel {title} icon={componentDefinition?.icon} iconTooltip={componentName} borderLeft wide>
<span class="panel-title-content" slot="panel-title-content"> <span class="panel-title-content" slot="panel-title-content">
<input <input
class="input" class="input"
value={title} value={title}
{title} {title}
placeholder={getComponentText(componentInstance)} placeholder={componentName}
on:keypress={e => { on:keypress={e => {
if (e.key.toLowerCase() === "enter") { if (e.key.toLowerCase() === "enter") {
e.target.blur() e.target.blur()

View File

@ -11,6 +11,7 @@
import { import {
findComponentPath, findComponentPath,
getComponentText, getComponentText,
getComponentName,
} from "builderStore/componentUtils" } from "builderStore/componentUtils"
import { get } from "svelte/store" import { get } from "svelte/store"
import { dndStore } from "./dndStore" import { dndStore } from "./dndStore"
@ -109,6 +110,7 @@
on:drop={onDrop} on:drop={onDrop}
text={getComponentText(component)} text={getComponentText(component)}
icon={getComponentIcon(component)} icon={getComponentIcon(component)}
iconTooltip={getComponentName(component)}
withArrow={componentHasChildren(component)} withArrow={componentHasChildren(component)}
indentLevel={level} indentLevel={level}
selected={$store.selectedComponentId === component._id} selected={$store.selectedComponentId === component._id}