Skip to content
Open
Show file tree
Hide file tree
Changes from 7 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
7 changes: 7 additions & 0 deletions libs/design-system/buttons/navigation/ng-package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"lib": {
"cssUrl": "inline",
"entryFile": "src/index.ts",
"styleIncludePaths": ["../../src/sass"]
}
}
2 changes: 2 additions & 0 deletions libs/design-system/buttons/navigation/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { Navigation } from './lib/navigation';
export { NavigationToggle } from './lib/navigation-toggle/navigation-toggle';
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<button matButton angTrackClick class="ang-navigation-toggle-button" disableRipple>
<span class="ang-navigation-toggle-text"><ng-content /></span>

<mat-icon
iconPositionEnd
class="ang-navigation-toggle-icon"
[fontIcon]="selected() ? 'expand_less' : 'expand_more'"
/>
</button>
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
@use '@angular/material' as mat;
@use 'internal/token-utils';
@use '../tokens' as *;

:host {
display: block;

@include mat.button-overrides(
(
text-container-height: 3rem,
text-label-text-color: token-utils.slot(label-color, $config),
text-icon-spacing: 0.125rem,
text-label-text-font: token-utils.slot(label-font, $config),
text-label-text-size: token-utils.slot(label-font-size, $config),
text-label-text-tracking: token-utils.slot(label-letter-spacing, $config),
text-label-text-weight: token-utils.slot(label-font-weight, $config),
text-with-icon-horizontal-padding: 0.75rem,
text-state-layer-color: transparent,
)
);

@include mat.icon-overrides(
(
color: token-utils.slot(icon-color, $config),
)
);

.ang-navigation-toggle-button {
&:focus-visible {
outline: solid 0.125rem token-utils.slot(focus-outline-color, $config);
}

:is(&.selected, &:hover, &:active, &:focus) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use focus-visible instead of focus

.ang-navigation-toggle-text {
text-decoration: underline;
text-underline-offset: 0.25rem;
text-decoration-thickness: 0.125rem;
text-decoration-color: token-utils.slot(underline-color, $config);
}
}

.ang-navigation-toggle-icon {
height: 1.25rem;
width: 1.25rem;
font-size: 1.25rem;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { render, screen } from '@testing-library/angular';
import userEvent from '@testing-library/user-event';
import { NavigationToggle } from './navigation-toggle';

describe('NavigationToggle', () => {
async function setup(link: string | null = null) {
const user = userEvent.setup();
const rendered = await render(`<ang-navigation-toggle>Category</ang-navigation-toggle>`, {
imports: [NavigationToggle],
componentProperties: {
link,
},
});

return {
user,
...rendered,
};
}

it('toggles state when clicked', async () => {
const { user } = await setup();
const toggle = screen.getByText('Category').closest('.ang-navigation-toggle-button');

expect(toggle).toBeTruthy();

const icon = toggle?.querySelector('.ang-navigation-toggle-icon');

expect(icon).toHaveAttribute('data-mat-icon-name', 'expand_more');

await user.click(toggle as Element);
expect(icon).toHaveAttribute('data-mat-icon-name', 'expand_less');

await user.click(toggle as Element);
expect(icon).toHaveAttribute('data-mat-icon-name', 'expand_more');
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { Meta, StoryObj } from '@storybook/angular';
import { NavigationToggle } from './navigation-toggle';

const meta: Meta<NavigationToggle> = {
component: NavigationToggle,
title: 'Design System/Buttons/Navigation/Navigation Toggle',
parameters: {
design: {
type: 'figma',
url: 'https://www.figma.com/design/BCEJn9KCIbBJ5MzqnojKQp/AtlasNG-Components?node-id=2101-11132',
},
},
render: (args) => ({
props: args,
template: `<ang-navigation-toggle>Label</ang-navigation-toggle>`,
}),
};

export default meta;
type Story = StoryObj<NavigationToggle>;

export const Default: Story = {};
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { ChangeDetectionStrategy, Component, model } from '@angular/core';
import { MatButtonModule } from '@angular/material/button';
import { MatIconModule } from '@angular/material/icon';
import { TrackClick } from '@atlasng/analytics';

@Component({
selector: 'ang-navigation-toggle',
imports: [MatButtonModule, MatIconModule, TrackClick],
templateUrl: './navigation-toggle.html',
styleUrl: './navigation-toggle.scss',
changeDetection: ChangeDetectionStrategy.OnPush,
host: {
'[attr.selected]': 'selected()',
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change to a class, i.e. [class.ang-navigation-toggle-selected]

'(click)': 'selected.set(!selected())',
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer using the update method. selected.update(s => !s)

},
})
export class NavigationToggle {
/** Whether the button is currently selected */
readonly selected = model<boolean>(false);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove <boolean>, it is inferred

}
3 changes: 3 additions & 0 deletions libs/design-system/buttons/navigation/src/lib/navigation.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<button matButton angTrackClick class="ang-navigation-button" target="_blank" disableRipple [angAnyLink]="link()">
<span class="ang-navigation-text"><ng-content /></span>
</button>
36 changes: 36 additions & 0 deletions libs/design-system/buttons/navigation/src/lib/navigation.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
@use '@angular/material' as mat;
@use 'internal/token-utils';
@use './tokens' as *;

:host {
display: block;

@include mat.button-overrides(
(
text-container-height: 3rem,
text-label-text-color: token-utils.slot(label-color, $config),
text-icon-spacing: 0.125rem,
text-label-text-font: token-utils.slot(label-font, $config),
text-label-text-size: token-utils.slot(label-font-size, $config),
text-label-text-tracking: token-utils.slot(label-letter-spacing, $config),
text-label-text-weight: token-utils.slot(label-font-weight, $config),
text-with-icon-horizontal-padding: 0.75rem,
text-state-layer-color: transparent,
)
);

.ang-navigation-button {
&:focus-visible {
outline: solid 0.125rem token-utils.slot(focus-outline-color, $config);
}

:is(&:hover, &:active, &:focus) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use focus-visible instead of focus

.ang-navigation-text {
text-decoration: underline;
text-underline-offset: 0.25rem;
text-decoration-thickness: 0.125rem;
text-decoration-color: token-utils.slot(underline-color, $config);
}
}
}
}
30 changes: 30 additions & 0 deletions libs/design-system/buttons/navigation/src/lib/navigation.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { render, screen } from '@testing-library/angular';
import userEvent from '@testing-library/user-event';
import { Navigation } from './navigation';

describe('Navigation', () => {
async function setup(link: string | null = null) {
const user = userEvent.setup();

await render(`<ang-navigation [link]="link">Go to Docs</ang-navigation>`, {
imports: [Navigation],
componentProperties: {
link,
},
});

const button = screen.getByRole('button', { name: 'Go to Docs' });

return {
user,
button,
};
}

it('renders projected content inside the navigation button', async () => {
const { button } = await setup();

expect(button).toBeInTheDocument();
expect(button).toHaveTextContent('Go to Docs');
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { Meta, StoryObj } from '@storybook/angular';
import { Navigation } from './navigation';

const meta: Meta<Navigation> = {
component: Navigation,
title: 'Design System/Buttons/Navigation',
parameters: {
design: {
type: 'figma',
url: 'https://www.figma.com/design/BCEJn9KCIbBJ5MzqnojKQp/AtlasNG-Components?node-id=7493-48830',
},
},
args: {
link: 'https://example.com',
},
render: (args) => ({
props: args,
template: `<ang-navigation [link]="link">Label</ang-navigation>`,
}),
};

export default meta;
type Story = StoryObj<Navigation>;

export const Default: Story = {};
16 changes: 16 additions & 0 deletions libs/design-system/buttons/navigation/src/lib/navigation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { ChangeDetectionStrategy, Component, input } from '@angular/core';
import { MatButtonModule } from '@angular/material/button';
import { TrackClick } from '@atlasng/analytics';
import { AnyLink, AnyLinkCommand } from '@atlasng/common';

@Component({
selector: 'ang-navigation',
imports: [MatButtonModule, AnyLink, TrackClick],
templateUrl: './navigation.html',
styleUrl: './navigation.scss',
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class Navigation {
/** The link to navigate to */
readonly link = input<AnyLinkCommand | null>(null);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove null, input<AnyLinkCommand>()

}
19 changes: 19 additions & 0 deletions libs/design-system/buttons/navigation/src/lib/tokens.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
@use 'internal/token-utils';

$config: (
namespace: 'navigation',
tokens: (
label-color: token-utils.sys-token(on-surface),
icon-color: token-utils.sys-token(on-surface-variant),
underline-color: token-utils.sys-token(primary),
focus-outline-color: token-utils.sys-token(on-surface),
label-font: token-utils.sys-token(title-medium-font),
label-font-size: token-utils.sys-token(title-medium-size),
label-letter-spacing: token-utils.sys-token(title-medium-tracking),
label-font-weight: token-utils.sys-token(title-medium-weight),
),
);

@mixin overrides($overrides) {
@include token-utils.apply-overrides($overrides, $config);
}
5 changes: 4 additions & 1 deletion nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,10 @@
"preVersionCommand": "npx nx run-many -t build --projects=tag:library",
"manifestRootsToUpdate": [
"{projectRoot}",
{ "path": "{workspaceRoot}/dist/{projectRoot}", "preserveLocalDependencyProtocols": false }
{
"path": "{workspaceRoot}/dist/{projectRoot}",
"preserveLocalDependencyProtocols": false
}
],
"currentVersionResolver": "git-tag",
"fallbackCurrentVersionResolver": "disk"
Expand Down
3 changes: 3 additions & 0 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
"@atlasng/core": ["./libs/core/src/index.ts"],
"@atlasng/design-system": ["./libs/design-system/src/index.ts"],
"@atlasng/design-system/buttons/help": ["./libs/design-system/buttons/help/src/index.ts"],
"@atlasng/design-system/buttons/navigation-category-toggle": [
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update

"./libs/design-system/buttons/navigation-category-toggle/src/index.ts"
],
"@atlasng/design-system/buttons/social-media": ["./libs/design-system/buttons/social-media/src/index.ts"],
"@atlasng/design-system/indicators/end-of-results": [
"./libs/design-system/indicators/end-of-results/src/index.ts"
Expand Down