Skip to content

Commit 835c70c

Browse files
authored
feat(top-bar): updated docs examples (#DS-3487) (#600)
1 parent 1658514 commit 835c70c

File tree

27 files changed

+1271
-630
lines changed

27 files changed

+1271
-630
lines changed

apps/docs/src/app/components/live-example-viewer/docs-live-example-viewer.scss

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
border-radius: inherit;
77
border-bottom-left-radius: 0;
88
border-bottom-right-radius: 0;
9+
background: var(--docs-live-example-example-background);
910
}
1011

1112
.docs-live-example-viewer {

apps/docs/src/app/services/documentation-items.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -696,8 +696,8 @@ const DOCS: { [key: string]: DocCategory[] } = {
696696
{
697697
id: 'top-bar',
698698
name: {
699-
ru: 'Top Bar',
700-
en: 'Top Bar'
699+
ru: 'Topbar',
700+
en: 'Topbar'
701701
},
702702
svgPreview: 'top-bar',
703703
hasApi: true,

apps/docs/src/assets/example-icon.svg

+12
Loading
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import { provideHttpClient } from '@angular/common/http';
22
import { bootstrapApplication } from '@angular/platform-browser';
33
import { provideAnimations } from '@angular/platform-browser/animations';
4+
import { provideRouter } from '@angular/router';
45
import { KBQ_LOCALE_SERVICE, KbqLocaleService } from '@koobiq/components/core';
56
import { KoobiqDocsExample } from './example/koobiq-docs-example';
67

78
bootstrapApplication(KoobiqDocsExample, {
89
providers: [
910
provideAnimations(),
1011
provideHttpClient(),
12+
provideRouter([]),
1113
{ provide: KBQ_LOCALE_SERVICE, useClass: KbqLocaleService }]
1214
}).catch((err) => console.error(err));

apps/docs/src/styles/_examples.scss

+11-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1-
.docs-live-example__example_breadcrumbs-with-auto-wrap-adaptive {
2-
background: var(--kbq-background-bg-secondary);
1+
.docs-live-example__example {
2+
&.docs-live-example__example_top-bar-overflow,
3+
&.docs-live-example__example_top-bar-breadcrumbs-adaptive,
4+
&.docs-live-example__example_top-bar-title-counter-adaptive,
5+
&.docs-live-example__example_breadcrumbs-with-auto-wrap-adaptive {
6+
--docs-live-example-example-background: var(--kbq-background-bg-secondary);
7+
}
8+
9+
&.docs-live-example__example_top-bar-overflow {
10+
padding: var(--kbq-size-3xl);
11+
}
312
}

packages/components-dev/main.scss

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
@use '../components/core/styles/visual/layout';
66

7+
@use '../components/core/styles/common/list';
8+
79
@use '../../apps/docs/src/styles/koobiq/default-theme/css-tokens.css';
810
@use '../../apps/docs/src/styles/koobiq/default-theme/css-tokens-light.css';
911
@use '../../apps/docs/src/styles/koobiq/default-theme/css-tokens-dark.css';

packages/components-dev/top-bar/module.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { ChangeDetectionStrategy, Component, ViewEncapsulation } from '@angular/core';
2+
import { KbqLocaleServiceModule } from '@koobiq/components/core';
23
import { TopBarExamplesModule } from '../../docs-examples/components/top-bar';
4+
import { DevLocaleSelector } from '../locale-selector';
35

46
@Component({
57
standalone: true,
@@ -8,7 +10,9 @@ import { TopBarExamplesModule } from '../../docs-examples/components/top-bar';
810
encapsulation: ViewEncapsulation.None,
911
templateUrl: './template.html',
1012
imports: [
11-
TopBarExamplesModule
13+
TopBarExamplesModule,
14+
DevLocaleSelector,
15+
KbqLocaleServiceModule
1216
],
1317
changeDetection: ChangeDetectionStrategy.OnPush
1418
})
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<div class="app-shell-dev">
22
<aside class="app-sidebar-dev">app-sidebar</aside>
3-
<top-bar-active-breadcrumb-example class="app-container-dev layout-column flex" />
3+
<dev-locale-selector />
4+
<top-bar-breadcrumbs-example class="app-container-dev layout-column flex" />
45
</div>
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
.kbq-top-bar {
1+
:where(.kbq-top-bar) {
22
--kbq-top-bar-position: sticky;
33
--kbq-top-bar-background: var(--kbq-background-bg);
44
--kbq-top-bar-spacer-min-width: 80px;
55
--kbq-top-bar-padding-vertical: var(--kbq-size-xl);
66
--kbq-top-bar-padding-horizontal: var(--kbq-size-xxl);
77
--kbq-top-bar-border-radius: 0;
8-
--kbq-top-bar-left-gap: 0;
9-
--kbq-top-bar-right-gap: var(--kbq-size-s);
8+
--kbq-top-bar-container-start-gap: 0;
9+
--kbq-top-bar-container-start-basis: 0;
10+
--kbq-top-bar-container-end-gap: var(--kbq-size-s);
1011
--kbq-top-bar-shadow-bottom: var(--kbq-shadow-overflow-normal-bottom);
1112
--kbq-top-bar-shadow-transition: ease-out 300ms;
1213
}
+37-23
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,60 @@
1-
The `Top Bar` is a toolbar that remains visible on the page at all times, providing quick access to navigation and
2-
controls. Depending on the interface requirements, it can include breadcrumbs, a title, action buttons, and other
3-
elements. Below are various ways to use the toolbar and recommendations for adapting it to different scenarios.
1+
Topbar is a toolbar that always remains visible on the page and provides quick access to navigation and controls.
2+
3+
<!-- example(top-bar-overview) -->
4+
5+
Depending on the interface requirements, it may include a logo, a title, breadcrumbs, action buttons, and other elements.
6+
7+
### Page title
8+
9+
This content option is suitable for initial screens when there is no need to display the navigation path.
10+
11+
<!-- example(top-bar-overview) -->
12+
13+
If you need to display the number of objects on the current page, you can do so by showing a special counter next to the page title:
14+
15+
<!-- example(top-bar-title-counter) -->
416

517
### Breadcrumbs
618

7-
Use breadcrumbs to display the navigation path. This panel is always visible and helps users navigate the application.
19+
For internal pages of a specific module, using [Breadcrumbs](/en/components/breadcrumbs) is an excellent option. This helps users navigate the application more easily.
820

921
<!-- example(top-bar-breadcrumbs) -->
1022

11-
### Replacing Breadcrumbs with a Title
23+
### Action buttons
1224

13-
For a more compact layout, replace breadcrumbs with a title that reflects the current section.
25+
On the right side of the toolbar, there is a dedicated area for placing any actions that need to be displayed on the current page.
1426

15-
<!-- example(top-bar-overview) -->
27+
We recommend using the following set of actions (from left to right):
28+
29+
- Indicators (e.g., data refresh indicator)
30+
- A group of icon buttons (e.g., filters)
31+
- Frequently used actions as buttons (e.g., "Add...", "Share")
32+
- Additional actions in a dropdown menu, where all secondary actions related to the current page can be placed.
1633

17-
### Active Breadcrumb Display
34+
<!-- example(top-bar-actions) -->
1835

19-
The last breadcrumb in the navigation is always active and can be used for various actions.
36+
### Responsive mode
2037

21-
<!-- example(top-bar-active-breadcrumb) -->
38+
Internal elements can adjust to the toolbar size.
2239

23-
### Additional Actions
40+
The minimum allowed spacing between the left side and the right side with actions is **80px** and is defined using the CSS variable `--kbq-top-bar-spacer-min-width`.
2441

25-
Additional (secondary) actions are placed in a dropdown menu for better UI convenience.
42+
#### Breadcrumbs variant
2643

27-
<!-- example(top-bar-secondary-actions) -->
44+
When the panel is compressed, the breadcrumbs will adjust as follows:
2845

29-
### Responsive Behavior
46+
<!-- example(top-bar-breadcrumbs-adaptive) -->
3047

31-
Additional actions can be moved into the dropdown menu as the screen width decreases, ensuring a seamless user experience across different devices.
48+
A more detailed explanation of breadcrumb compression is provided on the [Breadcrumbs](/en/components/breadcrumbs) page.
3249

33-
<!-- example(top-bar-secondary-actions-responsive) -->
50+
#### Page title variant
3451

35-
### Minimum Spacing Between Elements
52+
The variant using only the page title will adjust as follows:
3653

37-
<!-- cspell:ignore Dashbo -->
54+
<!-- example(top-bar-title-counter-adaptive) -->
3855

39-
To ensure usability:
56+
#### Scroll behavior
4057

41-
- Hide button text when the screen width decreases.
42-
- Show a tooltip with the button text on hover.
43-
- Maintain a minimum spacing of **80px**, set via `--kbq-top-bar-spacer-min-width`. It applies to Top Bar elements, including the header.
44-
- If a long title does not fit, truncate it with an ellipsis (**"Dashbo..."**).
58+
The toolbar can remain fixed while scrolling the page.
4559

4660
<!-- example(top-bar-overflow) -->
+38-26
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,61 @@
1-
`Top Bar` — это панель инструментов, которая всегда остается видимой на странице и обеспечивает быстрый доступ к
2-
навигации
3-
и управлению. В зависимости от требований интерфейса, она может включать хлебные крошки, заголовок, кнопки действий и
4-
другие элементы. Ниже представлены различные варианты использования toolbar и рекомендации по его адаптации под разные
5-
сценарии.
1+
Topbar — это панель инструментов, которая всегда остается видимой на странице и обеспечивает быстрый доступ к
2+
навигации и управлению.
3+
4+
<!-- example(top-bar-overview) -->
5+
6+
В зависимости от требований интерфейса, она может включать логотип, заголовок, хлебные крошки, кнопки действий и другие элементы.
7+
8+
### Заголовок страницы
9+
10+
Данный вариант наполнения подходит для начальных экранов, когда отсутствует необходимость в отображении навигационного пути.
11+
12+
<!-- example(top-bar-overview) -->
13+
14+
Если необходимо вывести количество объектов на текущей странице, то это можно сделать с помощью отображения рядом с заголовком страницы специального счетчика:
15+
16+
<!-- example(top-bar-title-counter) -->
617

718
### Хлебные крошки
819

9-
Используйте хлебные крошки для отображения пути навигации. Эта панель всегда видна и помогает пользователю
10-
ориентироваться в приложении.
20+
Для внутренних страниц отдельного модуля отлично подойдет вариант с [хлебными крошками](/ru/components/breadcrumbs). 
Это поможет пользователю легче ориентироваться в приложении.
1121

1222
<!-- example(top-bar-breadcrumbs) -->
1323

14-
### Замена хлебных крошек заголовком
24+
### Кнопки действий
1525

16-
Если требуется более компактное представление, замените хлебные крошки заголовком, отображающим текущий раздел.
26+
В правой части панели инструментов располагается область для размещения любых действий, которые необходимо отобразить на текущей странице.
1727

18-
<!-- example(top-bar-overview) -->
28+
Мы рекомендуем использовать следующий набор действий (слева направо):
29+
30+
- Индикаторы (например, индикатор обновления данных)
31+
- Группа кнопок-иконок (фильтры)
32+
- Частые действия в виде кнопок (например, «Добавить…», «Поделиться»)
33+
- Дополнительные действия в виде дропдаун меню, куда можно отнести все второстепенные действия относящиеся к текущей странице.
1934

20-
### Отображение активной крошки
35+
<!-- example(top-bar-actions) -->
2136

22-
Последняя крошка в навигации всегда активна и может использоваться для различных действий.
37+
### Адаптивный режим
2338

24-
<!-- example(top-bar-active-breadcrumb) -->
39+
Внутренние элементы могут подстраиваться под размер панели.
2540

26-
### Дополнительные действия
41+
Допустимое минимальное расстояние между левой частью и правой частью с действиями составляет **80px** и задается через CSS-переменную `--kbq-top-bar-spacer-min-width`.
2742

28-
Дополнительные (второстепенные) действия выносятся в выпадающее меню.
43+
#### Вариант с хлебными крошками
2944

30-
<!-- example(top-bar-secondary-actions) -->
45+
При сжатии панели хлебные крошки будут перестраиваться следующим образом:
3146

32-
#### Адаптивное поведение
47+
<!-- example(top-bar-breadcrumbs-adaptive) -->
3348

34-
Дополнительные действия могут скрываться в выпадающее меню при уменьшении ширины экрана, обеспечивая удобную навигацию на разных устройствах.
49+
#### Вариант с заголовком страницы
3550

36-
<!-- example(top-bar-secondary-actions-responsive) -->
51+
Вариант с использованием только заголовка будет перестраиваться следующим образом:
3752

38-
### Минимальный отступ между элементами
53+
<!-- example(top-bar-title-counter-adaptive) -->
3954

40-
<!-- cspell:ignore Дашбо -->
55+
Более подробно сжатие хлебных крошек разобрано на странице [хлебных крошек](/ru/components/breadcrumbs).
4156

42-
Чтобы обеспечить удобство взаимодействия:
57+
#### Поведение при прокрутке
4358

44-
- Скрывайте текст на кнопках при уменьшении ширины экрана.
45-
- Добавляйте тултип с текстом при наведении.
46-
- Соблюдайте минимальный отступ **80px**, задаваемый через `--kbq-top-bar-spacer-min-width`. Он применяется к элементам топ-меню, включая заголовок.
47-
- Чтобы длинный заголовок не ломал верстку, скрывайте часть текста многоточием (**"Дашбо..."**).
59+
Панель может фиксироваться при прокрутке страницы.
4860

4961
<!-- example(top-bar-overflow) -->

packages/components/top-bar/top-bar.scss

+27-3
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,41 @@
1414

1515
.kbq-top-bar-spacer {
1616
height: 100%;
17-
flex: 1 0 var(--kbq-top-bar-spacer-min-width);
17+
flex: 0 0 var(--kbq-top-bar-spacer-min-width);
1818
}
1919

2020
.kbq-top-bar-container__start {
2121
display: flex;
22-
gap: var(--kbq-top-bar-left-gap);
22+
gap: var(--kbq-top-bar-container-start-gap);
23+
flex: 1 0 var(--kbq-top-bar-container-start-basis);
24+
justify-content: flex-start;
25+
min-width: 0;
2326
}
2427

2528
.kbq-top-bar-container__end {
2629
display: flex;
27-
gap: var(--kbq-top-bar-right-gap);
30+
gap: var(--kbq-top-bar-container-end-gap);
31+
justify-content: end;
32+
}
33+
34+
.kbq-top-bar-container__with-overflow-items {
35+
gap: unset;
36+
padding: 1px;
37+
38+
> .kbq-overflow-item {
39+
&:not(:last-of-type) {
40+
margin-right: var(--kbq-top-bar-container-end-gap);
41+
}
42+
43+
// apply margin if the last item needs to be alwaysVisible
44+
&:last-of-type:is([aria-hidden='false']) + .kbq-overflow-items-result {
45+
margin-left: var(--kbq-top-bar-container-end-gap);
46+
}
47+
}
48+
49+
.kbq-overflow-items-result:first-child {
50+
margin-right: var(--kbq-top-bar-container-end-gap);
51+
}
2852
}
2953

3054
&.kbq-top-bar_with-shadow {

packages/components/top-bar/top-bar.ts

+10-1
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ import {
33
ChangeDetectionStrategy,
44
Component,
55
Directive,
6+
inject,
67
input,
78
Input,
89
ViewEncapsulation
910
} from '@angular/core';
11+
import { KbqOverflowItems } from '@koobiq/components/overflow-items';
1012

1113
@Directive({
1214
standalone: true,
@@ -26,14 +28,21 @@ export class KbqTopBarSpacer {}
2628
host: {
2729
class: 'kbq-top-bar-container',
2830
'[class.kbq-top-bar-container__start]': 'placement() === "start"',
29-
'[class.kbq-top-bar-container__end]': 'placement() === "end"'
31+
'[class.kbq-top-bar-container__end]': 'placement() === "end"',
32+
'[class.kbq-top-bar-container__with-overflow-items]': 'overflowItems'
3033
}
3134
})
3235
export class KbqTopBarContainer {
3336
/**
3437
* Conditionally applies a CSS class based on the value
3538
*/
3639
placement = input.required<'start' | 'end'>();
40+
/**
41+
* Track if container has `KbqOverflowItems` directive assigned.
42+
* Used to replace `gap` with `margin` so `KbqOverflowItems` will calculate correct width on resize.
43+
* @docs-private
44+
*/
45+
protected readonly overflowItems = inject(KbqOverflowItems, { optional: true, self: true });
3746
}
3847

3948
@Component({

0 commit comments

Comments
 (0)