Skip to content

Commit

Permalink
feat(addon-doc): add ability to disable default search-bar (#9099)
Browse files Browse the repository at this point in the history
  • Loading branch information
vladimirpotekhin authored Sep 19, 2024
1 parent 83300f1 commit 90cc083
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions projects/addon-doc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ npm i @taiga-ui/addon-doc

`TUI_DOC_SEE_ALSO` — a two dimensional array of related pages by their titles

`TUI_DOC_SEARCH_ENABLED` — enable doc search. Default value is true

4. Configure routing:

```typescript
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {Router, RouterLink, RouterLinkActive, Scroll} from '@angular/router';
import {
TUI_DOC_ICONS,
TUI_DOC_PAGE_LOADED,
TUI_DOC_SEARCH_ENABLED,
TUI_DOC_SEARCH_TEXT,
} from '@taiga-ui/addon-doc/tokens';
import type {TuiDocRoutePage, TuiDocRoutePages} from '@taiga-ui/addon-doc/types';
Expand Down Expand Up @@ -91,6 +92,7 @@ export class TuiDocNavigation {
protected readonly labels = inject(NAVIGATION_LABELS);
protected readonly items = inject(NAVIGATION_ITEMS);
protected readonly searchText = inject(TUI_DOC_SEARCH_TEXT);
protected readonly searchEnabled = inject(TUI_DOC_SEARCH_ENABLED);
protected readonly docIcons = inject(TUI_DOC_ICONS);
protected readonly icons = inject(TUI_COMMON_ICONS);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
}
}

.t-accordion-standalone {
margin-top: 1rem;
}

.t-scrollbar {
scroll-behavior: var(--tui-scroll-behavior);
inline-size: 100%;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<tui-textfield
*ngIf="searchEnabled"
tuiTextfieldSize="m"
class="t-input"
[iconStart]="docIcons.search"
Expand Down Expand Up @@ -66,6 +67,7 @@
<nav class="t-navigation">
<tui-scrollbar class="t-scrollbar">
<tui-accordion
[class.t-accordion-standalone]="!searchEnabled"
[closeOthers]="false"
[rounded]="false"
>
Expand Down
1 change: 1 addition & 0 deletions projects/addon-doc/tokens/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,4 @@ export const TUI_DOC_MENU_TEXT = tuiCreateToken('Menu');
export const TUI_DOC_SEARCH_TEXT = tuiCreateToken('Search');
export const TUI_DOC_SEE_ALSO_TEXT = tuiCreateToken('See also');
export const TUI_DOC_SOURCE_CODE_TEXT = tuiCreateToken('Source code');
export const TUI_DOC_SEARCH_ENABLED = tuiCreateToken(true);
5 changes: 5 additions & 0 deletions projects/demo/src/modules/app/app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
TUI_DOC_EXAMPLE_CONTENT_PROCESSOR,
TUI_DOC_LOGO,
TUI_DOC_PAGES,
TUI_DOC_SEARCH_ENABLED,
TUI_DOC_SEE_ALSO,
TUI_DOC_SOURCE_CODE,
TUI_DOC_TITLE,
Expand Down Expand Up @@ -135,6 +136,10 @@ export const config: ApplicationConfig = {
provide: TUI_DOC_LOGO,
useValue: LOGO_CONTENT,
},
{
provide: TUI_DOC_SEARCH_ENABLED,
useValue: false,
},
{
provide: TUI_DOC_CODE_EDITOR,
useClass: TuiStackblitzService,
Expand Down

0 comments on commit 90cc083

Please sign in to comment.