Skip to content

Commit

Permalink
chore(demo): Appearance add all options
Browse files Browse the repository at this point in the history
  • Loading branch information
waterplea committed Sep 4, 2024
1 parent 9add899 commit c3a839c
Show file tree
Hide file tree
Showing 8 changed files with 88 additions and 24 deletions.
4 changes: 2 additions & 2 deletions projects/core/directives/appearance/appearance.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
import {tuiWithStyles} from '@taiga-ui/cdk/utils/miscellaneous';
import type {TuiInteractiveState} from '@taiga-ui/core/types';

import {TUI_APPEARANCE_OPTIONS} from './appearance.options';
import {TUI_APPEARANCE_OPTIONS, type TuiAppearanceOptions} from './appearance.options';

@Component({
standalone: true,
Expand Down Expand Up @@ -43,7 +43,7 @@ export class TuiAppearance {
public readonly focus = signal<boolean | null>(null);

@Input()
public set tuiAppearance(appearance: string) {
public set tuiAppearance(appearance: TuiAppearanceOptions['appearance']) {
this.appearance.set(appearance);
}

Expand Down
25 changes: 24 additions & 1 deletion projects/core/directives/appearance/appearance.options.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,31 @@
import type {ExistingProvider, ProviderToken} from '@angular/core';
import {tuiCreateToken, tuiProvide} from '@taiga-ui/cdk/utils/miscellaneous';

/**
* Bundled appearances for autocomplete purposes, not exported on purpose
*/
type Appearance =
| 'primary'
| 'secondary'
| 'accent'
| 'floating'
| 'glass'
| 'link'
| 'textfield'
| 'opposite'
| 'whiteblock'
| 'outline'
| 'flat'
| 'destructive'
| 'neutral'
| 'error'
| 'success'
| 'warning'
| 'info'
| ({} & string);

Check failure on line 25 in projects/core/directives/appearance/appearance.options.ts

View workflow job for this annotation

GitHub Actions / Lint

Remove this type without members or change this type intersection

export interface TuiAppearanceOptions {
readonly appearance: string;
readonly appearance: Appearance;
}

export const TUI_APPEARANCE_DEFAULT_OPTIONS: TuiAppearanceOptions = {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<button
*ngFor="let appearance of appearances"
tuiButton
[appearance]="appearance"
>
{{ appearance }}
</button>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
:host {
display: flex;
gap: 1rem;
flex-wrap: wrap;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import {NgForOf} from '@angular/common';
import {Component} from '@angular/core';
import {changeDetection} from '@demo/emulate/change-detection';
import {encapsulation} from '@demo/emulate/encapsulation';
import {TuiAppearance, TuiButton} from '@taiga-ui/core';

@Component({
standalone: true,
imports: [TuiAppearance, TuiButton, NgForOf],
templateUrl: './index.html',
styleUrls: ['./index.less'],
encapsulation,
changeDetection,
})
export default class Example {
protected readonly appearances = [
'primary',
'secondary',
'destructive',
'neutral',
'flat',
'link',
'accent',
'opposite',
'floating',
'textfield',
'whiteblock',
'outline',
'error',
'success',
'warning',
'info',
'glass',
] as const;
}
28 changes: 7 additions & 21 deletions projects/demo/src/modules/directives/appearance/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,13 @@
<p>A directive for visual presets of interactive components</p>

<tui-doc-example
id="basic"
description="Interactive elements react to pointer natively but you can override state with inputs"
heading="Basic"
[component]="1 | tuiComponent"
[content]="1 | tuiExample"
/>

<tui-doc-example
id="custom"
description="Use LESS or SCSS mixins to create your own appearances in global styles"
heading="Custom"
[component]="2 | tuiComponent"
[content]="2 | tuiExample"
/>

<tui-doc-example
id="checkbox"
description="You can use it on input[type='checkbox'] to create a custom toggle component easily"
heading="Checkbox"
[component]="3 | tuiComponent"
[content]="3 | tuiExample"
*ngFor="let example of examples; let index = index; let last = last"
[component]="index + 1 | tuiComponent"
[content]="index + 1 | tuiExample"
[description]="descriptions[index]"
[fullsize]="last"
[heading]="example"
[id]="example | tuiKebab"
/>
</ng-template>

Expand Down
7 changes: 7 additions & 0 deletions projects/demo/src/modules/directives/appearance/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ import {TuiButton} from '@taiga-ui/core';
changeDetection,
})
export default class Page {
protected examples = ['Basic', 'Custom', 'Checkbox', 'Bundled'];
protected descriptions = [
'Interactive elements react to pointer natively but you can override state with inputs',
'Use LESS or SCSS mixins to create your own appearances in global styles',
'You can use it on input[type="checkbox"] to create a custom toggle component easily',
'You can create your own appearances or use one of the bundled options',
];
protected appearances = ['primary', 'secondary', 'flat'];
protected appearance = this.appearances[0]!;

Expand Down
1 change: 1 addition & 0 deletions projects/layout/components/navigation/aside.style.less
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ tui-dropdown[data-appearance='dropdown-navigation'] {

[tuiAsideItem] {
justify-content: flex-start;
margin: 0;

&._active {
background: transparent;
Expand Down

0 comments on commit c3a839c

Please sign in to comment.