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

feat(components/pages): add sky-link-list component #2784

Merged
merged 8 commits into from
Oct 4, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,17 @@
<sky-page-content>
<app-record-page-content />
</sky-page-content>
<sky-page-links>
<sky-link-list headingText="Related links">
<sky-link-list-item>
<a href="#">Analysis</a>
</sky-link-list-item>
<sky-link-list-item>
<a href="#">Tools</a>
</sky-link-list-item>
<sky-link-list-item>
<button type="button" class="sky-btn-link-inline">Settings</button>
</sky-link-list-item>
</sky-link-list>
</sky-page-links>
</sky-page>
7 changes: 7 additions & 0 deletions apps/e2e/pages-storybook/src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import { NgModule } from '@angular/core';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { Route, RouterModule } from '@angular/router';
import { provideInitialTheme } from '@skyux/theme';

import { AppComponent } from './app.component';

const routes: Route[] = [
{
path: '',
redirectTo: '/page/layouts/blocks-with-links',
pathMatch: 'full',
},
{
path: 'action-hub',
loadChildren: () =>
Expand All @@ -28,6 +34,7 @@ if (routes.length > 0 && routes.findIndex((r) => r.path === '') === -1) {
bindToComponentInputs: true,
}),
],
providers: [provideInitialTheme('modern')],
bootstrap: [AppComponent],
})
export class AppModule {}
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,6 @@
</sky-fluid-grid>
</sky-page-content>
@if (showLinks()) {
<sky-page-links>Links.</sky-page-links>
<sky-page-links><app-links /></sky-page-links>
}
</sky-page>
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { SkyBoxModule, SkyFluidGridModule } from '@skyux/layout';
import { SkyPageModule } from '@skyux/pages';
import { SkyDropdownModule } from '@skyux/popovers';

import { LinksComponent } from '../../../shared/links/links.component';

@Component({
selector: 'app-blocks-page',
standalone: true,
Expand All @@ -18,6 +20,7 @@ import { SkyDropdownModule } from '@skyux/popovers';
SkyFluidGridModule,
SkyLabelModule,
SkyPageModule,
LinksComponent,
],
templateUrl: './blocks-page.component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,6 @@
</sky-split-view>
</sky-page-content>
@if (showLinks()) {
<sky-page-links>Links.</sky-page-links>
<sky-page-links><app-links /></sky-page-links>
}
</sky-page>
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import {

import { Subject } from 'rxjs';

import { LinksComponent } from '../../../shared/links/links.component';

interface WorkspaceItem {
id: number;
amount: number;
Expand All @@ -46,6 +48,7 @@ interface WorkspaceItem {
SkyRepeaterModule,
SkySplitViewModule,
SkySummaryActionBarModule,
LinksComponent,
],
templateUrl: './fit-page.component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
</sky-page-header>
<sky-page-content class="sky-border-dark">List content</sky-page-content>
@if (showLinks()) {
<sky-page-links>Links.</sky-page-links>
<sky-page-links><app-links /></sky-page-links>
}
</sky-page>
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ import { CommonModule } from '@angular/common';
import { ChangeDetectionStrategy, Component, input } from '@angular/core';
import { SkyPageModule } from '@skyux/pages';

import { LinksComponent } from '../../../shared/links/links.component';

@Component({
selector: 'app-list-page',
standalone: true,
imports: [CommonModule, SkyPageModule],
imports: [CommonModule, SkyPageModule, LinksComponent],
templateUrl: './list-page.component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
</sky-tabset>
</sky-page-content>
@if (showLinks()) {
<sky-page-links>Links.</sky-page-links>
<sky-page-links><app-links /></sky-page-links>
}
</sky-page>
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ import { ChangeDetectionStrategy, Component, input } from '@angular/core';
import { SkyPageModule } from '@skyux/pages';
import { SkyTabsModule } from '@skyux/tabs';

import { LinksComponent } from '../../../shared/links/links.component';

@Component({
selector: 'app-tabs-page',
standalone: true,
imports: [CommonModule, SkyPageModule, SkyTabsModule],
imports: [CommonModule, SkyPageModule, SkyTabsModule, LinksComponent],
templateUrl: './tabs-page.component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
})
Expand Down
14 changes: 14 additions & 0 deletions apps/e2e/pages-storybook/src/app/shared/links/links.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<sky-link-list headingText="Links">
<sky-link-list-item>
<a href="#">Link 1</a>
</sky-link-list-item>
<sky-link-list-item>
<a href="#">Link 2</a>
</sky-link-list-item>
<sky-link-list-item>
<a href="#">Link 3</a>
</sky-link-list-item>
<sky-link-list-item>
<button type="button" class="sky-btn-link-inline">Button</button>
</sky-link-list-item>
</sky-link-list>
10 changes: 10 additions & 0 deletions apps/e2e/pages-storybook/src/app/shared/links/links.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Component } from '@angular/core';
import { SkyLinkListModule } from '@skyux/pages';

@Component({
selector: 'app-links',
standalone: true,
imports: [SkyLinkListModule],
templateUrl: './links.component.html',
})
export class LinksComponent {}
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,15 @@
</sky-row>
</sky-fluid-grid>
</sky-page-content>
<sky-page-links>
<sky-link-list
headingText="Related links"
[links]="linksLoading()"
(click)="linksLoading.set(linksLoading() ? undefined : 'loading')"
>
<sky-link-list-item>
<a href="/">Components</a>
</sky-link-list-item>
</sky-link-list>
</sky-page-links>
</sky-page>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { ChangeDetectionStrategy, Component, signal } from '@angular/core';
import { SkyBoxModule, SkyFluidGridModule } from '@skyux/layout';
import { SkyPageModule } from '@skyux/pages';

Expand All @@ -8,4 +8,6 @@ import { SkyPageModule } from '@skyux/pages';
templateUrl: './blocks-page.component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
})
export default class BlocksPageComponent {}
export default class BlocksPageComponent {
protected readonly linksLoading = signal<'loading' | undefined>(undefined);
}
10 changes: 9 additions & 1 deletion libs/components/colorpicker/testing/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,15 @@
"sourceRoot": "libs/components/colorpicker/testing/src",
"prefix": "sky",
"tags": ["testing"],
"implicitDependencies": ["colorpicker", "testing", "theme"],
"implicitDependencies": [
"colorpicker",
"core-testing",
"forms-testing",
"help-inline-testing",
"icon-testing",
"testing",
"theme"
],
"targets": {
"build": {
"command": "echo ' 🏗️ build colorpicker-testing'",
Expand Down
3 changes: 3 additions & 0 deletions libs/components/pages/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export {
SkyActionHubNeedsAttentionClickHandler,
SkyActionHubNeedsAttentionClickHandlerArgs,
} from './lib/modules/action-hub/types/action-hub-needs-attention-click-handler';
export { SkyLinkListModule } from './lib/modules/link-list/link-list.module';
export { SkyPageLink } from './lib/modules/action-hub/types/page-link';
export { SkyPageLinksInput } from './lib/modules/action-hub/types/page-links-input';
export { SkyPageModalLink } from './lib/modules/action-hub/types/page-modal-link';
Expand All @@ -19,6 +20,8 @@ export { SkyPageLayoutType } from './lib/modules/page/types/page-layout-type';
export { SkyActionHubButtonsComponent as λ2 } from './lib/modules/action-hub/action-hub-buttons.component';
export { SkyActionHubContentComponent as λ3 } from './lib/modules/action-hub/action-hub-content.component';
export { SkyActionHubComponent as λ1 } from './lib/modules/action-hub/action-hub.component';
export { SkyLinkListComponent as λ13 } from './lib/modules/link-list/link-list.component';
export { SkyLinkListItemComponent as λ14 } from './lib/modules/link-list/link-list-item.component';
export { SkyModalLinkListComponent as λ5 } from './lib/modules/modal-link-list/modal-link-list.component';
export { SkyPageHeaderActionsComponent as λ9 } from './lib/modules/page-header/page-header-actions.component';
export { SkyPageHeaderAlertsComponent as λ11 } from './lib/modules/page-header/page-header-alerts.component';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
<sky-column [screenLarge]="3" [screenXSmall]="12">
<sky-link-list
[links]="relatedLinks | skyActionHubRelatedLinksSort"
[title]="'sky_action_hub_related_links' | skyLibResources"
[headingText]="'sky_action_hub_related_links' | skyLibResources"
/>
<sky-link-list
[links]="recentLinks | skyActionHubRecentLinksResolve"
[title]="'sky_action_hub_recent_links' | skyLibResources"
[headingText]="'sky_action_hub_recent_links' | skyLibResources"
/>
<sky-modal-link-list
[links]="settingsLinks"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,7 @@ describe('Action hub component', () => {
expect(fixture.nativeElement.querySelectorAll('.sky-wait').length).toBe(
0,
);
const recent1 = fixture.nativeElement.querySelector(
'sky-link-list[ng-reflect-title="Recently accessed"] a',
);
const recent1 = fixture.nativeElement.querySelector('sky-link-list a');
expect(recent1).toHaveText('Recent link');
}));

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { Component, input } from '@angular/core';

import { SkyPageLinksInput } from '../../action-hub/types/page-links-input';
import { SkyLinkListModule } from '../link-list.module';

@Component({
standalone: true,
selector: 'sky-link-list-fixture',
template: `
<sky-link-list headingText="Heading..." [links]="links()">
@if (showLinks()) {
<sky-link-list-item>
<a href="#">Link 1</a>
</sky-link-list-item>
<sky-link-list-item>
<a href="#">Link 2</a>
</sky-link-list-item>
}
</sky-link-list>
`,
imports: [SkyLinkListModule],
})
export class LinkListFixtureComponent {
public readonly links = input<SkyPageLinksInput | undefined>();
public readonly showLinks = input<boolean>(false);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { Component } from '@angular/core';

/**
* A wrapper for each link in a link list.
*/
@Component({
standalone: true,
selector: 'sky-link-list-item',
template: `<ng-content />`,
styles: `
:host {
display: block;
margin: 0 0 var(--sky-margin-stacked-sm) 0;
}
`,
host: {
'[attr.role]': '"listitem"',
},
})
export class SkyLinkListItemComponent {}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<sky-wait [isWaiting]="links === 'loading'" />
@if (links === 'loading') {
<sky-wait [isWaiting]="links() === 'loading'" />
@if (links() === 'loading') {
<ng-container [ngTemplateOutlet]="headingTemplateRef" />
} @else {
@if (linksArray.length > 0) {
@if (hasLinks()) {
<ng-container [ngTemplateOutlet]="headingTemplateRef" />
<ul class="sky-link-list">
@for (link of linksArray; track link) {
@for (link of linksArray(); track link) {
<li>
@if (link | linkAs: 'skyHref') {
<a [skyHref]="link.permalink.url">
Expand Down Expand Up @@ -35,12 +35,11 @@
}
</li>
}
<ng-content select="sky-link-list-item" />
</ul>
}
}

<ng-template #headingTemplateRef>
<h2 class="sky-font-heading-4">
{{ title }}
</h2>
<h2 class="sky-font-heading-4">{{ headingText() }}</h2>
</ng-template>
Loading
Loading