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

Draft permissions UI #255

Merged
merged 52 commits into from
Jul 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
cdc56d5
WIP sidebar tweaks
jeffdaley Jun 14, 2023
68a2f9b
Merge branch 'main' into jeffdaley/sidebar-overview
jeffdaley Jun 14, 2023
f5a7b02
Prototype success animation
jeffdaley Jun 14, 2023
021d0b4
Improved animations and icon-display logic
jeffdaley Jun 14, 2023
c6871e6
Prep for loading state
jeffdaley Jun 14, 2023
d68565e
Merge branch 'main' into jeffdaley/sidebar-overview
jeffdaley Jun 15, 2023
1272506
Update index.ts
jeffdaley Jun 15, 2023
17672cb
Merge branch 'jeffdaley/fix-header' into jeffdaley/sidebar-overview
jeffdaley Jun 15, 2023
0552257
Create index.hbs
jeffdaley Jun 15, 2023
7a81d80
Move folders
jeffdaley Jun 15, 2023
9c42126
Popover tweak, type fixes
jeffdaley Jun 15, 2023
16088b4
Merge branch 'main' into jeffdaley/sidebar-overview
jeffdaley Jul 5, 2023
8dd6f17
Cleanup, style tweaks
jeffdaley Jul 5, 2023
79d80f2
WIP Tooltip states
jeffdaley Jul 5, 2023
1f697be
Improve most UX bugs
jeffdaley Jul 5, 2023
515ef51
Add isSelected check
jeffdaley Jul 6, 2023
f35d226
Copy and design tweaks
jeffdaley Jul 6, 2023
0e30c35
WIP: Tooltip delay
jeffdaley Jul 6, 2023
f834df0
Add delay to tooltip
jeffdaley Jul 6, 2023
a909bc0
Reduce default delay
jeffdaley Jul 6, 2023
49737d9
Cleanup and documentation
jeffdaley Jul 6, 2023
df3d572
Cleanup and documentation
jeffdaley Jul 6, 2023
df00543
Merge branch 'jeffdaley/tooltip-delay' into jeffdaley/draft-visibilit…
jeffdaley Jul 6, 2023
74207eb
Add open animation
jeffdaley Jul 7, 2023
a4d26d2
WIP tile styles
jeffdaley Jul 7, 2023
c77a233
Merge branch 'jeffdaley/tile-typography' into jeffdaley/draft-visibil…
jeffdaley Jul 7, 2023
6f33aec
Update thumbnail.hbs
jeffdaley Jul 7, 2023
ca3554d
Badge style tweaks
jeffdaley Jul 7, 2023
92c9e4d
Add default animation
jeffdaley Jul 7, 2023
b081e18
Merge branch 'jeffdaley/tooltip-animation' into jeffdaley/draft-visib…
jeffdaley Jul 7, 2023
04d56fd
Update tooltip.ts
jeffdaley Jul 7, 2023
47ac4fa
Update sidebar.scss
jeffdaley Jul 7, 2023
6627e3d
Merge branch 'main' into jeffdaley/draft-visibility-toggle
jeffdaley Jul 17, 2023
0d33bd3
Update sidebar.hbs
jeffdaley Jul 17, 2023
be5313f
Merge branch 'main' into jeffdaley/draft-visibility-toggle
jeffdaley Jul 17, 2023
8d24a00
Merge branch 'main' into jeffdaley/draft-visibility-toggle
jeffdaley Jul 18, 2023
73ff328
Basic wiring up
jeffdaley Jul 18, 2023
8d4b45e
Update copyable URL (draft)
jeffdaley Jul 19, 2023
4dada54
Add documentation to CopyURL
jeffdaley Jul 19, 2023
263b8b8
Revert out-of-scope changes
jeffdaley Jul 19, 2023
4ce452e
Revert drastic design changes
jeffdaley Jul 19, 2023
132128a
Rename a prop
jeffdaley Jul 19, 2023
a0375ba
Improve UI reactivity
jeffdaley Jul 19, 2023
37d59d4
Remove unused property
jeffdaley Jul 19, 2023
05d5492
Remove unused import
jeffdaley Jul 19, 2023
8112020
Rename didInsert
jeffdaley Jul 19, 2023
bdd3b2e
Documentation and dasherize test
jeffdaley Jul 19, 2023
221652c
Remove old code, unused color variables
jeffdaley Jul 19, 2023
274edc2
CSS tweak
jeffdaley Jul 19, 2023
1a3b787
Add CopyURLButton tests
jeffdaley Jul 19, 2023
bda5c5b
Additional tests and cleanup
jeffdaley Jul 19, 2023
8e23b77
Fix failing tests
jeffdaley Jul 19, 2023
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
10 changes: 6 additions & 4 deletions web/app/components/copy-u-r-l-button.hbs
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
{{! @glint-nocheck: not typesafe yet }}
<Action
data-test-copy-url-button
data-test-url={{@url}}
data-test-icon={{this.icon}}
{{tooltip
(if this.urlWasRecentlyCopied "Copied!" "Copy URL")
placement=(or @tooltipPlacement "top")
this.tooltipText
placement=@tooltipPlacement
isForcedOpen=this.tooltipIsForcedOpen
stayOpenOnClick=true
}}
{{did-insert this.didInsertButton}}
{{on "click" (perform this.copyURL)}}
...attributes
>
<FlightIcon @name={{if this.urlWasRecentlyCopied "check" "link"}} />
<FlightIcon @name={{this.icon}} />
</Action>
50 changes: 47 additions & 3 deletions web/app/components/copy-u-r-l-button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ interface CopyURLButtonComponentSignature {
Args: {
url: string;
tooltipPlacement?: Placement;
tooltipIsForcedOpen?: boolean;
tooltipText?: string;
icon?: string;
};
}

Expand All @@ -21,20 +24,55 @@ export default class CopyURLButtonComponent extends Component<CopyURLButtonCompo

/**
* Whether the URL was recently copied to the clipboard.
* Used to determine if the tooltip should say "Copy URL" or "Copied."
* Used to determine if the tooltip should say "Copy link" or "Copied."
* Temporarily set true when the URL is successfully copied.
*/
@tracked protected urlWasRecentlyCopied = false;

/**
* The button element.
* The button element, captured on render.
* Used to get the tooltip's ID by way of the `aria-describedby` attribute.
*/
@tracked private button: HTMLElement | null = null;

/**
* Whether the tooltip is forced open regardless of hover state.
* True when the parent has provided text for the tooltip,
* such as "Creating link..." and "Link created!"
*/
protected get tooltipIsForcedOpen() {
return this.args.tooltipIsForcedOpen ?? false;
}

/**
* The icon to show in the button.
* If the parent has provided an icon, e.g., "loading," use that.
* Otherwise use use "link" or, if a URL was recently copied, "check."
*/
protected get icon() {
if (this.args.icon) {
return this.args.icon;
} else {
return this.urlWasRecentlyCopied ? "check" : "link";
}
}

/**
* The text to show in the tooltip.
* If the parent has provided text, e.g., "Loading," use that.
* Otherwise use "Copy link" or, if a URL was recently copied, "Link copied!"
*/
get tooltipText(): string {
if (this.args.tooltipText) {
return this.args.tooltipText;
} else {
return this.urlWasRecentlyCopied ? "Link copied!" : "Copy link";
}
}

/**
* The action called when the button is clicked.
* Registers the button element locally.
* Registers the button locally for its `aria-describedby` attribute.
*/
@action protected didInsertButton(e: HTMLElement) {
this.button = e;
Expand Down Expand Up @@ -83,3 +121,9 @@ export default class CopyURLButtonComponent extends Component<CopyURLButtonCompo
}
});
}

declare module "@glint/environment-ember-loose/registry" {
export default interface Registry {
CopyURLButton: typeof CopyURLButtonComponent;
}
}
159 changes: 111 additions & 48 deletions web/app/components/document/sidebar.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@
@isCollapsed={{@isCollapsed}}
@toggleCollapsed={{@toggleCollapsed}}
@userHasScrolled={{this.userHasScrolled}}
@shareButtonIsShown={{this.shareButtonIsShown}}
@shareButtonTooltipText={{this.temporaryShareButtonTooltipText}}
@shareButtonIcon={{this.temporaryShareButtonIcon}}
/>

{{#unless @isCollapsed}}
<div
class="sidebar-body"
{{on "scroll" this.onScroll}}
{{did-insert this.registerBody}}
{{did-insert this.didInsertBody}}
>
{{#let (get-product-id this.product) as |productIcon|}}
{{#if productIcon}}
Expand All @@ -24,62 +27,119 @@
{{/let}}

<div class="sidebar-body-container">
<div class="flex flex-col items-start space-y-2">
{{#if (is-empty @document.docNumber)}}
<small class="hds-typography-body-100 hds-foreground-faint">{{#unless
(is-empty @document.docType)
}}{{@document.docType}}{{/unless}}
</small>
{{else}}
<small class="hds-typography-body-100 hds-foreground-faint">{{#unless
(is-empty @document.docType)
}}{{@document.docType}}{{/unless}}
&bullet;
<span data-test-sidebar-doc-number>
{{@document.docNumber}}
</span>
</small>
{{/if}}
<div>
{{! div to break the parent's space-y styles }}
<div
class="flex items-center space-x-1.5
{{if this.isDraft 'mb-4 -mt-2' 'mb-2'}}"
>
<Hds::Badge
data-test-sidebar-title-badge
@text={{if this.isDraft "Draft" @document.docNumber}}
class="uppercase !rounded-[3px]
{{if
@document.isDraft
'!bg-color-palette-neutral-500 !text-white'
'!bg-transparent pl-0 !text-color-foreground-faint'
}}
"
/>
{{#if this.isDraft}}
<X::DropdownList
data-test-draft-visibility-dropdown
@items={{this.draftVisibilityOptions}}
@selected={{this.draftVisibility}}
@renderOut={{true}}
@offset={{hash mainAxis=0 crossAxis=-7}}
class="w-[350px]"
>
<:anchor as |dd|>
<dd.ToggleAction
data-test-draft-visibility-toggle
data-test-icon={{this.draftVisibilityIcon}}
data-test-chevron-direction={{if
dd.contentIsShown
"up"
"down"
}}
class="flex items-center text-color-foreground-faint sidebar-header-button draft-visibility-button"
{{tooltip
this.toggleDraftVisibilityTooltipText
placement="bottom"
}}
>
<FlightIcon @name={{this.draftVisibilityIcon}} />
<FlightIcon
@name={{if dd.contentIsShown "chevron-up" "chevron-down"}}
/>
</dd.ToggleAction>
</:anchor>
<:item as |dd|>
<dd.Action
data-test-draft-visibility-option
data-test-is-checked={{dd.isSelected}}
data-test-value={{dd.value}}
class="flex items-start gap-3 py-2.5 pl-4 pr-6"
{{on "click" (perform this.setDraftVisibility dd.value)}}
>
<FlightIcon @name={{dd.attrs.icon}} class="shrink-0 mt-0.5" />
<div class="w-full">
<h4>{{dd.attrs.title}}</h4>
<p>{{dd.attrs.description}}</p>
</div>
<FlightIcon
@name="check"
class="check shrink-0 mt-0.5
{{if dd.isSelected 'visible' 'invisible'}}"
/>
</dd.Action>
</:item>
</X::DropdownList>
{{/if}}
</div>
{{#if this.editingIsDisabled}}
<h1
class="hds-typography-display-300 hds-font-weight-semibold hds-foreground-strong"
>{{this.title}}</h1>
{{else}}
<EditableField
@value={{this.title}}
@onChange={{perform this.save "title"}}
@loading={{this.save.isRunning}}
@disabled={{this.editingIsDisabled}}
>
<:default>
{{#unless (is-empty this.title)}}
<h1
class="hds-typography-display-300 hds-font-weight-semibold hds-foreground-strong"
>{{this.title}}</h1>
{{else}}
<h1
class="hds-typography-display-300 hds-font-weight-semibold hds-foreground-faint"
>Enter a title here.</h1>
{{/unless}}
</:default>
<:editing as |F|>
<Hds::Form::Textarea::Field
{{auto-height-textarea}}
@value={{F.value}}
class="primary-textarea"
name="title"
{{on "blur" F.update}}
as |F|
/>
</:editing>
</EditableField>
<div class="mb-8">
<EditableField
@value={{this.title}}
@onChange={{perform this.save "title"}}
@loading={{this.save.isRunning}}
@disabled={{this.editingIsDisabled}}
>
<:default>
{{#unless (is-empty this.title)}}
<h1
class="hds-typography-display-300 hds-font-weight-semibold hds-foreground-strong"
>{{this.title}}</h1>
{{else}}
<h1
class="hds-typography-display-300 hds-font-weight-semibold hds-foreground-faint"
>Enter a title here.</h1>
{{/unless}}
</:default>
<:editing as |F|>
<Hds::Form::Textarea::Field
{{auto-height-textarea}}
@value={{F.value}}
class="primary-textarea"
name="title"
{{on "blur" F.update}}
as |F|
/>
</:editing>
</EditableField>
</div>
{{/if}}
</div>

<hr class="border-0 border-b hds-border-faint" />

<div class="flex flex-col items-start space-y-2">
<Document::Sidebar::SectionHeader @title="Summary" />
{{! Summary }}
<div class="mb-5">
<Document::Sidebar::SectionHeader @title="Summary" class="mb-2" />
{{#if this.editingIsDisabled}}
<p
class="hds-typography-body-200 hds-font-weight-medium hds-foreground-primary"
Expand Down Expand Up @@ -120,7 +180,10 @@

<div class="flex flex-col items-start space-y-2">
<Document::Sidebar::SectionHeader @title="Status" />
<Doc::State @state={{@document.status}} @hideProgress={{true}} />
<div class="flex space-x-1">
<Doc::State @state={{@document.status}} @hideProgress={{true}} />
<Hds::Badge @text={{@document.docType}} />
</div>
</div>

<div class="flex flex-col items-start space-y-2">
Expand Down
Loading