Skip to content

feat(sidebar): refactored module (#DS-3649) #736

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

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
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
12 changes: 12 additions & 0 deletions apps/docs/src/app/services/documentation-items.ts
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,18 @@ const DOCS: { [key: string]: DocCategory[] } = {
apiId: 'select',
hasExamples: true
},
{
id: 'sidebar',
name: {
ru: 'Sidebar',
en: 'Sidebar'
},
svgPreview: 'sidebar',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rmnturov нужна svg иконка

hasApi: true,
apiId: 'sidebar',
hasExamples: true,
isNew: expiresAt('2025-06-16')
},
{
id: 'sidepanel',
name: {
Expand Down
12 changes: 12 additions & 0 deletions apps/docs/src/sitemap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,18 @@
<url>
<loc>https://koobiq.io/ru/components/select/api</loc>
</url>
<url>
<loc>https://koobiq.io/en/components/sidebar/overview</loc>
</url>
<url>
<loc>https://koobiq.io/ru/components/sidebar/overview</loc>
</url>
<url>
<loc>https://koobiq.io/en/components/sidebar/api</loc>
</url>
<url>
<loc>https://koobiq.io/ru/components/sidebar/api</loc>
</url>
<url>
<loc>https://koobiq.io/en/components/sidepanel/overview</loc>
</url>
Expand Down
52 changes: 18 additions & 34 deletions packages/components-dev/sidebar/module.ts
Original file line number Diff line number Diff line change
@@ -1,45 +1,29 @@
import { JsonPipe } from '@angular/common';
import { ChangeDetectionStrategy, Component, ViewEncapsulation } from '@angular/core';
import { KbqButtonModule } from '@koobiq/components/button';
import { KbqSidebarModule, SidebarPositions } from '@koobiq/components/sidebar';
import { Direction, KbqSplitterModule } from '@koobiq/components/splitter';
import { SidebarExamplesModule } from 'packages/docs-examples/components/sidebar';

@Component({
standalone: true,
imports: [SidebarExamplesModule],
selector: 'dev-examples',
template: `
<sidebar-overview-example />
<hr />
<sidebar-with-splitter-example />
<hr />
`,
changeDetection: ChangeDetectionStrategy.OnPush
})
export class DevExamples {}

@Component({
standalone: true,
imports: [
KbqSplitterModule,
KbqButtonModule,
KbqSidebarModule,
JsonPipe
DevExamples
],
selector: 'dev-app',
templateUrl: './template.html',
styleUrls: ['./styles.scss'],
styleUrl: './styles.scss',
encapsulation: ViewEncapsulation.None,
changeDetection: ChangeDetectionStrategy.OnPush
})
export class DevApp {
direction = Direction;
sidebarPositions = SidebarPositions;

leftSidebarSidebarState: boolean = false;
leftSplitterState: boolean = false;

rightSidebarSidebarState: boolean = false;

onStateChanged($event): void {
console.log('onStateChanged: ', $event);
}

toggleLeftSidebar() {
this.leftSidebarSidebarState = !this.leftSidebarSidebarState;
}

toggleRightSidebar() {
this.rightSidebarSidebarState = !this.rightSidebarSidebarState;
}

toggleLeftSplitterState() {
this.leftSplitterState = !this.leftSplitterState;
}
}
export class DevApp {}
26 changes: 1 addition & 25 deletions packages/components-dev/sidebar/styles.scss
Original file line number Diff line number Diff line change
@@ -1,25 +1 @@
dev-app {
display: block;
}

.dev-container {
display: flex;
flex-direction: row;
justify-content: flex-start;

height: 200px;
}

.dev-container__body {
flex: 1 1 30%;

background-color: antiquewhite;
}

.kbq-sidebar-opened {
background-color: #6fba53;
}

.kbq-sidebar-closed {
background-color: darkgray;
}
/* stylelint-disable-next-line no-empty-source */
89 changes: 1 addition & 88 deletions packages/components-dev/sidebar/template.html
Original file line number Diff line number Diff line change
@@ -1,88 +1 @@
<br />

<div class="layout-row layout-align-space-between">
<div>
<button kbq-button (click)="leftSidebar.toggle()">toggle by method</button>
&nbsp;
</div>

<div>
<button kbq-button (click)="rightSidebar.toggle()">toggle by method</button>
&nbsp;
</div>
</div>

<br />
<br />

<div class="dev-container layout-row layout-align-space-between">
<kbq-sidebar #leftSidebar="kbqSidebar" [position]="sidebarPositions.Left" (stateChanged)="onStateChanged($event)">
<div kbq-sidebar-opened class="kbq-sidebar-opened">kbq-sidebar-opened</div>
<div kbq-sidebar-closed class="kbq-sidebar-closed">kbq-sidebar-closed</div>
</kbq-sidebar>

<div class="dev-container__body">main area</div>

<kbq-sidebar #rightSidebar="kbqSidebar" [position]="sidebarPositions.Right" (stateChanged)="onStateChanged($event)">
<div kbq-sidebar-opened class="kbq-sidebar-opened">kbq-sidebar-opened</div>
<div kbq-sidebar-closed class="kbq-sidebar-closed">kbq-sidebar-closed</div>
</kbq-sidebar>
</div>

<br />
<br />
<br />

<div class="layout-row layout-align-space-between">
<div>
<button kbq-button (click)="toggleLeftSidebar()">toggle by state</button>
&nbsp;
<button kbq-button (click)="toggleLeftSplitterState()">toggle splitter state</button>
&nbsp;
</div>

<div>
<button kbq-button (click)="toggleRightSidebar()">toggle by state</button>
&nbsp;
</div>
</div>

<br />
<br />

<kbq-splitter
class="dev-container layout-row layout-align-space-between"
[direction]="direction.Horizontal"
[disabled]="leftSplitterState"
>
<kbq-sidebar
kbq-splitter-area
[opened]="leftSidebarSidebarState"
[position]="sidebarPositions.Left"
(stateChanged)="onStateChanged($event)"
>
<div kbq-sidebar-opened class="kbq-sidebar-opened" [maxWidth]="'600px'" [minWidth]="'320px'">
kbq-sidebar-opened
</div>

<div kbq-sidebar-closed class="kbq-sidebar-closed" [width]="'32px'">kbq-sidebar-closed</div>
</kbq-sidebar>

<div kbq-splitter-area class="flex dev-container__body">main body</div>

<kbq-sidebar
kbq-splitter-area
[opened]="rightSidebarSidebarState"
[position]="sidebarPositions.Right"
(stateChanged)="onStateChanged($event)"
>
<div kbq-sidebar-opened class="kbq-sidebar-opened">kbq-sidebar-opened</div>
<div kbq-sidebar-closed class="kbq-sidebar-closed">kbq-sidebar-closed</div>
</kbq-sidebar>
</kbq-splitter>

<br />
<br />
<br />

<div>{{ leftSidebar.params | json }}</div>
<dev-examples />
39 changes: 39 additions & 0 deletions packages/components/sidebar/__snapshots__/sidebar.spec.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`KbqSidebar should match snapshot when closed 1`] = `
DebugElement {
"nativeNode": <kbq-sidebar
class="kbq-sidebar ng-trigger ng-trigger-state"
style="min-width: 32px; width: 32px; max-width: 32px;"
>

<div
class="kbq-sidebar-closed"
kbqsidebarclosed=""
style=""
>
kbqSidebarClosed
</div>

</kbq-sidebar>,
}
`;

exports[`KbqSidebar should match snapshot when opened 1`] = `
DebugElement {
"nativeNode": <kbq-sidebar
class="kbq-sidebar ng-trigger ng-trigger-state"
style="min-width: inherit; width: inherit; max-width: inherit;"
>
<div
class="kbq-sidebar-opened"
kbqsidebaropened=""
style=""
>
kbqSidebarOpened
</div>


</kbq-sidebar>,
}
`;
6 changes: 2 additions & 4 deletions packages/components/sidebar/examples.sidebar.en.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
🚧 **Documentation in progress** 🚧
### With splitter

Unfortunately, the documentation for this section is not ready yet. We are actively working on its creation and plan to add it soon.

If you would like to contribute to the documentation or have any questions, please feel free to [open an issue](https://github.com/koobiq/angular-components/issues) in our GitHub repository.
<!-- example(sidebar-with-splitter) -->
6 changes: 2 additions & 4 deletions packages/components/sidebar/examples.sidebar.ru.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
🚧 **Документация в процессе написания** 🚧
### Со сплиттером

К сожалению, документация для этого раздела еще не готова. Мы активно работаем над ее созданием и планируем добавить в ближайшее время.

Если вы хотите помочь в написании документации или у вас есть вопросы, пожалуйста, [создайте issue](https://github.com/koobiq/angular-components/issues) в нашем репозитории на GitHub.
<!-- example(sidebar-with-splitter) -->
2 changes: 1 addition & 1 deletion packages/components/sidebar/public-api.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from './sidebar.component';
export * from './sidebar';
export * from './sidebar.module';
32 changes: 0 additions & 32 deletions packages/components/sidebar/sidebar-animations.ts

This file was deleted.

5 changes: 0 additions & 5 deletions packages/components/sidebar/sidebar.component.html

This file was deleted.

Loading