Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add X affordance to PeopleSelect #195

Merged
merged 1 commit into from
Jun 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions web/app/components/multiselect/user-email-image-chip.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
{{! @glint-nocheck: not typesafe yet }}
<Person
@imgURL={{@option.imgURL}}
@email={{@option.email}}
/>
<Person @imgURL={{@option.imgURL}} @email={{@option.email}} />
20 changes: 20 additions & 0 deletions web/app/components/multiselect/user-email-image-chip.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import Component from "@glimmer/component";
import { HermesUser } from "hermes/types/document";

interface MultiselectUserEmailImageChipComponentSignature {
Element: HTMLDivElement;
Args: {
option: HermesUser;
};
Blocks: {
default: [];
};
}

export default class MultiselectUserEmailImageChipComponent extends Component<MultiselectUserEmailImageChipComponentSignature> {}

declare module "@glint/environment-ember-loose/registry" {
export default interface Registry {
"multiselect/user-email-image-chip": typeof MultiselectUserEmailImageChipComponent;
}
}
4 changes: 2 additions & 2 deletions web/app/components/person/index.hbs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{! @glint-nocheck - not typesafe yet}}
{{#unless this.isHidden}}
<div class="flex space-x-2 w-full" ...attributes>
<div class="relative">
<div class="relative shrink-0">
{{#if (eq @badge "approved")}}
<div
data-test-person-approved-badge
Expand All @@ -14,7 +14,7 @@
</div>
{{/if}}
<div
class="w-5 h-5 shrink-0 overflow-hidden rounded-full flex justify-center items-center bg-[color:var(--token-color-palette-alpha-300)]"
class="w-5 h-5 overflow-hidden rounded-full flex justify-center items-center bg-[color:var(--token-color-palette-alpha-300)]"
>
{{#if @imgURL}}
<img src={{@imgURL}} referrerpolicy="no-referrer" class="w-full" />
Expand Down
2 changes: 1 addition & 1 deletion web/app/components/person/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ interface PersonComponentSignature {
Element: HTMLDivElement;
Args: {
email: string;
imgURL?: string;
imgURL?: string | null;
ignoreUnknown?: boolean;
badge?: string;
};
Expand Down
36 changes: 8 additions & 28 deletions web/app/styles/components/multiselect.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
background-size: var(--token-form-select-background-image-size);
background-repeat: no-repeat;
box-shadow: var(--token-elevation-low-box-shadow);
@apply p-1;

&--narrow {
min-width: 0;
Expand Down Expand Up @@ -36,7 +37,7 @@
}

.ember-power-select-multiple-options {
@apply flex flex-wrap h-full;
@apply flex flex-wrap h-full mr-6;
}

.ember-power-select-trigger-multiple-input {
Expand All @@ -48,35 +49,14 @@
}

.ember-power-select-multiple-option {
position: relative;
border: none;
padding: 3px 7px;
cursor: pointer;
flex-basis: 0;
white-space: nowrap;
@apply flex items-center px-0 m-0.5 max-w-[100%] relative pr-7 pl-1.5 py-1 border-0;

// avoid overlapping the dropdown affordance
width: calc(100% - 28px);

&:hover {
background: var(--token-color-palette-neutral-200);
}

.flight-icon {
vertical-align: middle;
}

// This is an unremovable element used to remove selected options.
// We don't want the little x at all, but we need to continue to use this
// button, so we're hacking it a bit.
.ember-power-select-multiple-remove-btn {
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
color: transparent;
border-radius: var(--token-form-control-border-radius);
@apply absolute right-1 grid place-items-center h-5 w-5 shrink-0 z-10 rounded-sm text-color-foreground-primary pb-px;

&:hover {
@apply bg-neutral-200;
}

&:focus,
&:active {
Expand Down