This repository has been archived by the owner on Jun 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4542aa3
commit 5c3a382
Showing
23 changed files
with
277 additions
and
0 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
apps/docs/src/app/examples/breadcrumbs/basic/basic.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<anglify-breadcrumbs [items]="items"></anglify-breadcrumbs> |
Empty file.
31 changes: 31 additions & 0 deletions
31
apps/docs/src/app/examples/breadcrumbs/basic/basic.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { ChangeDetectionStrategy, Component } from '@angular/core'; | ||
import { BreadCrumb } from 'libs/anglify/src/modules/breadcrumbs/breadcrumbs.interface'; | ||
|
||
@Component({ | ||
templateUrl: './basic.component.html', | ||
styleUrls: ['./basic.component.scss'], | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class BasicComponent { | ||
public items: BreadCrumb[] = [ | ||
{ | ||
text: 'Home', | ||
disabled: false, | ||
href: '#', | ||
routerLink: ['/components/breadcrumbs'], | ||
}, | ||
{ | ||
text: 'About', | ||
disabled: false, | ||
href: '#', | ||
routerLink: ['/getting-started/installation'], | ||
}, | ||
{ | ||
text: 'Contact', | ||
disabled: true, | ||
href: '#', | ||
routerLink: ['/components/card'], | ||
}, | ||
]; | ||
} | ||
export default BasicComponent; |
11 changes: 11 additions & 0 deletions
11
apps/docs/src/app/examples/breadcrumbs/breadcrumbs-example.module.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { BreadcrumbsModule, IconModule } from '@anglify/components'; | ||
import { CommonModule } from '@angular/common'; | ||
import { NgModule } from '@angular/core'; | ||
import { BasicComponent } from './basic/basic.component'; | ||
import { IconComponent } from './icon/icon.component'; | ||
|
||
@NgModule({ | ||
declarations: [BasicComponent, IconComponent], | ||
imports: [CommonModule, BreadcrumbsModule, IconModule], | ||
}) | ||
export class BreadcrumbsExampleModule {} |
5 changes: 5 additions & 0 deletions
5
apps/docs/src/app/examples/breadcrumbs/icon/icon.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<anglify-breadcrumbs [items]="items"> | ||
<ng-template slot="divider"> | ||
<anglify-icon icon="mdi-chevron-right" size="small"></anglify-icon> | ||
</ng-template> | ||
</anglify-breadcrumbs> |
Empty file.
32 changes: 32 additions & 0 deletions
32
apps/docs/src/app/examples/breadcrumbs/icon/icon.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { ChangeDetectionStrategy, Component } from '@angular/core'; | ||
import { BreadCrumb } from 'libs/anglify/src/modules/breadcrumbs/breadcrumbs.interface'; | ||
|
||
@Component({ | ||
templateUrl: './icon.component.html', | ||
styleUrls: ['./icon.component.scss'], | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class IconComponent { | ||
public items: BreadCrumb[] = [ | ||
{ | ||
text: 'Home', | ||
disabled: false, | ||
href: '#', | ||
routerLink: ['/components/breadcrumbs'], | ||
}, | ||
{ | ||
text: 'About', | ||
disabled: false, | ||
href: '#', | ||
routerLink: ['/getting-started/installation'], | ||
}, | ||
{ | ||
text: 'Contact', | ||
disabled: true, | ||
href: '#', | ||
routerLink: ['/components/card'], | ||
}, | ||
]; | ||
} | ||
|
||
export default IconComponent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
apps/docs/src/app/pages/components/breadcrumbs-page/breadcrumbs-page.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<h1>Breadcrumbs</h1> | ||
<app-references | ||
issues="https://github.com/valentingavran/anglify/labels/component%3A%20Breadcrumbs" | ||
bundleSize="https://bundlephobia.com/package/@anglify/components@latest" | ||
w3c="https://www.w3.org/WAI/ARIA/apg/patterns/breadcrumb/" | ||
></app-references> | ||
<p> | ||
Breadcrumbs consist of a list of links that help a user visualize a page's location within the hierarchical structure of a website, and | ||
allow navigation up to any of its "ancestors". | ||
</p> | ||
|
||
<h2>Examples</h2> | ||
|
||
<h3>Basic</h3> | ||
<app-code-example component="breadcrumbs" example="basic"></app-code-example> | ||
|
||
<h3>With Icon</h3> | ||
<app-code-example component="breadcrumbs" example="icon"></app-code-example> | ||
|
||
<h2>API</h2> | ||
<h3>Styling</h3> | ||
<app-styling-table forComponent="breadcrumbs"></app-styling-table> |
Empty file.
9 changes: 9 additions & 0 deletions
9
apps/docs/src/app/pages/components/breadcrumbs-page/breadcrumbs-page.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { ChangeDetectionStrategy, Component } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'anglify-breadcrumbs-page', | ||
templateUrl: './breadcrumbs-page.component.html', | ||
styleUrls: ['./breadcrumbs-page.component.scss'], | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class BreadcrumbsPageComponent {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
$breadcrumbs-active-color: var(--anglify-breadcrumbs-active-color, var(--color-primary)) !default; | ||
$breadcrumbs-inactive-color: var(--anglify-breadcrumbs-inactive-color, var(--color-on-surface-medium-emphasis)) !default; | ||
$breadcrumbs-text-font: var(--anglify-breadcrumbs-text-font, var(--font-body-2)) !default; | ||
$breadcrumbs-text-letter-spacing: var(--anglify-breadcrumbs-text-letter-spacing, var(--font-letter-spacing-body-2)) !default; | ||
$breadcrumbs-text-transform: var(--anglify-breadcrumbs-text-transform, var(--font-text-transform-body-2)) !default; | ||
$breadcrumbs-divider-font: var(--anglify-breadcrumbs-divider-font, var(--font-body-2)) !default; | ||
$breadcrumbs-divider-letter-spacing: var(--anglify-breadcrumbs-divider-letter-spacing, var(--font-letter-spacing-body-2)) !default; | ||
$breadcrumbs-divider-transform: var(--anglify-breadcrumbs-divider-transform, var(--font-text-transform-body-2)) !default; | ||
$breadcrumbs-divider-padding: var(--anglify-breadcrumbs-divider-padding, 0 12px) !default; | ||
$breadcrumbs-disabled-color: var(--anglify-breadcrumbs-disabled-color, var(--color-on-surface-low-emphasis)) !default; |
9 changes: 9 additions & 0 deletions
9
libs/anglify/src/modules/breadcrumbs/breadcrumbs-settings.token.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { InjectionToken } from '@angular/core'; | ||
import { BreadCrumbsSettings, EntireBreadCrumbsSettings } from './breadcrumbs.interface'; | ||
|
||
export const DEFAULT_BREADCRUMBS_SETTINGS: EntireBreadCrumbsSettings = { | ||
items: [], | ||
divider: '/', | ||
matchOptions: { matrixParams: 'exact', queryParams: 'exact', paths: 'exact', fragment: 'exact' }, | ||
}; | ||
export const BREADCRUMBS_SETTINGS = new InjectionToken<BreadCrumbsSettings>('Breadcrumbs Settings'); |
15 changes: 15 additions & 0 deletions
15
libs/anglify/src/modules/breadcrumbs/breadcrumbs.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<ng-container *ngFor="let item of items"> | ||
<a | ||
*ngIf="!item.disabled" | ||
[routerLink]="item.routerLink" | ||
routerLinkActive="active" | ||
[routerLinkActiveOptions]="matchOptions" | ||
[href]="item.href" | ||
> | ||
{{ item.text }} | ||
</a> | ||
<a *ngIf="item.disabled" class="disabled" routerLinkActive="active" [routerLinkActiveOptions]="matchOptions">{{ item.text }}</a> | ||
<div *ngIf="isLastItem(item) === false" class="divider"> | ||
<ng-container *anglifySlotOutlet="slots | findSlot: 'divider'">{{ divider }}</ng-container> | ||
</div> | ||
</ng-container> |
33 changes: 33 additions & 0 deletions
33
libs/anglify/src/modules/breadcrumbs/breadcrumbs.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
@use 'variables' as *; | ||
|
||
:host { | ||
display: flex; | ||
align-items: center; | ||
user-select: none; | ||
|
||
a { | ||
color: $breadcrumbs-inactive-color; | ||
font: $breadcrumbs-text-font; | ||
letter-spacing: $breadcrumbs-text-letter-spacing; | ||
text-decoration: none; | ||
text-transform: $breadcrumbs-text-transform; | ||
} | ||
|
||
.active { | ||
color: $breadcrumbs-active-color; | ||
} | ||
|
||
.divider { | ||
padding: $breadcrumbs-divider-padding; | ||
color: $breadcrumbs-inactive-color; | ||
font: $breadcrumbs-divider-font; | ||
letter-spacing: $breadcrumbs-divider-letter-spacing; | ||
text-decoration: none; | ||
text-transform: $breadcrumbs-divider-transform; | ||
} | ||
|
||
.disabled { | ||
color: $breadcrumbs-disabled-color; | ||
cursor: not-allowed; | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
libs/anglify/src/modules/breadcrumbs/breadcrumbs.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { BreadcrumbsComponent } from './breadcrumbs.component'; | ||
|
||
describe('BreadcrumbsComponent', () => { | ||
let component: BreadcrumbsComponent; | ||
let fixture: ComponentFixture<BreadcrumbsComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [BreadcrumbsComponent], | ||
}).compileComponents(); | ||
}); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(BreadcrumbsComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
29 changes: 29 additions & 0 deletions
29
libs/anglify/src/modules/breadcrumbs/breadcrumbs.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { ChangeDetectionStrategy, Component, ContentChildren, Inject, Input, QueryList, Self } from '@angular/core'; | ||
import { IsActiveMatchOptions } from '@angular/router'; | ||
import { BREADCRUMBS_SETTINGS, DEFAULT_BREADCRUMBS_SETTINGS } from './breadcrumbs-settings.token'; | ||
import { BreadCrumb, EntireBreadCrumbsSettings } from './breadcrumbs.interface'; | ||
import { createSettingsProvider } from '../../factories/settings.factory'; | ||
import { SlotDirective } from '../common/directives/slot/slot.directive'; | ||
|
||
@Component({ | ||
selector: 'anglify-breadcrumbs', | ||
templateUrl: './breadcrumbs.component.html', | ||
styleUrls: ['./breadcrumbs.component.scss'], | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
providers: [ | ||
createSettingsProvider<EntireBreadCrumbsSettings>('anglifyBreadcrumbsSettings', DEFAULT_BREADCRUMBS_SETTINGS, BREADCRUMBS_SETTINGS), | ||
], | ||
}) | ||
export class BreadcrumbsComponent { | ||
@ContentChildren(SlotDirective) public readonly slots?: QueryList<SlotDirective>; | ||
|
||
@Input() public items: BreadCrumb[] = this.settings.items; | ||
@Input() public divider: string = this.settings.divider; | ||
@Input() public matchOptions: IsActiveMatchOptions = this.settings.matchOptions; | ||
|
||
public constructor(@Self() @Inject('anglifyBreadcrumbsSettings') public settings: EntireBreadCrumbsSettings) {} | ||
|
||
public isLastItem(item: BreadCrumb) { | ||
return item === this.items[this.items.length - 1]; | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
libs/anglify/src/modules/breadcrumbs/breadcrumbs.interface.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { IsActiveMatchOptions } from '@angular/router'; | ||
import { RouterLinkCommands } from '../../utils/interfaces'; | ||
|
||
export interface EntireBreadCrumbsSettings { | ||
items: BreadCrumb[]; | ||
divider: string; | ||
matchOptions: IsActiveMatchOptions; | ||
} | ||
export interface BreadCrumb { | ||
text: string; | ||
disabled: boolean; | ||
href: string; | ||
routerLink: RouterLinkCommands; | ||
} | ||
export type BreadCrumbsSettings = Partial<EntireBreadCrumbsSettings>; |
12 changes: 12 additions & 0 deletions
12
libs/anglify/src/modules/breadcrumbs/breadcrumbs.module.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { CommonModule } from '@angular/common'; | ||
import { NgModule } from '@angular/core'; | ||
import { RouterModule } from '@angular/router'; | ||
import { BreadcrumbsComponent } from './breadcrumbs.component'; | ||
import { AnglifyCommonModule } from '../common/anglify-common.module'; | ||
|
||
@NgModule({ | ||
declarations: [BreadcrumbsComponent], | ||
imports: [CommonModule, AnglifyCommonModule, RouterModule], | ||
exports: [BreadcrumbsComponent, AnglifyCommonModule, RouterModule], | ||
}) | ||
export class BreadcrumbsModule {} |