From 3776137a5270bc4c78ead3d2cef77932b6fc4a54 Mon Sep 17 00:00:00 2001 From: Andrey Sobolev Date: Wed, 24 May 2023 23:53:06 +0700 Subject: [PATCH] UBER-206: Redefined color palettes (#3243) Signed-off-by: Andrey Sobolev --- models/hr/src/index.ts | 13 +- models/lead/src/migration.ts | 13 +- models/recruit/src/index.ts | 26 ++ models/recruit/src/migration.ts | 9 +- models/tracker/src/index.ts | 44 ++- packages/kanban/tsconfig.json | 1 + .../components/breadcrumbs/Breadcrumbs.svelte | 8 +- packages/text-editor/src/Completion.ts | 4 - .../src/components/CollaboratorEditor.svelte | 5 +- packages/theme/src/Theme.svelte | 24 +- packages/theme/src/index.ts | 21 +- packages/theme/tsconfig.json | 1 + packages/ui/src/colors.ts | 315 ++++++++++++++++-- packages/ui/src/components/ColorPopup.svelte | 13 +- .../ui/src/components/MultiProgress.svelte | 9 +- packages/ui/src/components/Progress.svelte | 4 +- .../ui/src/components/ProgressCircle.svelte | 3 +- .../ui/src/components/wizard/Wizard.svelte | 6 +- packages/ui/src/index.ts | 2 + packages/ui/src/types.ts | 5 - packages/ui/tsconfig.json | 1 + .../src/components/ListHeader.svelte | 11 +- .../src/components/Day.svelte | 6 +- .../src/components/Hour.svelte | 5 +- .../src/components/Avatar.svelte | 60 +--- .../src/components/PersonContent.svelte | 28 +- .../src/components/ScheduleRequests.svelte | 6 +- .../src/components/EmployeeInbox.svelte | 6 +- .../src/components/Inbox.svelte | 24 +- .../components/NotificationPresenter.svelte | 4 +- .../src/components/CreateApplication.svelte | 32 +- .../src/components/EditApplication.svelte | 3 +- .../src/components/MoveApplication.svelte | 20 +- .../src/components/CategoryBar.svelte | 5 +- .../src/components/CollapsedTags.svelte | 7 +- .../src/components/CreateTagElement.svelte | 22 +- .../src/components/EditTagElement.svelte | 24 +- .../src/components/TagFilterPresenter.svelte | 4 +- .../src/components/TagItem.svelte | 14 +- .../components/TagReferencePresenter.svelte | 14 +- .../src/components/TagsCategoryPopup.svelte | 25 +- .../src/components/TagsFilter.svelte | 12 +- .../src/components/TagsPopup.svelte | 16 +- plugins/tags-resources/src/utils.ts | 8 +- plugins/task-assets/lang/en.json | 4 +- plugins/task-assets/lang/ru.json | 4 +- .../src/components/kanban/KanbanView.svelte | 99 ++---- .../state/DoneStatePresenter.svelte | 11 +- .../state/DoneStateRefPresenter.svelte | 8 +- .../components/state/DoneStatesPopup.svelte | 8 +- .../components/state/StatePresenter.svelte | 31 +- .../src/components/state/StatesBar.svelte | 4 +- .../src/components/state/StatesEditor.svelte | 46 ++- .../src/components/state/StatesPopup.svelte | 8 +- .../components/todos/TodoItemPresenter.svelte | 1 + .../todos/TodoStatePresenter.svelte | 4 +- .../src/components/Message.svelte | 6 +- plugins/templates-resources/tsconfig.json | 1 + plugins/tracker-assets/lang/en.json | 3 +- plugins/tracker-assets/lang/ru.json | 3 +- .../src/components/icons/StatusIcon.svelte | 16 +- .../components/issues/IssueStatusIcon.svelte | 9 +- .../src/components/issues/KanbanView.svelte | 132 +++----- .../issues/edit/SubIssueSelector.svelte | 5 +- .../components/projects/CreateProject.svelte | 14 +- .../projects/ProjectIconChooser.svelte | 22 +- .../projects/ProjectPresenter.svelte | 9 +- .../projects/ProjectSpacePresenter.svelte | 15 +- .../components/workflow/StatusEditor.svelte | 23 +- plugins/tracker-resources/src/plugin.ts | 3 +- .../components/BooleanTruePresenter.svelte | 6 +- .../src/components/ColorsPopup.svelte | 12 +- .../src/components/RolePresenter.svelte | 8 +- .../src/components/ViewletSetting.svelte | 13 +- .../linkPresenters/GithubPresenter.svelte | 4 +- .../linkPresenters/YoutubePresenter.svelte | 4 +- .../src/components/list/ListCategory.svelte | 1 + .../src/components/list/ListHeader.svelte | 47 +-- plugins/view-resources/src/utils.ts | 4 +- plugins/view/src/index.ts | 2 +- server/ws/src/server_http.ts | 2 +- 81 files changed, 897 insertions(+), 578 deletions(-) diff --git a/models/hr/src/index.ts b/models/hr/src/index.ts index 4873f60431..91b85c5d3d 100644 --- a/models/hr/src/index.ts +++ b/models/hr/src/index.ts @@ -50,6 +50,7 @@ import workbench from '@hcengineering/model-workbench' import notification from '@hcengineering/notification' import { Asset, IntlString } from '@hcengineering/platform' import hr from './plugin' +import { PaletteColorIndexes } from '@hcengineering/ui/src/colors' export { hrId } from '@hcengineering/hr' export { hrOperation } from './migration' @@ -243,7 +244,7 @@ export function createModel (builder: Builder): void { { label: hr.string.Sick, icon: hr.icon.Sick, - color: 11, + color: PaletteColorIndexes.Turquoise, value: -1 }, hr.ids.Sick @@ -255,7 +256,7 @@ export function createModel (builder: Builder): void { { label: hr.string.PTO, icon: hr.icon.PTO, - color: 9, + color: PaletteColorIndexes.Firework, value: -1 }, hr.ids.PTO @@ -267,7 +268,7 @@ export function createModel (builder: Builder): void { { label: hr.string.PTO2, icon: hr.icon.PTO, - color: 9, + color: PaletteColorIndexes.Watermelon, value: -0.5 }, hr.ids.PTO2 @@ -279,7 +280,7 @@ export function createModel (builder: Builder): void { { label: hr.string.Overtime, icon: hr.icon.Overtime, - color: 5, + color: PaletteColorIndexes.Waterway, value: 1 }, hr.ids.Overtime @@ -291,7 +292,7 @@ export function createModel (builder: Builder): void { { label: hr.string.Overtime2, icon: hr.icon.Overtime, - color: 5, + color: PaletteColorIndexes.Cerulean, value: 0.5 }, hr.ids.Overtime2 @@ -303,7 +304,7 @@ export function createModel (builder: Builder): void { { label: hr.string.Remote, icon: hr.icon.Remote, - color: 4, + color: PaletteColorIndexes.Coin, value: 0 }, hr.ids.Remote diff --git a/models/lead/src/migration.ts b/models/lead/src/migration.ts index 6152421fba..6012488b6d 100644 --- a/models/lead/src/migration.ts +++ b/models/lead/src/migration.ts @@ -19,6 +19,7 @@ import core from '@hcengineering/model-core' import { createKanbanTemplate, createSequence } from '@hcengineering/model-task' import task, { createKanban, KanbanTemplate } from '@hcengineering/task' import lead from './plugin' +import { PaletteColorIndexes } from '@hcengineering/ui/src/colors' async function createSpace (tx: TxOperations): Promise { const current = await tx.findOne(core.class.Space, { @@ -62,12 +63,12 @@ async function createSpace (tx: TxOperations): Promise { async function createDefaultKanbanTemplate (tx: TxOperations): Promise> { const defaultKanban = { states: [ - { color: 9, name: 'Incoming' }, - { color: 10, name: 'Negotation' }, - { color: 1, name: 'Offer preparing' }, - { color: 0, name: 'Make a decision' }, - { color: 11, name: 'Contract conclusion' }, - { color: 9, name: 'Done' } + { color: PaletteColorIndexes.Coin, name: 'Incoming' }, + { color: PaletteColorIndexes.Arctic, name: 'Negotation' }, + { color: PaletteColorIndexes.Watermelon, name: 'Offer preparing' }, + { color: PaletteColorIndexes.Orange, name: 'Make a decision' }, + { color: PaletteColorIndexes.Ocean, name: 'Contract conclusion' }, + { color: PaletteColorIndexes.Grass, name: 'Done' } ], doneStates: [ { isWon: true, name: 'Won' }, diff --git a/models/recruit/src/index.ts b/models/recruit/src/index.ts index 03450dde93..8d2027b530 100644 --- a/models/recruit/src/index.ts +++ b/models/recruit/src/index.ts @@ -1009,6 +1009,32 @@ export function createModel (builder: Builder): void { group: 'edit' } }) + createAction(builder, { + action: view.actionImpl.ValueSelector, + actionPopup: view.component.ValueSelector, + actionProps: { + attribute: 'doneState', + _class: task.class.DoneState, + query: {}, + searchField: 'name', + // should match space + fillQuery: { space: 'space' }, + // Only apply for same vacancy + docMatches: ['space'], + placeholder: task.string.DoneState + }, + label: task.string.DoneState, + icon: task.icon.TaskState, + keyBinding: [], + input: 'none', + category: recruit.category.Recruit, + target: recruit.class.Applicant, + context: { + mode: ['context'], + application: recruit.app.Recruit, + group: 'edit' + } + }) createAction( builder, { diff --git a/models/recruit/src/migration.ts b/models/recruit/src/migration.ts index 535e07240a..48848d9e90 100644 --- a/models/recruit/src/migration.ts +++ b/models/recruit/src/migration.ts @@ -34,6 +34,7 @@ import { createKanbanTemplate, createSequence, DOMAIN_KANBAN } from '@hcengineer import { Vacancy } from '@hcengineering/recruit' import task, { KanbanTemplate, Sequence } from '@hcengineering/task' import recruit from './plugin' +import { PaletteColorIndexes } from '@hcengineering/ui/src/colors' async function fixImportedTitle (client: MigrationClient): Promise { await client.update( @@ -189,10 +190,10 @@ async function createDefaults (tx: TxOperations): Promise { async function createDefaultKanbanTemplate (tx: TxOperations): Promise> { const defaultKanban = { states: [ - { color: 9, name: 'HR Interview' }, - { color: 10, name: 'Technical Interview' }, - { color: 1, name: 'Test task' }, - { color: 0, name: 'Offer' } + { color: PaletteColorIndexes.Coin, name: 'HR Interview' }, + { color: PaletteColorIndexes.Cerulean, name: 'Technical Interview' }, + { color: PaletteColorIndexes.Waterway, name: 'Test task' }, + { color: PaletteColorIndexes.Grass, name: 'Offer' } ], doneStates: [ { isWon: true, name: 'Won' }, diff --git a/models/tracker/src/index.ts b/models/tracker/src/index.ts index 838c550ec3..2b84a5d739 100644 --- a/models/tracker/src/index.ts +++ b/models/tracker/src/index.ts @@ -65,21 +65,22 @@ import { IssueStatus, IssueTemplate, IssueTemplateChild, + Milestone, + MilestoneStatus, Project, Scrum, ScrumRecord, - Milestone, - MilestoneStatus, TimeReportDayType, TimeSpendReport, trackerId } from '@hcengineering/tracker' -import { KeyBinding, ViewOptionsModel } from '@hcengineering/view' +import { KeyBinding, ViewOptionModel, ViewOptionsModel } from '@hcengineering/view' import tracker from './plugin' import { generateClassNotificationTypes } from '@hcengineering/model-notification' import presentation from '@hcengineering/model-presentation' import { defaultPriorities, issuePriorities } from '@hcengineering/tracker-resources/src/types' +import { PaletteColorIndexes } from '@hcengineering/ui/src/colors' export { trackerId } from '@hcengineering/tracker' export { trackerOperation } from './migration' @@ -448,7 +449,15 @@ export function createModel (builder: Builder): void { TTypeReportedTime ) - const issuesOptions: ViewOptionsModel = { + const showColors: ViewOptionModel = { + key: 'shouldShowColors', + type: 'toggle', + defaultValue: false, + actionTarget: 'display', + label: tracker.string.ShowColors + } + + const issuesOptions = (kanban: boolean): ViewOptionsModel => ({ groupBy: ['status', 'assignee', 'priority', 'component', 'milestone'], orderBy: [ ['status', SortingOrder.Ascending], @@ -474,9 +483,10 @@ export function createModel (builder: Builder): void { actionTarget: 'category', action: view.function.ShowEmptyGroups, label: view.string.ShowEmptyGroups - } + }, + ...(!kanban ? [showColors] : []) ] - } + }) builder.createDoc( view.class.Viewlet, @@ -484,7 +494,7 @@ export function createModel (builder: Builder): void { { attachTo: tracker.class.Issue, descriptor: view.viewlet.List, - viewOptions: issuesOptions, + viewOptions: issuesOptions(false), config: [ { key: '', @@ -586,7 +596,7 @@ export function createModel (builder: Builder): void { ['dueDate', SortingOrder.Ascending] ], groupDepth: 1, - other: [] + other: [showColors] } builder.createDoc( @@ -665,7 +675,7 @@ export function createModel (builder: Builder): void { ['dueDate', SortingOrder.Ascending], ['rank', SortingOrder.Ascending] ], - other: [] + other: [showColors] }, config: [ // { key: '', presenter: tracker.component.PriorityEditor, props: { kind: 'list', size: 'small' } }, @@ -728,7 +738,7 @@ export function createModel (builder: Builder): void { attachTo: tracker.class.Issue, descriptor: tracker.viewlet.Kanban, viewOptions: { - ...issuesOptions, + ...issuesOptions(true), groupDepth: 1 }, config: [] @@ -754,7 +764,7 @@ export function createModel (builder: Builder): void { ofAttribute: tracker.attribute.IssueStatus, label: tracker.string.CategoryBacklog, icon: tracker.icon.CategoryBacklog, - color: 12, + color: PaletteColorIndexes.Cloud, defaultStatusName: 'Backlog', order: 0 }, @@ -768,7 +778,7 @@ export function createModel (builder: Builder): void { ofAttribute: tracker.attribute.IssueStatus, label: tracker.string.CategoryUnstarted, icon: tracker.icon.CategoryUnstarted, - color: 13, + color: PaletteColorIndexes.Porpoise, defaultStatusName: 'Todo', order: 1 }, @@ -782,7 +792,7 @@ export function createModel (builder: Builder): void { ofAttribute: tracker.attribute.IssueStatus, label: tracker.string.CategoryStarted, icon: tracker.icon.CategoryStarted, - color: 14, + color: PaletteColorIndexes.Cerulean, defaultStatusName: 'In Progress', order: 2 }, @@ -796,7 +806,7 @@ export function createModel (builder: Builder): void { ofAttribute: tracker.attribute.IssueStatus, label: tracker.string.CategoryCompleted, icon: tracker.icon.CategoryCompleted, - color: 15, + color: PaletteColorIndexes.Grass, defaultStatusName: 'Done', order: 3 }, @@ -810,7 +820,7 @@ export function createModel (builder: Builder): void { ofAttribute: tracker.attribute.IssueStatus, label: tracker.string.CategoryCanceled, icon: tracker.icon.CategoryCanceled, - color: 16, + color: PaletteColorIndexes.Coin, defaultStatusName: 'Canceled', order: 4 }, @@ -1772,7 +1782,7 @@ export function createModel (builder: Builder): void { ['targetDate', SortingOrder.Descending], ['createOn', SortingOrder.Descending] ], - other: [] + other: [showColors] } builder.createDoc( @@ -1844,7 +1854,7 @@ export function createModel (builder: Builder): void { ['modifiedOn', SortingOrder.Descending], ['createOn', SortingOrder.Descending] ], - other: [] + other: [showColors] } builder.createDoc( diff --git a/packages/kanban/tsconfig.json b/packages/kanban/tsconfig.json index 0980a1b8b4..37ad178f48 100644 --- a/packages/kanban/tsconfig.json +++ b/packages/kanban/tsconfig.json @@ -1,4 +1,5 @@ { + "extends": "./node_modules/@hcengineering/platform-rig/profiles/ui/tsconfig.json", "compilerOptions": { "moduleResolution": "node", "target": "esnext", diff --git a/packages/presentation/src/components/breadcrumbs/Breadcrumbs.svelte b/packages/presentation/src/components/breadcrumbs/Breadcrumbs.svelte index 5eab818902..5c938eb1d9 100644 --- a/packages/presentation/src/components/breadcrumbs/Breadcrumbs.svelte +++ b/packages/presentation/src/components/breadcrumbs/Breadcrumbs.svelte @@ -13,9 +13,9 @@ // limitations under the License. --> +
diff --git a/packages/ui/src/components/ProgressCircle.svelte b/packages/ui/src/components/ProgressCircle.svelte index c91935bb23..2af05960ae 100644 --- a/packages/ui/src/components/ProgressCircle.svelte +++ b/packages/ui/src/components/ProgressCircle.svelte @@ -13,6 +13,7 @@ // limitations under the License. --> +
{ diff --git a/plugins/contact-resources/src/components/Avatar.svelte b/plugins/contact-resources/src/components/Avatar.svelte index 814df9f552..fdf5b33e9f 100644 --- a/plugins/contact-resources/src/components/Avatar.svelte +++ b/plugins/contact-resources/src/components/Avatar.svelte @@ -31,8 +31,7 @@ import { Client, Ref } from '@hcengineering/core' import { Asset, getResource } from '@hcengineering/platform' import { getBlobURL, getClient } from '@hcengineering/presentation' - import { AnySvelteComponent, Icon, IconSize, hexToRgb, imageToColor } from '@hcengineering/ui' - import { createEventDispatcher } from 'svelte' + import { AnySvelteComponent, Icon, IconSize } from '@hcengineering/ui' import { getAvatarProviderId } from '../utils' import AvatarIcon from './icons/Avatar.svelte' @@ -44,8 +43,6 @@ let url: string | undefined let avatarProvider: AvatarProvider | undefined - const dispatch = createEventDispatcher() - async function update (size: IconSize, avatar?: string | null, direct?: Blob) { if (direct !== undefined) { getBlobURL(direct).then((blobURL) => { @@ -71,64 +68,15 @@ } $: update(size, avatar, direct) - let style = '' - - async function updateStyle (avatar?: string | null, avatarProvider?: AvatarProvider) { - if (!avatar || avatarProvider?.type !== AvatarType.COLOR) { - style = '' - } else { - const uri = avatar.split('://')[1] - - const color: string | undefined = (await getResource(avatarProvider.getUrl))(uri, size) - if (color != null) { - style = `background-color: ${color}` - accentColor = hexToRgb(color) - dispatch('accent-color', accentColor) - } - } - } - $: updateStyle(avatar, avatarProvider) - let imageElement: HTMLImageElement | undefined = undefined - let accentColor: any | undefined -
+
{#if url} {#if size === 'large' || size === 'x-large'} - {''} { - if (imageElement !== undefined) { - try { - accentColor = imageToColor(imageElement) - dispatch('accent-color', accentColor) - } catch (err) { - // Ignore - } - } - }} - /> + {''} {/if} - {''} { - if (imageElement !== undefined) { - try { - accentColor = imageToColor(imageElement) - dispatch('accent-color', accentColor) - } catch (err) { - // ignore - } - } - }} - /> + {''} {:else} {/if} diff --git a/plugins/contact-resources/src/components/PersonContent.svelte b/plugins/contact-resources/src/components/PersonContent.svelte index 25e419f788..c7bbe5ae34 100644 --- a/plugins/contact-resources/src/components/PersonContent.svelte +++ b/plugins/contact-resources/src/components/PersonContent.svelte @@ -15,9 +15,17 @@ {#if value} @@ -57,7 +77,7 @@ class:mr-2={shouldShowName && !enlargedText} class:mr-3={shouldShowName && enlargedText} > - + {/if} {#if shouldShowName} diff --git a/plugins/hr-resources/src/components/ScheduleRequests.svelte b/plugins/hr-resources/src/components/ScheduleRequests.svelte index a59d269826..c8bf988507 100644 --- a/plugins/hr-resources/src/components/ScheduleRequests.svelte +++ b/plugins/hr-resources/src/components/ScheduleRequests.svelte @@ -15,7 +15,7 @@ {#if hasNotification} -
+
{/if}