Skip to content
Open
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
3 changes: 2 additions & 1 deletion packages/components-dev/button/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { ChangeDetectionStrategy, Component, ViewEncapsulation } from '@angular/
import { KbqButtonModule, KbqButtonStyles } from '@koobiq/components/button';
import { KbqComponentColors } from '@koobiq/components/core';
import { KbqIconModule } from '@koobiq/components/icon';
import { KbqTitleModule } from '@koobiq/components/title';
import { ButtonExamplesModule } from 'packages/docs-examples/components/button';

@Component({
Expand All @@ -26,7 +27,7 @@ export class DevDocsExamples {}

@Component({
selector: 'dev-app',
imports: [KbqButtonModule, KbqIconModule, DevDocsExamples],
imports: [KbqButtonModule, KbqIconModule, DevDocsExamples, KbqTitleModule],
templateUrl: 'template.html',
styleUrls: ['styles.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
Expand Down
53 changes: 53 additions & 0 deletions packages/components-dev/button/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,59 @@

<hr />

<div id="icon-slots-demo">
<h4>Explicit icon slots (source order is reversed on purpose)</h4>

<!-- left icon written AFTER the text, right icon written BEFORE — slots put them in place -->
<button kbq-button [color]="colors.Contrast">
Кнопка
<i kbqButtonLeftIcon kbq-icon="kbq-plus_16"></i>
</button>
&nbsp;
<button kbq-button [color]="colors.Contrast">
<i kbqButtonRightIcon kbq-icon="kbq-chevron-down-s_16"></i>
Кнопка
</button>
&nbsp;
<button kbq-button [color]="colors.Contrast">
<i kbqButtonRightIcon kbq-icon="kbq-chevron-down-s_16"></i>
Кнопка
<i kbqButtonLeftIcon kbq-icon="kbq-plus_16"></i>
</button>
&nbsp;
<!-- icon-only two-icon trigger, markers in reversed order -->
<button kbq-button class="kbq-dropdown-trigger" [color]="colors.Contrast">
<i kbqButtonRightIcon kbq-icon="kbq-chevron-down-s_16"></i>
<i kbqButtonLeftIcon kbq-icon="kbq-play_16"></i>
</button>
</div>

<hr />

<div id="ellipsis-demo">
<h4>Text ellipsis (width-constrained)</h4>

<!-- text only -->
<button kbq-button style="max-width: 160px" kbq-title [color]="colors.Contrast">
Очень длинный текст кнопки, который не помещается
</button>
&nbsp;
<!-- with marker icons: icons stay, only the text is clipped -->
<button kbq-button style="max-width: 160px" kbq-title [color]="colors.Contrast">
<i kbqButtonLeftIcon kbq-icon="kbq-plus_16"></i>
Очень длинный текст кнопки, который не помещается
<i kbqButtonRightIcon kbq-icon="kbq-chevron-down-s_16"></i>
</button>
&nbsp;
<!-- legacy: icon in default slot, nested inside .kbq-button-text -->
<button kbq-button style="max-width: 160px" kbq-title [color]="colors.Contrast">
<i kbq-icon="kbq-plus_16"></i>
Очень длинный текст кнопки, который не помещается
</button>
</div>

<hr />

<div>
<div>
<button disabled kbq-button class="kbq-dropdown-trigger">
Expand Down
12 changes: 12 additions & 0 deletions packages/components/button/_button-base.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@use '../core/styles/common/button';
@use '../core/styles/common/list';

@use '../core/styles/common/tokens' as *;

Expand Down Expand Up @@ -47,6 +48,17 @@
& .kbq-button-wrapper {
display: flex;
align-items: center;

min-width: 0;
}

& .kbq-button-text {
@include list.kbq-truncate-line();

display: flex;
align-items: center;

min-width: 0;
}

& .kbq-icon_left {
Expand Down
14 changes: 3 additions & 11 deletions packages/components/button/_button-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@
}

@mixin kbq-button-theme() {
.kbq-button-overlay {
display: none;
}

.kbq-button,
.kbq-button-icon {
-webkit-font-smoothing: antialiased;
Expand Down Expand Up @@ -87,7 +83,9 @@
&.kbq-button_filled,
&.kbq-button_outline,
&.kbq-button_transparent {
&.cdk-keyboard-focused {
// :not(.kbq-disabled): a disabled <a kbq-button> can keep DOM focus (tabindex=-1 does
// not blur it), and FocusMonitor stays attached for the whole component lifetime.
&.cdk-keyboard-focused:not(.kbq-disabled) {
$focused-color: var(--kbq-states-line-focus-theme);
outline: 1px solid $focused-color;
border-color: $focused-color;
Expand All @@ -101,10 +99,4 @@
.kbq-button-icon {
@include kbq-typography-level-to-styles-css-variables(typography, text-normal-medium);
}

.kbq-button-icon.kbq-button-wrapper {
.kbq-icon {
@include kbq-css-font-variable(typography, body, line-height, '');
}
}
}
13 changes: 13 additions & 0 deletions packages/components/button/button-icon.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Directive } from '@angular/core';

/** Marks an icon to be projected into the left slot of a button. */
@Directive({
selector: '[kbqButtonLeftIcon]'
})
export class KbqButtonLeftIcon {}

/** Marks an icon to be projected into the right slot of a button. */
@Directive({
selector: '[kbqButtonRightIcon]'
})
export class KbqButtonRightIcon {}
14 changes: 11 additions & 3 deletions packages/components/button/button.component.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
<span #kbqTitleText class="kbq-button-wrapper" (cdkObserveContent)="projectContentChanged()">
<ng-content />
<span
#parentTextElement
class="kbq-button-wrapper"
[cdkObserveContentDisabled]="!styler.icons().length"
(cdkObserveContent)="projectContentChanged()"
>
<ng-content select="[kbqButtonLeftIcon]" />
<span #kbqTitleText class="kbq-button-text">
<ng-content />
</span>
<ng-content select="[kbqButtonRightIcon]" />
</span>
<span class="kbq-button-overlay" (click)="haltDisabledEvents($event)"></span>
Loading
Loading