-
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wip: implement id anchor for API tab
- Loading branch information
Showing
6 changed files
with
142 additions
and
1 deletion.
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
30 changes: 30 additions & 0 deletions
30
.../daffio/src/app/docs/design/components/component-content/component-content.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,30 @@ | ||
<daffio-doc-article [breadcrumbs]="doc().breadcrumbs" [toc]="toc()"> | ||
<daff-tabs | ||
[initiallySelected]="USAGE_TAB_ID" | ||
[linkMode]="true" | ||
[url]="doc().id" | ||
(tabChange)="setTab($event)" | ||
> | ||
<daff-tab [id]="USAGE_TAB_ID"> | ||
<daff-tab-label> | ||
Usage | ||
</daff-tab-label> | ||
<daff-tab-panel> | ||
<daff-article | ||
[innerHtml]="doc().contents | safe"> | ||
</daff-article> | ||
</daff-tab-panel> | ||
</daff-tab> | ||
|
||
<daff-tab [id]="API_TAB_ID"> | ||
<daff-tab-label> | ||
API | ||
</daff-tab-label> | ||
<daff-tab-panel> | ||
@for (apiDoc of doc().api; track $index) { | ||
<div [innerHtml]="apiDoc | safe"></div> | ||
} | ||
</daff-tab-panel> | ||
</daff-tab> | ||
</daff-tabs> | ||
</daffio-doc-article> |
39 changes: 39 additions & 0 deletions
39
...ffio/src/app/docs/design/components/component-content/component-content.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,39 @@ | ||
import { | ||
provideHttpClient, | ||
withInterceptorsFromDi, | ||
} from '@angular/common/http'; | ||
import { provideHttpClientTesting } from '@angular/common/http/testing'; | ||
import { | ||
waitForAsync, | ||
ComponentFixture, | ||
TestBed, | ||
} from '@angular/core/testing'; | ||
import { NoopAnimationsModule } from '@angular/platform-browser/animations'; | ||
import { RouterTestingModule } from '@angular/router/testing'; | ||
|
||
import { DaffioDocsDesignComponentPageComponent } from './docs-list.component'; | ||
|
||
describe('DaffioDocsDesignComponentPageComponent', () => { | ||
let component: DaffioDocsDesignComponentPageComponent; | ||
let fixture: ComponentFixture<DaffioDocsDesignComponentPageComponent>; | ||
|
||
beforeEach(waitForAsync(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [DaffioDocsDesignComponentPageComponent, | ||
RouterTestingModule, | ||
NoopAnimationsModule], | ||
providers: [provideHttpClient(withInterceptorsFromDi()), provideHttpClientTesting()], | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(DaffioDocsDesignComponentPageComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
64 changes: 64 additions & 0 deletions
64
apps/daffio/src/app/docs/design/components/component-content/component-content.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,64 @@ | ||
import { | ||
ChangeDetectionStrategy, | ||
Component, | ||
computed, | ||
effect, | ||
input, | ||
signal, | ||
viewChild, | ||
} from '@angular/core'; | ||
import { toSignal } from '@angular/core/rxjs-interop'; | ||
import { ActivatedRoute } from '@angular/router'; | ||
|
||
import { DAFF_ARTICLE_COMPONENTS } from '@daffodil/design/article'; | ||
import { | ||
DAFF_TABS_COMPONENTS, | ||
DaffTabsComponent, | ||
} from '@daffodil/design/tabs'; | ||
import { | ||
DaffDocKind, | ||
DaffPackageGuideDoc, | ||
} from '@daffodil/docs-utils'; | ||
|
||
import { DaffioSafeHtmlPipe } from '../../../../core/html-sanitizer/safe.pipe'; | ||
import { DaffioDocArticleModule } from '../../../components/doc-article/module'; | ||
import { DaffioDocsDynamicContent } from '../../../dynamic-content/dynamic-content.type'; | ||
|
||
|
||
@Component({ | ||
selector: 'daffio-docs-design-component-content', | ||
templateUrl: './component-content.component.html', | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
standalone: true, | ||
imports: [ | ||
DAFF_TABS_COMPONENTS, | ||
DAFF_ARTICLE_COMPONENTS, | ||
DaffioDocArticleModule, | ||
DaffioSafeHtmlPipe, | ||
], | ||
}) | ||
export class DaffioDocsDesignComponentContentComponent implements DaffioDocsDynamicContent<DaffPackageGuideDoc> { | ||
static readonly kind = DaffDocKind.COMPONENT; | ||
|
||
private readonly _tab = signal<string>(''); | ||
|
||
readonly USAGE_TAB_ID = 'usage'; | ||
readonly API_TAB_ID = 'api'; | ||
|
||
tabs = viewChild.required(DaffTabsComponent); | ||
doc = input<DaffPackageGuideDoc>(); | ||
toc = computed(() => { | ||
switch (this._tab()) { | ||
case this.API_TAB_ID: | ||
return this.doc().apiToc; | ||
|
||
default: | ||
case this.USAGE_TAB_ID: | ||
return this.doc().tableOfContents; | ||
} | ||
}); | ||
|
||
setTab(tab: string) { | ||
this._tab.set(tab); | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
apps/daffio/src/app/docs/design/components/component-content/component-content.provider.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,4 @@ | ||
import { DaffioDocsDesignComponentContentComponent } from './component-content.component'; | ||
import { provideDaffioDocsDynamicContentComponents } from '../../../dynamic-content/dynamic-content-components.token'; | ||
|
||
export const provideDaffioDocsDesignComponentContentComponent = () => provideDaffioDocsDynamicContentComponents(DaffioDocsDesignComponentContentComponent); |
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 |
---|---|---|
@@ -1,14 +1,18 @@ | ||
import { NgModule } from '@angular/core'; | ||
|
||
import { provideDaffioDocsDesignComponentContentComponent } from './components/component-content/component-content.provider'; | ||
import { DaffioDocsDesignRoutingModule } from './design-routing.module'; | ||
import { DaffioDocsDesignIndexService } from './services/index.service'; | ||
import { provideDaffioDocsPackagesContentComponent } from '../packages/components/packages-content/packages-content.provider'; | ||
|
||
@NgModule({ | ||
imports: [ | ||
DaffioDocsDesignRoutingModule, | ||
], | ||
providers: [ | ||
DaffioDocsDesignIndexService, | ||
provideDaffioDocsDesignComponentContentComponent(), | ||
provideDaffioDocsPackagesContentComponent(), | ||
], | ||
}) | ||
export class DaffioDocsDesignModule {} |