Skip to content

Commit

Permalink
chore(demo): update appearances customization page (#8761)
Browse files Browse the repository at this point in the history
Co-authored-by: taiga-family-bot <[email protected]>
  • Loading branch information
waterplea and taiga-family-bot authored Aug 30, 2024
1 parent f73ae00 commit ae3ea2d
Show file tree
Hide file tree
Showing 15 changed files with 179 additions and 146 deletions.
6 changes: 3 additions & 3 deletions projects/demo/src/modules/app/app.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ export const ROUTES: Routes = [
loadComponent: async () => import('../customization/variables'),
}),
route({
path: DemoRoute.Wrapper,
title: 'Wrapper',
loadComponent: async () => import('../customization/wrapper'),
path: DemoRoute.Appearances,
title: 'Appearances',
loadComponent: async () => import('../customization/appearances'),
}),
route({
path: DemoRoute.DialogCustom,
Expand Down
1 change: 1 addition & 0 deletions projects/demo/src/modules/app/demo-routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const DemoRoute = {
Amount: '/pipes/amount',
Emails: '/pipes/emails',
Appearance: '/directives/appearance',
Appearances: '/appearances',
FluidTypography: '/directives/fluid-typography',
Chip: '/components/chip',
Title: '/components/title',
Expand Down
4 changes: 2 additions & 2 deletions projects/demo/src/modules/app/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1082,9 +1082,9 @@ export const pages: TuiDocRoutePages = [
},
{
section: 'Customization',
title: 'Wrapper',
title: 'Appearances',
keywords: 'colors, css, theme, custom, style',
route: DemoRoute.Wrapper,
route: DemoRoute.Appearances,
},
{
section: 'Customization',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<tui-input
minlength="5"
[(ngModel)]="value"
>
Input example
</tui-input>
<tui-textfield>
<label tuiLabel>Input example</label>
<input
minlength="5"
tuiTextfield
[(ngModel)]="value"
/>
</tui-textfield>
<label
tuiLabel
class="tui-space_vertical-4"
Expand All @@ -16,11 +18,4 @@
/>
<small>Checkbox example</small>
</label>
<button
appearance="material-button"
size="s"
tuiButton
type="button"
>
Submit
</button>
<button tuiButton>Submit</button>
Original file line number Diff line number Diff line change
@@ -1,58 +1,50 @@
@import '@taiga-ui/legacy/styles/taiga-ui-local';
@import '@taiga-ui/core/styles/taiga-ui-local';

[tuiWrapper][data-appearance='material-textfield'] {
tui-wrapper-example-1 {
--tui-background-accent-1: #6200ee;
--tui-background-accent-1-hover: #6e14ef;
--tui-background-accent-1-pressed: #6e14ef;
--tui-text-primary-on-accent-1: #fff;
}

[tuiAppearance][data-appearance='material-textfield'] {
.transition(~'background, box-shadow');
background: #f5f5f5;
outline: none;
color: rgba(0, 0, 0, 0.87);
border-radius: 0.25rem 0.25rem 0 0;
box-shadow: inset 0 -1px #8e8e8e;

&:after {
.transition(all);
height: 0.0625rem;
background: #8e8e8e;
top: auto;
border: none;
transform-origin: bottom;
}

.wrapper-hover({
.appearance-hover({
background: #ececec;

&:after {
background: #1f1f1f;
}
box-shadow: inset 0 -1px #1f1f1f;
});

.wrapper-focus({
.appearance-focus({
background: #dcdcdc;
box-shadow: inset 0 -2px var(--tui-background-accent-1) !important;

// TODO: Better internal elements customization
label {
color: #6200ee !important;
}

&:after {
background: #6200ee;
transform: scaleY(2);
~ label {
--tui-text-primary: var(--tui-background-accent-1);
}
});

.wrapper-invalid({
// TODO: Better internal elements customization
label {
color: #b00020 !important;
}
&:invalid {
--tui-background-accent-1: #b00020;
box-shadow: inset 0 -1px var(--tui-background-accent-1) !important;

&:after {
background: #b00020;
~ label {
--tui-text-primary: #b00020 !important;
}
});
}
}

[tuiAppearance][data-appearance='material-button'] {
.transition(all);
border-radius: 0.25rem;
background: #6200ee;
color: #fff;
background: var(--tui-background-accent-1);
color: var(--tui-text-primary-on-accent-1);
outline: none;
text-transform: uppercase;
font-weight: bold;
box-shadow:
Expand All @@ -61,34 +53,30 @@
0rem 0.0625rem 0.3125rem 0rem rgba(0, 0, 0, 0.12);

.appearance-hover({
background: #6e14ef;
background: var(--tui-background-accent-1-hover);
box-shadow: 0 0.125rem 0.25rem -0.0625rem rgba(0, 0, 0, 0.2), 0rem 0.25rem 0.3125rem 0rem rgba(0, 0, 0, 0.14),
0rem 0.0625rem 0.625rem 0rem rgba(0, 0, 0, 0.12);
});

.appearance-active({
background: #6e14ef;
background: var(--tui-background-accent-1-pressed);
box-shadow: 0 0.3125rem 0.3125rem -0.1875rem rgba(0, 0, 0, 0.2),
0rem 0.5rem 0.625rem 0.0625rem rgba(0, 0, 0, 0.14), 0rem 0.1875rem 0.875rem 0.125rem rgba(0, 0, 0, 0.12);
});

.appearance-focus({
background: #883df2;

&:after {
display: none;
}
});
}

[tuiAppearance][data-appearance='material-checkbox-on'],
[tuiAppearance][data-appearance='material-checkbox-off'] {
color: #fff;
[tuiAppearance][data-appearance='material-checkbox'] {
color: var(--tui-text-primary-on-accent-1);
border-radius: 0.125rem;
border: 0.125rem solid rgba(0, 0, 0, 0.54);
outline: none;

&:after {
.transition(opacity);
.transition(all);
content: '';
position: absolute;
top: -0.625rem;
Expand All @@ -98,28 +86,32 @@
border-radius: 100%;
background: #000;
opacity: 0;
transform: scale(0);
}

.appearance-hover({
&:after {
opacity: 0.05;
transform: none;
}
});

.appearance-active({
&:after {
opacity: 0.1;
transform: none;
}
});

.appearance-focus({
&:after {
opacity: 0.1;
transform: none;
}
});
}

[tuiAppearance][data-appearance='material-checkbox-on'] {
background: #6200ee;
border-color: transparent;
&:checked {
background: var(--tui-background-accent-1);
border-color: transparent;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import {Component, signal, ViewEncapsulation} from '@angular/core';
import {FormsModule} from '@angular/forms';
import {
TuiButton,
tuiButtonOptionsProvider,
TuiTextfield,
tuiTextfieldOptionsProvider,
} from '@taiga-ui/core';
import {TuiCheckbox, tuiCheckboxOptionsProvider} from '@taiga-ui/kit';

@Component({
standalone: true,
selector: 'tui-wrapper-example-1',
imports: [FormsModule, TuiCheckbox, TuiButton, TuiTextfield],
templateUrl: './index.html',
styleUrls: ['./index.less'],
encapsulation: ViewEncapsulation.None,
providers: [
tuiButtonOptionsProvider({appearance: 'material-button', size: 's'}),
tuiCheckboxOptionsProvider({appearance: 'material-checkbox'}),
tuiTextfieldOptionsProvider({
appearance: signal('material-textfield'),
cleaner: signal(false),
}),
],
})
export class TuiWrapperExample1 {
protected value = '';
protected checkbox = false;
}
75 changes: 75 additions & 0 deletions projects/demo/src/modules/customization/appearances/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<tui-doc-page header="Appearances">
<p>
Most Taiga UI components rely on
<a
tuiLink
[routerLink]="routes.Appearance"
>
Appearance
</a>
directive to represent their interactive state — you will find
<code>appearance</code>
input on many components, such as
<a
tuiLink
[routerLink]="routes.Button"
>
Button
</a>
,
<a
tuiLink
[routerLink]="routes.Chip"
>
Chip
</a>
,
<a
tuiLink
[routerLink]="routes.Notification"
>
Notification
</a>
etc.
</p>
<p>
When you include Taiga UI theme what you do is define light and dark mode values for CSS
<a
tuiLink
[routerLink]="routes.Variables"
>
variables
</a>
and make built-in appearances, such as
<code>primary</code>
or
<code>outline</code>
, available to use in components.
</p>
<p>
You can easily create your own appearances with the help of mixins (both LESS and SCSS) to define style rules
for particular states:
</p>
<ul>
<li *ngFor="let item of mixins">
<tui-doc-copy
class="var"
[cdkCopyToClipboard]="item"
>
<code>{{ item }}</code>
</tui-doc-copy>
</li>
</ul>
<p>
Don't forget to import
<code>&#64;import '&#64;taiga-ui/core/styles/taiga-ui-local';</code>
</p>

<tui-doc-example
id="material"
heading="Imitate material"
[content]="example1"
>
<tui-wrapper-example-1 />
</tui-doc-example>
</tui-doc-page>
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {ClipboardModule} from '@angular/cdk/clipboard';
import {Component, ViewEncapsulation} from '@angular/core';
import {changeDetection} from '@demo/emulate/change-detection';
import {DemoRoute} from '@demo/routes';
import {TuiDemo} from '@demo/utils';
import {TuiLink} from '@taiga-ui/core';

Expand All @@ -21,11 +22,11 @@ export default class Page {
};

protected readonly mixins = [
'.wrapper-hover(@ruleset)',
'.wrapper-active(@ruleset)',
'.wrapper-readonly(@ruleset)',
'.wrapper-disabled(@ruleset)',
'.wrapper-focus(@ruleset)',
'.wrapper-invalid(@ruleset)',
'.appearance-hover(@ruleset)',
'.appearance-active(@ruleset)',
'.appearance-disabled(@ruleset)',
'.appearance-focus(@ruleset)',
];

protected readonly routes = DemoRoute;
}

This file was deleted.

Loading

0 comments on commit ae3ea2d

Please sign in to comment.