From 948a6a078d0ea72c9eaeac3cd2a01c9a195b7bc0 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Tue, 21 May 2024 09:03:53 +0100 Subject: [PATCH] Assign colours to new options by defaults and use consistent colour set across the board --- .../DataTable/modals/OptionsEditor.svelte | 24 +++++-------------- .../components/grid/cells/OptionsCell.svelte | 9 ++++--- .../grid/cells/RelationshipCell.svelte | 4 ++-- .../src/components/grid/lib/utils.js | 7 ------ packages/frontend-core/src/constants.js | 4 ++++ 5 files changed, 18 insertions(+), 30 deletions(-) diff --git a/packages/builder/src/components/backend/DataTable/modals/OptionsEditor.svelte b/packages/builder/src/components/backend/DataTable/modals/OptionsEditor.svelte index 9068d5bc73..f903edfd2b 100644 --- a/packages/builder/src/components/backend/DataTable/modals/OptionsEditor.svelte +++ b/packages/builder/src/components/backend/DataTable/modals/OptionsEditor.svelte @@ -3,6 +3,7 @@ import { dndzone } from "svelte-dnd-action" import { Icon, Popover } from "@budibase/bbui" import { onMount } from "svelte" + import { Constants } from "@budibase/frontend-core" export let constraints export let optionColors = {} @@ -13,14 +14,6 @@ let colorPopovers = [] let anchors = [] - let colorsArray = [ - "hsla(0, 90%, 75%, 0.3)", - "hsla(50, 80%, 75%, 0.3)", - "hsla(120, 90%, 75%, 0.3)", - "hsla(200, 90%, 75%, 0.3)", - "hsla(240, 90%, 75%, 0.3)", - "hsla(320, 90%, 75%, 0.3)", - ] const removeInput = idx => { delete optionColors[options[idx].name] constraints.inclusion = constraints.inclusion.filter((e, i) => i !== idx) @@ -30,15 +23,10 @@ } const addNewInput = () => { - options = [ - ...options, - { name: `Option ${constraints.inclusion.length + 1}`, id: Math.random() }, - ] - constraints.inclusion = [ - ...constraints.inclusion, - `Option ${constraints.inclusion.length + 1}`, - ] - + const newOption = `Option ${constraints.inclusion.length + 1}` + options = [...options, { name: newOption, id: Math.random() }] + constraints.inclusion = [...constraints.inclusion, newOption] + optionColors[newOption] = Constants.OptionColours[(options.length - 1) % 9] colorPopovers.push(undefined) anchors.push(undefined) } @@ -124,7 +112,7 @@ animate={false} >
- {#each colorsArray as color} + {#each Constants.OptionColours as color}
handleColorChange(option.name, color, idx)} style="--color:{color};" diff --git a/packages/frontend-core/src/components/grid/cells/OptionsCell.svelte b/packages/frontend-core/src/components/grid/cells/OptionsCell.svelte index a815855b09..cb13e1db41 100644 --- a/packages/frontend-core/src/components/grid/cells/OptionsCell.svelte +++ b/packages/frontend-core/src/components/grid/cells/OptionsCell.svelte @@ -1,8 +1,8 @@