From 0dbc4fcd3cb0dc0dd55a860b7b2b8803eb6731cd Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Fri, 24 Jun 2022 14:31:35 +0100 Subject: [PATCH] Pull in more work from new design UI --- packages/bbui/src/Form/Core/Picker.svelte | 29 ++++++++++++------- .../src/components/common/RoleSelect.svelte | 0 packages/frontend-core/src/constants.js | 9 ++++++ packages/frontend-core/src/utils/index.js | 1 + packages/frontend-core/src/utils/roles.js | 22 ++++++++++++++ 5 files changed, 51 insertions(+), 10 deletions(-) create mode 100644 packages/builder/src/components/common/RoleSelect.svelte create mode 100644 packages/frontend-core/src/utils/roles.js diff --git a/packages/bbui/src/Form/Core/Picker.svelte b/packages/bbui/src/Form/Core/Picker.svelte index a3b5c147e5..92c99cd631 100644 --- a/packages/bbui/src/Form/Core/Picker.svelte +++ b/packages/bbui/src/Form/Core/Picker.svelte @@ -86,9 +86,13 @@ on:mousedown={onClick} > {#if fieldIcon} - + + {:else if fieldColour} + + + {/if} {/if} - {#if fieldColour} - + {#if fieldIcon && fieldColour} + {/if} @@ -166,9 +170,13 @@ on:click={() => onSelectOption(getOptionValue(option, idx))} > {#if getOptionIcon(option, idx)} - + + {:else if getOptionColour(option, idx)} + + + {/if} {getOptionLabel(option, idx)} @@ -180,8 +188,8 @@ > - {#if getOptionColour(option, idx)} - + {#if getOptionIcon(option, idx) && getOptionColour(option, idx)} + {/if} @@ -224,13 +232,14 @@ .spectrum-Menu-checkmark { align-self: center; margin-top: 0; + margin-left: 12px; } - .option-colour { - padding-left: 8px; - } - .option-icon { + .option-left { padding-right: 8px; } + .option-right { + padding-left: 8px; + } .spectrum-Popover :global(.spectrum-Search) { margin-top: -1px; diff --git a/packages/builder/src/components/common/RoleSelect.svelte b/packages/builder/src/components/common/RoleSelect.svelte new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/frontend-core/src/constants.js b/packages/frontend-core/src/constants.js index 33cf1b7d1c..dc16067875 100644 --- a/packages/frontend-core/src/constants.js +++ b/packages/frontend-core/src/constants.js @@ -63,3 +63,12 @@ export const TableNames = { * - Coerce types for search endpoint */ export const ApiVersion = "1" + +// Role IDs +export const Roles = { + ADMIN: "ADMIN", + POWER: "POWER", + BASIC: "BASIC", + PUBLIC: "PUBLIC", + BUILDER: "BUILDER", +} diff --git a/packages/frontend-core/src/utils/index.js b/packages/frontend-core/src/utils/index.js index 6755940289..3ba3bf0fd4 100644 --- a/packages/frontend-core/src/utils/index.js +++ b/packages/frontend-core/src/utils/index.js @@ -1,4 +1,5 @@ export * as LuceneUtils from "./lucene" export * as JSONUtils from "./json" export * as CookieUtils from "./cookies" +export * as RoleUtils from "./roles" export * as Utils from "./utils" diff --git a/packages/frontend-core/src/utils/roles.js b/packages/frontend-core/src/utils/roles.js new file mode 100644 index 0000000000..5c4aff2cf5 --- /dev/null +++ b/packages/frontend-core/src/utils/roles.js @@ -0,0 +1,22 @@ +import { Roles } from "../constants" + +const RolePriorities = { + [Roles.ADMIN]: 4, + [Roles.POWER]: 3, + [Roles.BASIC]: 2, + [Roles.PUBLIC]: 1, +} +const RoleColours = { + [Roles.ADMIN]: "var(--spectrum-global-color-static-seafoam-400)", + [Roles.POWER]: "var(--spectrum-global-color-static-purple-400)", + [Roles.BASIC]: "var(--spectrum-global-color-static-magenta-400)", + [Roles.PUBLIC]: "var(--spectrum-global-color-static-yellow-400)", +} + +export const getRolePriority = roleId => { + return RolePriorities[roleId] ?? 0 +} + +export const getRoleColour = roleId => { + return RoleColours[roleId] ?? "rgb(20, 115, 230)" +}