From 2938013af6ffbef82155b12f3e537ddf5f65d19e Mon Sep 17 00:00:00 2001 From: Alexander Platov Date: Sat, 9 Apr 2022 06:46:40 +0300 Subject: [PATCH] Update UserBox and Button layouts (#1343) Signed-off-by: Alexander Platov --- packages/presentation/lang/en.json | 4 +- packages/presentation/lang/ru.json | 4 +- .../presentation/src/components/Avatar.svelte | 2 +- .../src/components/SpacesPopup.svelte | 25 ++--- .../src/components/UserBox.svelte | 90 ++++++++-------- .../src/components/UsersPopup.svelte | 32 +++--- .../src/components/icons/Person.svelte | 25 +++++ packages/presentation/src/plugin.ts | 4 +- packages/theme/styles/_layouts.scss | 6 ++ packages/theme/styles/popups.scss | 12 ++- packages/ui/src/components/Button.svelte | 21 +++- packages/ui/src/components/CheckBox.svelte | 2 +- packages/ui/src/components/Dropdown.svelte | 100 +++++------------- .../ui/src/components/DropdownLabels.svelte | 9 +- .../src/components/DropdownLabelsPopup.svelte | 45 +++----- .../ui/src/components/DropdownPopup.svelte | 49 +++------ .../ui}/src/components/SelectPopup.svelte | 2 +- packages/ui/src/index.ts | 2 +- .../components/OrganizationPresenter.svelte | 2 +- .../components/OrganizationSelector.svelte | 13 ++- .../src/components/icons/Company.svelte | 3 +- .../src/components/CreateProduct.svelte | 5 +- .../src/components/CreateLead.svelte | 7 +- .../src/components/EditLead.svelte | 7 +- .../src/components/CreateApplication.svelte | 15 ++- .../src/components/CreateVacancy.svelte | 5 +- .../src/components/review/CreateReview.svelte | 10 +- .../src/components/review/EditReview.svelte | 4 +- .../src/components/CreateTagElement.svelte | 2 +- .../src/components/EditTagElement.svelte | 2 +- .../src/components/CreateTask.svelte | 4 +- .../src/components/TaskHeader.svelte | 4 +- .../kanban/KanbanTemplateSelector.svelte | 2 +- plugins/tracker-assets/lang/en.json | 3 +- plugins/tracker-assets/lang/ru.json | 2 + .../src/components/CreateIssue.svelte | 9 +- .../src/components/PrioritySelector.svelte | 3 +- .../src/components/StatusSelector.svelte | 3 +- .../src/components/issues/EditIssue.svelte | 6 +- plugins/tracker-resources/src/plugin.ts | 2 +- tests/sanity/tests/recruit.spec.ts | 6 +- 41 files changed, 282 insertions(+), 271 deletions(-) create mode 100644 packages/presentation/src/components/icons/Person.svelte rename {plugins/tracker-resources => packages/ui}/src/components/SelectPopup.svelte (98%) diff --git a/packages/presentation/lang/en.json b/packages/presentation/lang/en.json index 263b820aa2..95c21b671e 100644 --- a/packages/presentation/lang/en.json +++ b/packages/presentation/lang/en.json @@ -10,6 +10,8 @@ "Deselect": "Deselect", "AddSocialLinks": "Add social links", "Change": "Change", - "Remove": "Remove" + "Remove": "Remove", + "Search": "Search...", + "Unassigned": "Unassigned" } } diff --git a/packages/presentation/lang/ru.json b/packages/presentation/lang/ru.json index 4d379b637b..a182323321 100644 --- a/packages/presentation/lang/ru.json +++ b/packages/presentation/lang/ru.json @@ -10,6 +10,8 @@ "Deselect": "Снять выделение", "AddSocialLinks": "Добавить контактную информацию", "Change": "Изменить", - "Remove": "Удалить" + "Remove": "Удалить", + "Search": "Поиск...", + "Unassigned": "Не назначен" } } diff --git a/packages/presentation/src/components/Avatar.svelte b/packages/presentation/src/components/Avatar.svelte index e9dbcbf7f2..34440a6079 100644 --- a/packages/presentation/src/components/Avatar.svelte +++ b/packages/presentation/src/components/Avatar.svelte @@ -50,7 +50,7 @@ flex-shrink: 0; position: relative; overflow: hidden; - background-color: rgba(196, 196, 204, .2); + background-color: var(--popup-bg-hover); border-radius: 50%; pointer-events: none; diff --git a/packages/presentation/src/components/SpacesPopup.svelte b/packages/presentation/src/components/SpacesPopup.svelte index 3b97880a7b..71f9e97b09 100644 --- a/packages/presentation/src/components/SpacesPopup.svelte +++ b/packages/presentation/src/components/SpacesPopup.svelte @@ -14,18 +14,19 @@ --> -
-
-
- -
+
+
+ { }} on:change/>
-
-
-
+
+
{#each objects as space} - {/each}
-
diff --git a/packages/presentation/src/components/UserBox.svelte b/packages/presentation/src/components/UserBox.svelte index ff4ca1c754..f2139ffb65 100644 --- a/packages/presentation/src/components/UserBox.svelte +++ b/packages/presentation/src/components/UserBox.svelte @@ -18,10 +18,12 @@ import { onMount } from 'svelte' import type { IntlString } from '@anticrm/platform' import { getClient } from '../utils' - - import { Label, showPopup } from '@anticrm/ui' + import { Label, showPopup, Button, Tooltip } from '@anticrm/ui' + import type { TooltipAligment } from '@anticrm/ui' import Avatar from './Avatar.svelte' import UsersPopup from './UsersPopup.svelte' + import UserInfo from './UserInfo.svelte' + import IconPerson from './icons/Person.svelte' import type { Ref, Class } from '@anticrm/core' import contact, { Contact, formatName } from '@anticrm/contact' @@ -29,18 +31,22 @@ import presentation from '..' export let _class: Ref> - export let title: IntlString - export let caption: IntlString + export let label: IntlString + export let placeholder: IntlString = presentation.string.Search export let value: Ref | null | undefined export let show: boolean = false export let allowDeselect = false export let titleDeselect: IntlString | undefined = undefined export let readonly = false + export let kind: 'primary' | 'secondary' | 'no-border' | 'transparent' | 'link' | 'dangerous' = 'no-border' + export let size: 'small' | 'medium' | 'large' | 'x-large' = 'small' + export let justify: 'left' | 'center' = 'center' + export let width: string | undefined = undefined + export let labelDirection: TooltipAligment | undefined = undefined const dispatch = createEventDispatcher() let selected: Contact | undefined - let btn: HTMLElement let container: HTMLElement let opened: boolean = false @@ -50,16 +56,7 @@ selected = await client.findOne(_class, { _id: value }) } - $: if (value != null) { - updateSelected(value) - } - - onMount(() => { - if (btn && show) { - btn.click() - show = false - } - }) + $: if (value != null) updateSelected(value) function getName (obj: Contact): string { const isPerson = client.getHierarchy().isDerived(obj._class, contact.class.Person) @@ -67,33 +64,40 @@ } -
{ - btn.focus() - if (!opened && !readonly) { - opened = true - showPopup(UsersPopup, { _class, title, caption, allowDeselect, selected: value, titleDeselect }, container, (result) => { - if (result === null) { - value = null - selected = undefined - dispatch('change', null) - } else if (result !== undefined && result._id !== value) { - value = result._id - dispatch('change', value) +
+ + - -
- - - {#if selected}{getName(selected)}{:else} -
+ }} + > + + {#if selected} + {#if size === 'x-large'} + + {:else} + {getName(selected)} + {/if} + {:else} + + +
diff --git a/packages/presentation/src/components/UsersPopup.svelte b/packages/presentation/src/components/UsersPopup.svelte index a9c6001692..31a2784f1a 100644 --- a/packages/presentation/src/components/UsersPopup.svelte +++ b/packages/presentation/src/components/UsersPopup.svelte @@ -14,24 +14,23 @@ --> -
-
-
- -
+
+
+ { }} on:change/>
-
-
-
+
+
{#each objects as person} - {/each}
-
diff --git a/packages/presentation/src/components/icons/Person.svelte b/packages/presentation/src/components/icons/Person.svelte new file mode 100644 index 0000000000..60b28de2d9 --- /dev/null +++ b/packages/presentation/src/components/icons/Person.svelte @@ -0,0 +1,25 @@ + + + + + + + + diff --git a/packages/presentation/src/plugin.ts b/packages/presentation/src/plugin.ts index becb561d14..895a76f593 100644 --- a/packages/presentation/src/plugin.ts +++ b/packages/presentation/src/plugin.ts @@ -39,7 +39,9 @@ export default plugin(presentationId, { Deselect: '' as IntlString, AddSocialLinks: '' as IntlString, Change: '' as IntlString, - Remove: '' as IntlString + Remove: '' as IntlString, + Search: '' as IntlString, + Unassigned: '' as IntlString }, metadata: { RequiredVersion: '' as Metadata diff --git a/packages/theme/styles/_layouts.scss b/packages/theme/styles/_layouts.scss index b8b7401958..ed6c487433 100644 --- a/packages/theme/styles/_layouts.scss +++ b/packages/theme/styles/_layouts.scss @@ -182,6 +182,12 @@ p:last-child { margin-block-end: 0; } .icon { margin-right: .5rem; color: var(--theme-content-dark-color); + + &.circle { + padding: .25rem; + background-color: var(--popup-bg-hover); + border-radius: 50%; + } } .label { min-width: 0; diff --git a/packages/theme/styles/popups.scss b/packages/theme/styles/popups.scss index ae642cc605..31a2e77233 100644 --- a/packages/theme/styles/popups.scss +++ b/packages/theme/styles/popups.scss @@ -35,6 +35,8 @@ color: #d6d6d6; border: none; caret-color: var(--caret-color); + + &::placeholder { color: var(--content-color); } } } @@ -74,6 +76,14 @@ text-overflow: ellipsis; overflow: hidden; } + .check { + display: flex; + justify-content: flex-end; + align-items: center; + margin-left: 1rem; + width: 1rem; + height: 2rem; + } &:hover { background-color: var(--popup-bg-hover); } } } @@ -148,7 +158,7 @@ margin-left: 1rem; width: 1rem; height: 1rem; - } + } &-withHeader { .ap-header { diff --git a/packages/ui/src/components/Button.svelte b/packages/ui/src/components/Button.svelte index ca497bbaf4..0fa2b75b7e 100644 --- a/packages/ui/src/components/Button.svelte +++ b/packages/ui/src/components/Button.svelte @@ -21,7 +21,7 @@ import { onMount } from 'svelte' export let label: IntlString | undefined = undefined - export let kind: 'primary' | 'secondary' | 'no-border' | 'transparent' | 'dangerous' = 'secondary' + export let kind: 'primary' | 'secondary' | 'no-border' | 'transparent' | 'link' | 'dangerous' = 'secondary' export let size: 'small' | 'medium' | 'large' | 'x-large' = 'medium' export let icon: Asset | AnySvelteComponent | undefined = undefined export let justify: 'left' | 'center' = 'center' @@ -33,6 +33,8 @@ export let input: HTMLButtonElement | undefined = undefined + $: iconOnly = label === undefined && $$slots.content === undefined + onMount(() => { if (focus && input) { input.focus() @@ -44,15 +46,15 @@ @@ -158,6 +162,15 @@ } } &.transparent:hover { background-color: var(--button-bg-hover); } + &.link { + padding: 0 .875rem; + &:hover { + color: var(--caption-color); + background-color: var(--body-color); + border-color: var(--divider-color); + .btn-icon { color: var(--content-color); } + } + } &.primary { padding: 0 1rem; color: var(--white-color); diff --git a/packages/ui/src/components/CheckBox.svelte b/packages/ui/src/components/CheckBox.svelte index efd4046bfb..308d7e6b13 100644 --- a/packages/ui/src/components/CheckBox.svelte +++ b/packages/ui/src/components/CheckBox.svelte @@ -63,7 +63,7 @@ & .back { fill: var(--theme-bg-check); &.primary { - fill: var(--primary-button-enabled); + fill: var(--primary-bg-color); } } & .check { diff --git a/packages/ui/src/components/Dropdown.svelte b/packages/ui/src/components/Dropdown.svelte index 27f041232c..e670aa9cc6 100644 --- a/packages/ui/src/components/Dropdown.svelte +++ b/packages/ui/src/components/Dropdown.svelte @@ -19,9 +19,8 @@ import Label from './Label.svelte' import Icon from './Icon.svelte' - import { showPopup } from '..' - import type { AnySvelteComponent, ListItem } from '../types' - import DropdownPopup from './DropdownPopup.svelte' + import { showPopup, Button, Tooltip, DropdownPopup } from '..' + import type { AnySvelteComponent, ListItem, TooltipAligment } from '../types' import Add from './icons/Add.svelte' export let icon: Asset | AnySvelteComponent = Add @@ -29,77 +28,36 @@ export let placeholder: IntlString export let items: ListItem[] = [] export let selected: ListItem | undefined = undefined - export let show: boolean = false - let btn: HTMLElement + export let kind: 'primary' | 'secondary' | 'no-border' | 'transparent' | 'link' | 'dangerous' = 'no-border' + export let size: 'small' | 'medium' | 'large' | 'x-large' = 'small' + export let justify: 'left' | 'center' = 'center' + export let width: string | undefined = undefined + export let labelDirection: TooltipAligment | undefined = undefined + let container: HTMLElement let opened: boolean = false - - onMount(() => { - if (btn && show) { - btn.click() - show = false - } - }) -
{ - btn.focus() - if (!opened) { - opened = true - showPopup(DropdownPopup, { title: label, items, icon }, container, (result) => { - if (result) selected = result - opened = false - }) - } - }} -> -
container.click()}> - {#if selected && selected.image} - {selected.label} - {:else} - {#if typeof (icon) === 'string'} - - {:else} - - {/if} - {/if} -
- -
-
-
- {#if selected}{selected.label}{:else}
-
+
+ + +
- - diff --git a/packages/ui/src/components/DropdownLabels.svelte b/packages/ui/src/components/DropdownLabels.svelte index 4c2b8d1115..83f0528a56 100644 --- a/packages/ui/src/components/DropdownLabels.svelte +++ b/packages/ui/src/components/DropdownLabels.svelte @@ -26,11 +26,10 @@ import { createEventDispatcher } from 'svelte' import ui from '../plugin' - export let title: IntlString - export let caption: IntlString | undefined = undefined + export let label: IntlString + export let placeholder: IntlString | undefined = undefined export let items: DropdownTextItem[] export let selected: DropdownTextItem['id'] | undefined = undefined - export let header: boolean = false let btn: HTMLElement let opened: boolean = false @@ -52,7 +51,7 @@ on:click|preventDefault={() => { if (!opened) { opened = true - showPopup(DropdownLabelsPopup, { title, caption, items, selected, header }, btn, (result) => { + showPopup(DropdownLabelsPopup, { placeholder, items, selected }, btn, (result) => { if (result) { selected = result dispatch('selected', result) @@ -62,7 +61,7 @@ } }} > -
+
{#if opened} diff --git a/packages/ui/src/components/DropdownLabelsPopup.svelte b/packages/ui/src/components/DropdownLabelsPopup.svelte index 7765c12333..0a59c2ff03 100644 --- a/packages/ui/src/components/DropdownLabelsPopup.svelte +++ b/packages/ui/src/components/DropdownLabelsPopup.svelte @@ -15,53 +15,36 @@ -
- {#if header} - {#if title} -
- {:else} -
- {/if} -
- -
-
- {/if} -
-
-
+
+
+ { }} on:change/> +
+
+
{#each items.filter((x) => x.label.toLowerCase().includes(search.toLowerCase())) as item} - {/each}
-
diff --git a/packages/ui/src/components/DropdownPopup.svelte b/packages/ui/src/components/DropdownPopup.svelte index 7cd6e224b7..38269d212d 100644 --- a/packages/ui/src/components/DropdownPopup.svelte +++ b/packages/ui/src/components/DropdownPopup.svelte @@ -14,46 +14,31 @@ --> -
- {#if header} - {#if title} -
- {:else} -
- {/if} -
- -
-
- {/if} -
-
-
+
+
+ { }} on:change/> +
+
+
{#each items.filter((x) => x.label.toLowerCase().includes(search.toLowerCase())) as item} -
-