-
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(dgeni,daffio): render package API doc exports (#2991)
Co-authored-by: xelaint <xelaint@gmail.com>
- Loading branch information
Showing
25 changed files
with
339 additions
and
113 deletions.
There are no files selected for viewing
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
20 changes: 20 additions & 0 deletions
20
apps/daffio/src/app/docs/api/components/api-list-section/api-list-section-theme.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,20 @@ | ||
@use 'theme' as daff-theme; | ||
|
||
@mixin daffio-api-list-section-theme($theme) { | ||
$neutral: daff-theme.daff-map-deep-get($theme, 'core.neutral'); | ||
$base: daff-theme.daff-map-deep-get($theme, "core.base"); | ||
$base-contrast: daff-theme.daff-map-deep-get($theme, "core.base-contrast"); | ||
|
||
.daffio-api-list-section { | ||
&__item { | ||
&:focus { | ||
box-shadow: 0 0 0 4px rgba($base-contrast, 0.1); | ||
outline: none; | ||
} | ||
|
||
&:after { | ||
background: daff-theme.daff-illuminate($base, $neutral, 2); | ||
} | ||
} | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
apps/daffio/src/app/docs/api/components/api-list-section/api-list-section.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,6 @@ | ||
@for (childDoc of children; track childDoc.id) { | ||
<a [routerLink]="childDoc.path" class="daffio-api-list-section__item" > | ||
<div class="daffio-api-list-section__item-name">{{ childDoc.title }}</div> | ||
<label class="daffio-api-list-section__item-label {{ childDoc.docType }}">{{ childDoc.docType }}</label> | ||
</a> | ||
} |
70 changes: 70 additions & 0 deletions
70
apps/daffio/src/app/docs/api/components/api-list-section/api-list-section.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,70 @@ | ||
@use '../../../../../scss/type-descriptors/mixins' as type-mixin; | ||
@use 'utilities' as daff; | ||
|
||
$api-list-section-item-border-radius: 4px; | ||
|
||
:host { | ||
display: grid; | ||
grid-template-columns: 1fr; | ||
grid-gap: 8px 24px; | ||
|
||
@include daff.breakpoint(tablet) { | ||
grid-template-columns: repeat(2, 1fr); | ||
} | ||
|
||
@include daff.breakpoint(small-laptop) { | ||
grid-template-columns: repeat(3, 1fr); | ||
} | ||
|
||
a { | ||
text-decoration: none; | ||
} | ||
} | ||
|
||
.daffio-api-list-section { | ||
&__item { | ||
display: flex; | ||
align-items: center; | ||
border-radius: $api-list-section-item-border-radius; | ||
font-weight: normal; | ||
justify-content: space-between; | ||
overflow: hidden; | ||
padding: 8px; | ||
position: relative; | ||
|
||
&::after { | ||
content: ''; | ||
border-radius: $api-list-section-item-border-radius; | ||
position: absolute; | ||
left: 0; | ||
top: 0; | ||
height: 100%; | ||
width: 100%; | ||
opacity: 0; | ||
transition: opacity 300ms; | ||
z-index: 1; | ||
} | ||
|
||
&:hover { | ||
&::after { | ||
opacity: 1; | ||
} | ||
} | ||
} | ||
|
||
&__item-name { | ||
@include daff.text-truncate(); | ||
} | ||
|
||
&__item-label { | ||
@include type-mixin.type-label(); | ||
height: 1.5rem; | ||
padding: 4px; | ||
margin-left: 16px; | ||
} | ||
|
||
&__item-name, | ||
&__item-label { | ||
z-index: 2; | ||
} | ||
} |
85 changes: 85 additions & 0 deletions
85
apps/daffio/src/app/docs/api/components/api-list-section/api-list-section.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,85 @@ | ||
import { Component } from '@angular/core'; | ||
import { | ||
ComponentFixture, | ||
TestBed, | ||
waitForAsync, | ||
} from '@angular/core/testing'; | ||
import { By } from '@angular/platform-browser'; | ||
import { RouterTestingModule } from '@angular/router/testing'; | ||
|
||
import { DaffioApiListSectionComponent } from './api-list-section.component'; | ||
import { DaffioApiReference } from '../../models/api-reference'; | ||
|
||
@Component({ | ||
template: ` | ||
<daffio-api-list-section [children]="apiListValue"></daffio-api-list-section> | ||
`, | ||
standalone: true, | ||
imports: [ | ||
DaffioApiListSectionComponent, | ||
], | ||
}) | ||
class WrapperComponent { | ||
apiListValue: Array<DaffioApiReference> = [ | ||
{ | ||
id: 'name1Component', | ||
title: 'title1Component', | ||
path: 'path1', | ||
docType: 'docType1', | ||
docTypeShorthand: 'dt', | ||
children: [], | ||
}, | ||
{ | ||
id: 'name2Module', | ||
title: 'title2Module', | ||
path: 'path2', | ||
docType: 'docType2', | ||
docTypeShorthand: 'dt', | ||
children: [], | ||
}, | ||
]; | ||
} | ||
|
||
describe('DaffioApiListSectionComponent', () => { | ||
let wrapper: WrapperComponent; | ||
let fixture: ComponentFixture<WrapperComponent>; | ||
let component: DaffioApiListSectionComponent; | ||
let links; | ||
|
||
beforeEach(waitForAsync(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [ | ||
WrapperComponent, | ||
RouterTestingModule, | ||
], | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(WrapperComponent); | ||
wrapper = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
|
||
component = fixture.debugElement.query(By.css('daffio-api-list-section')).componentInstance; | ||
links = fixture.debugElement.queryAll(By.css('a')); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
|
||
it('should be able to take children as input', () => { | ||
expect(component.children).toEqual(wrapper.apiListValue); | ||
}); | ||
|
||
it('should render a link for every doc in children', () => { | ||
expect(links.length).toEqual(component.children.length); | ||
}); | ||
|
||
describe('on link', () => { | ||
it('should set routerLink', () => { | ||
expect(links[0].attributes['ng-reflect-router-link']).toEqual(component.children[0].path); | ||
}); | ||
}); | ||
}); |
28 changes: 28 additions & 0 deletions
28
apps/daffio/src/app/docs/api/components/api-list-section/api-list-section.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,28 @@ | ||
import { | ||
Component, | ||
Input, | ||
ChangeDetectionStrategy, | ||
HostBinding, | ||
} from '@angular/core'; | ||
import { RouterLink } from '@angular/router'; | ||
|
||
import { DaffioApiReference } from '../../models/api-reference'; | ||
|
||
@Component({ | ||
selector: 'daffio-api-list-section', | ||
templateUrl: './api-list-section.component.html', | ||
styleUrls: ['./api-list-section.component.scss'], | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
standalone: true, | ||
imports: [ | ||
RouterLink, | ||
], | ||
}) | ||
export class DaffioApiListSectionComponent { | ||
@HostBinding('class.daffio-api-list-section') class = true; | ||
|
||
/** | ||
* A list of references for API documents. | ||
*/ | ||
@Input() children: Array<DaffioApiReference>; | ||
} |
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
Oops, something went wrong.