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

Update "New" button #361

Merged
merged 1 commit into from
Oct 10, 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
8 changes: 4 additions & 4 deletions web/app/components/header/nav.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@

<div class="user-buttons">
<Hds::Button
data-test-create-new-button
@route="authenticated.new"
@isIconOnly={{true}}
@text="Create draft"
@icon="file-plus"
class="create-draft-button"
@text="New"
@icon="plus"
class="pl-2.5 pr-4"
/>
<div class="relative">
{{#if this.userMenuHighlightIsShown}}
Expand Down
26 changes: 11 additions & 15 deletions web/app/styles/components/nav.scss
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
.header-nav {
@apply flex flex-wrap justify-between md:flex-nowrap items-center w-full relative;
@apply relative flex w-full flex-wrap items-center justify-between md:flex-nowrap;

.header-nav-logo {
@apply mr-6 mt-3.5 md:mt-0 shrink-0 flex items-center md:mr-0 order-1 md:h-16 hover:text-color-foreground-strong;
@apply order-1 mr-6 mt-3.5 flex shrink-0 items-center hover:text-color-foreground-strong md:mt-0 md:mr-0 md:h-16;
}

.primary-links {
@apply -ml-2.5 h-16 flex shrink-0 md:mx-6 order-3 md:order-2;
@apply order-3 -ml-2.5 flex h-16 shrink-0 md:order-2 md:mx-6;

a {
@apply px-2.5 md:px-3.5 h-full flex items-center text-color-foreground-faint;
@apply flex h-full items-center px-2.5 text-color-foreground-faint md:px-3.5;

&:hover {
@apply text-color-foreground-strong;
}

&.active {
@apply text-color-palette-blue-200 relative;
@apply relative text-color-palette-blue-200;

/* Active indicator */
&::before {
content: "";
@apply absolute w-full h-1 left-0 -bottom-px bg-color-palette-blue-200;
@apply absolute left-0 -bottom-px h-1 w-full bg-color-palette-blue-200;
}
}
}
}

.global-search {
@apply order-2 md:order-3 pt-3.5 md:py-0 w-[calc(100%-9rem)] md:w-full flex;
@apply order-2 flex w-[calc(100%-9rem)] pt-3.5 md:order-3 md:w-full md:py-0;
}

.user-buttons {
@apply flex items-center justify-end space-x-1.5 sm:ml-6 md:ml-8 order-4;
@apply order-4 flex items-center justify-end space-x-1.5 sm:ml-6 md:ml-8;
}

.user-avatar {
@apply w-[30px] h-[30px] rounded-[3px] absolute z-10 top-1/2 -translate-y-1/2 left-[3px] pointer-events-none;
@apply pointer-events-none absolute top-1/2 left-[3px] z-10 h-[30px] w-[30px] -translate-y-1/2 rounded-[3px];
}

.user-menu-external-link {
Expand All @@ -58,7 +58,7 @@
}

.search-dropdown {
@apply w-full max-w-none min-w-[320px];
@apply w-full min-w-[320px] max-w-none;
}

a {
Expand All @@ -69,15 +69,11 @@
}
}

.create-draft-button {
@apply rounded-full w-9 p-0;
}

.highlighted-new {
.hds-dropdown-list-item__interactive-text {
&::after {
content: "New";
@apply text-body-100 px-2 py-1 rounded font-medium bg-color-surface-highlight text-color-foreground-highlight ml-0.5;
@apply ml-0.5 rounded bg-color-surface-highlight px-2 py-1 text-body-100 font-medium text-color-foreground-highlight;
}
}
}
Expand Down
8 changes: 8 additions & 0 deletions web/app/styles/hds-overrides.scss
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,11 @@
@apply absolute right-1.5 top-1/2 -translate-y-1/2;
}
}

a.hds-button {
&:hover,
&:focus,
&:active {
@apply no-underline;
}
}
9 changes: 6 additions & 3 deletions web/tests/integration/components/header/nav-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import ConfigService from "hermes/services/config";

const SUPPORT_URL = "https://example.com/support";
const USER_MENU_TOGGLE_SELECTOR = "[data-test-user-menu-toggle]";
const CREATE_NEW_BUTTON = "[data-test-create-new-button]";

module("Integration | Component | header/nav", function (hooks) {
setupRenderingTest(hooks);
Expand All @@ -19,7 +20,7 @@ module("Integration | Component | header/nav", function (hooks) {

hooks.beforeEach(function () {
let authenticatedUserSvc = this.owner.lookup(
"service:authenticated-user"
"service:authenticated-user",
) as AuthenticatedUserService;

authenticatedUserSvc._info = {
Expand All @@ -41,6 +42,8 @@ module("Integration | Component | header/nav", function (hooks) {
assert.dom('[data-test-nav-link="my"]').hasAttribute("href", "/my");
assert.dom('[data-test-nav-link="drafts"]').hasAttribute("href", "/drafts");

assert.dom(CREATE_NEW_BUTTON).hasText("New").hasAttribute("href", "/new");

assert.dom(".global-search").exists();

await click(USER_MENU_TOGGLE_SELECTOR);
Expand All @@ -66,7 +69,7 @@ module("Integration | Component | header/nav", function (hooks) {

assert.equal(
window.localStorage.getItem("emailNotificationsHighlightIsShown"),
null
null,
);

assert.dom("[data-test-user-menu-highlight]").exists("highlight is shown");
Expand All @@ -82,7 +85,7 @@ module("Integration | Component | header/nav", function (hooks) {
.hasPseudoElementStyle(
"after",
{ content: '"New"' },
"highlighted link has the correct class and pseudoElement text"
"highlighted link has the correct class and pseudoElement text",
);

// close and reopen the menu
Expand Down