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(addon-doc): add TUI_DOC_SUPPORT_LANGUAGE token #9201

Merged
merged 1 commit into from
Sep 26, 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
@@ -1,11 +1,10 @@
<tui-badged-content>
<img
*ngIf="flags.get(language.value ?? '') | tuiFlag as flag"
alt=""
size="s"
tuiBadge
tuiSlot="bottom"
[src]="flag"
[src]="flags.get(language.value ?? '') || flags.get(switcher.language) | tuiFlag"
/>

<button
Expand Down
3 changes: 2 additions & 1 deletion projects/addon-doc/components/page/page.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
Input,
} from '@angular/core';
import {RouterLink, RouterLinkActive} from '@angular/router';
import {TUI_DOC_DEFAULT_TABS} from '@taiga-ui/addon-doc/tokens';
import {TUI_DOC_DEFAULT_TABS, TUI_DOC_SUPPORT_LANGUAGE} from '@taiga-ui/addon-doc/tokens';
import {EMPTY_QUERY} from '@taiga-ui/cdk/constants';
import {TuiReplacePipe} from '@taiga-ui/cdk/pipes/replace';
import {TuiAutoColorPipe} from '@taiga-ui/core/pipes/auto-color';
Expand Down Expand Up @@ -44,6 +44,7 @@ import {TuiDocPageTabConnector} from './page-tab.directive';
providers: PAGE_PROVIDERS,
})
export class TuiDocPage {
protected readonly supportLanguage = inject(TUI_DOC_SUPPORT_LANGUAGE);
protected readonly defaultTabs = inject(TUI_DOC_DEFAULT_TABS);
protected readonly from = / /g;
protected readonly to = '_';
Expand Down
2 changes: 1 addition & 1 deletion projects/addon-doc/components/page/page.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ <h1 class="t-title">
[type]="type"
/>

<tui-doc-language-switcher />
<tui-doc-language-switcher *ngIf="supportLanguage.has(header)" />
</div>
</header>
<div class="t-content">
Expand Down
1 change: 1 addition & 0 deletions projects/addon-doc/tokens/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export * from './page-loaded';
export * from './pages';
export * from './see-also';
export * from './source-code';
export * from './support-language';
export * from './title';
export * from './type-reference-handler';
export * from './url-state-handler';
3 changes: 3 additions & 0 deletions projects/addon-doc/tokens/support-language.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import {tuiCreateToken} from '@taiga-ui/cdk/utils/miscellaneous';

export const TUI_DOC_SUPPORT_LANGUAGE = tuiCreateToken<Set<string>>(new Set());
17 changes: 17 additions & 0 deletions projects/demo/src/modules/app/app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
TUI_DOC_SEARCH_ENABLED,
TUI_DOC_SEE_ALSO,
TUI_DOC_SOURCE_CODE,
TUI_DOC_SUPPORT_LANGUAGE,
TUI_DOC_TITLE,
TUI_DOC_TYPE_REFERENCE_HANDLER,
TUI_DOC_URL_STATE_HANDLER,
Expand Down Expand Up @@ -44,6 +45,18 @@ import {pages} from './pages';
import {TuiStackblitzService} from './stackblitz/stackblitz.service';
import {exampleContentProcessor} from './utils';

export const TUI_DEFAULT_LANGUAGE_PAGE = new Set([
'Calendar',
'CalendarMonth',
'CalendarRange',
'InputCardGroup',
'InputFiles',
'InputPhoneInternational',
'MobileCalendar',
'Table',
'TablePagination',
]);

export const config: ApplicationConfig = {
providers: [
provideAnimations(),
Expand Down Expand Up @@ -162,6 +175,10 @@ export const config: ApplicationConfig = {
? {...TUI_DROPDOWN_HOVER_DEFAULT_OPTIONS, showDelay: 0, hideDelay: 0}
: TUI_DROPDOWN_HOVER_DEFAULT_OPTIONS,
},
{
provide: TUI_DOC_SUPPORT_LANGUAGE,
useValue: TUI_DEFAULT_LANGUAGE_PAGE,
},
{
provide: TUI_DOC_URL_STATE_HANDLER,
useFactory: () => (tree: UrlTree) =>
Expand Down
Loading