Skip to content

Commit

Permalink
feat(core): add new appearances (#9526)
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 Oct 18, 2024
1 parent f507d2e commit c3cd8f2
Show file tree
Hide file tree
Showing 118 changed files with 550 additions and 406 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<button
appearance="whiteblock"
appearance="outline-grayscale"
size="s"
tuiButton
type="button"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
display: block;
inline-size: var(--t-size);
block-size: var(--t-size);
border-radius: 100%;

&[data-size='xs'] {
--t-size: @size-xs;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
inline-size: var(--t-size);
block-size: var(--t-size);
flex-shrink: 0;
border-radius: 100%;

&[data-size='xs'] {
--t-size: @size-xs;
Expand Down
2 changes: 1 addition & 1 deletion projects/addon-doc/components/code/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<div class="t-code-actions">
<button type="button"
tuiIconButton
appearance="whiteblock"
appearance="outline-grayscale"
size="s"
class="t-copy-button"
[iconStart]="icon()"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describe('TuiDocCodeComponent', () => {
expect(fixture.nativeElement.querySelector('.t-code')?.innerHTML.trim()).toEqual(
`<code class="hljs"><span class="hljs-keyword">const</span> a = <span class="hljs-number">5</span>;</code>
<div class="t-code-actions">
<button tuiappearance="" tuiicons="" type="button" tuiiconbutton="" appearance="whiteblock" size="s" class="t-copy-button" data-appearance="whiteblock" style="--t-icon-start: url(assets/taiga-ui/icons/copy.svg);" data-size="s">
<button tuiappearance="" tuiicons="" type="button" tuiiconbutton="" appearance="outline-grayscale" size="s" class="t-copy-button" data-appearance="outline-grayscale" style="--t-icon-start: url(assets/taiga-ui/icons/copy.svg);" data-size="s">
</button>
\t
</div>`.replace('\t', ' '), // prettier problem
Expand All @@ -71,7 +71,7 @@ describe('TuiDocCodeComponent', () => {
expect(fixture.nativeElement.querySelector('.t-code')?.innerHTML.trim()).toEqual(
`<code class="hljs"><span class="hljs-keyword">const</span> a = <span class="hljs-number">10</span>;</code>
<div class="t-code-actions">
<button tuiappearance="" tuiicons="" type="button" tuiiconbutton="" appearance="whiteblock" size="s" class="t-copy-button" data-appearance="whiteblock" style="--t-icon-start: url(assets/taiga-ui/icons/copy.svg);" data-size="s">
<button tuiappearance="" tuiicons="" type="button" tuiiconbutton="" appearance="outline-grayscale" size="s" class="t-copy-button" data-appearance="outline-grayscale" style="--t-icon-start: url(assets/taiga-ui/icons/copy.svg);" data-size="s">
</button>
\t
</div>`.replace('\t', ' '), // prettier problem
Expand All @@ -89,7 +89,7 @@ describe('TuiDocCodeComponent', () => {
expect(fixture.nativeElement.querySelector('.t-code')?.innerHTML.trim()).toEqual(
`<code class="hljs"><span class="hljs-keyword">const</span> a = <span class="hljs-number">15</span>;</code>
<div class="t-code-actions">
<button tuiappearance="" tuiicons="" type="button" tuiiconbutton="" appearance="whiteblock" size="s" class="t-copy-button" data-appearance="whiteblock" style="--t-icon-start: url(assets/taiga-ui/icons/copy.svg);" data-size="s">
<button tuiappearance="" tuiicons="" type="button" tuiiconbutton="" appearance="outline-grayscale" size="s" class="t-copy-button" data-appearance="outline-grayscale" style="--t-icon-start: url(assets/taiga-ui/icons/copy.svg);" data-size="s">
</button>
\t
</div>`.replace('\t', ' '), // prettier problem
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
</tui-badge>
<tui-badge
*ngIf="propertyConnector.documentationPropertyDeprecated"
appearance="error"
appearance="negative"
size="s"
>
Deprecated
Expand Down
2 changes: 1 addition & 1 deletion projects/addon-doc/components/example/example.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export class TuiDocExample {
protected copyExampleLink(target: EventTarget | null): void {
this.clipboard.copy((target as HTMLAnchorElement | null)?.href ?? '');
this.alerts
.open(this.texts[1], {label: this.texts[2], appearance: 'success'})
.open(this.texts[1], {label: this.texts[2], appearance: 'positive'})
.subscribe();
}

Expand Down
1 change: 1 addition & 0 deletions projects/addon-doc/components/example/example.style.less
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
.t-demo {
.customize-scroll();

position: relative;
padding: 2rem;
max-inline-size: 100%;
box-sizing: border-box;
Expand Down
2 changes: 1 addition & 1 deletion projects/addon-doc/components/language-switcher/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/>

<button
appearance="whiteblock"
appearance="outline-grayscale"
size="s"
tuiButtonSelect
tuiIconButton
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const NAVIGATION_ITEMS = tuiCreateToken<readonly TuiDocRoutePages[]>();

export const NAVIGATION_PROVIDERS: Provider[] = [
tuiAutoFocusOptionsProvider({preventScroll: true}),
tuiLinkOptionsProvider({appearance: 'icon'}),
tuiLinkOptionsProvider({appearance: 'action-grayscale'}),
{
provide: NAVIGATION_TITLE,
deps: [Router, ActivatedRoute, TUI_DOC_TITLE],
Expand Down
16 changes: 8 additions & 8 deletions projects/addon-mobile/styles/common/button.less
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@
--t-radius: 0.75rem;
}

&[data-appearance='primary']:disabled:not(._loading),
&[data-appearance='secondary']:disabled:not(._loading),
&[data-appearance='accent']:disabled:not(._loading),
&[data-appearance='destructive']:disabled:not(._loading),
&[data-appearance='opposite']:disabled:not(._loading),
&[data-appearance='flat']:disabled:not(._loading) {
&[data-appearance^='primary']:disabled:not(._loading),
&[data-appearance^='secondary']:disabled:not(._loading),
&[data-appearance^='accent']:disabled:not(._loading),
&[data-appearance^='destructive']:disabled:not(._loading),
&[data-appearance^='opposite']:disabled:not(._loading),
&[data-appearance^='flat']:disabled:not(._loading) {
background: var(--tui-background-neutral-1);
color: var(--tui-background-neutral-1-pressed);
color: var(--tui-text-tertiary);
opacity: 1;

&[data-appearance='flat'] {
&[data-appearance^='flat'] {
background: transparent;
}
}
Expand Down
1 change: 0 additions & 1 deletion projects/addon-table/components/table/th/th.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import {TUI_TABLE_OPTIONS} from '../table.options';
host: {
'[style.width.px]': 'width',
'[class._sticky]': 'sticky',
'[attr.requiredSort]': 'requiredSort',
},
})
export class TuiTableTh<T extends Partial<Record<keyof T, any>>> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@ export const ATTR_WITH_VALUES_TO_REPLACE: ReplacementAttributeValue[] = [
newAttrName: 'tuiHintAppearance',
valueReplacer: [{from: 'onDark', to: 'dark'}],
},
{
attrNames: ['appearance'],
newAttrName: 'appearance',
valueReplacer: [{from: 'secondary-destructive', to: 'destructive'}],
},
{
attrNames: ['[pseudoActive]'],
newAttrName: '[tuiAppearanceState]',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export function migrateButtonAppearance({

recorder.insertLeft(
startOffset + templateOffset,
` ${appearanceInputName}="whiteblock"`,
` ${appearanceInputName}="outline-grayscale"`,
);
recorder.insertLeft(
startOffset + templateOffset,
Expand All @@ -90,6 +90,6 @@ export function migrateButtonAppearance({
function addTodo(recorder: UpdateRecorder, templateOffset: number): void {
recorder.insertRight(
templateOffset,
'<!-- Taiga migration TODO: tuiButton "whiteblock-active" appearance is no longer available. Use \'appearance="whiteblock" tuiAppearanceMode="checked"\' -->\n',
'<!-- Taiga migration TODO: tuiButton "whiteblock-active" appearance is no longer available. Use \'appearance="outline-grayscale" tuiAppearanceMode="checked"\' -->\n',
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,18 @@ const TEMPLATE_WITH_CONDITION_BEFORE = `
const TEMPLATE_AFTER = `
<button tuiButton></button>
<button tuiButton appearance="whiteblock" tuiAppearanceMode="checked"></button>
<button tuiButton appearance="outline-grayscale" tuiAppearanceMode="checked"></button>
<button tuiButton appearance="whiteblock" tuiAppearanceMode="checked"></button>
<button tuiButton appearance="outline-grayscale" tuiAppearanceMode="checked"></button>
<a tuiIconButton appearance="whiteblock" tuiAppearanceMode="checked"></a>
<a tuiIconButton appearance="outline-grayscale" tuiAppearanceMode="checked"></a>
<a tuiButton [appearance]="
'flat'
"></a>
`;

const TEMPLATE_WITH_CONDITION_AFTER = `<!-- Taiga migration TODO: tuiButton "whiteblock-active" appearance is no longer available. Use 'appearance="whiteblock" tuiAppearanceMode="checked"' -->
const TEMPLATE_WITH_CONDITION_AFTER = `<!-- Taiga migration TODO: tuiButton "whiteblock-active" appearance is no longer available. Use 'appearance="outline-grayscale" tuiAppearanceMode="checked"' -->
<a tuiButton [appearance]="
true ? appearance : 'flat'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ const TEMPLATE_BEFORE = `
const TEMPLATE_AFTER = `
<!-- TODO: (Taiga UI migration) [shape] input has been removed. Please use border-radius css property for rounding borders https://taiga-ui.dev/components/button -->
<button
appearance="destructive"
appearance="secondary-destructive"
tuiButton
type="button"
[iconStart]="icon"
Expand Down
7 changes: 3 additions & 4 deletions projects/cdk/utils/miscellaneous/provide-options.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type {FactoryProvider, InjectionToken} from '@angular/core';
import {Optional, SkipSelf} from '@angular/core';
import {inject} from '@angular/core';

export function tuiProvideOptions<T>(
provide: InjectionToken<T>,
Expand All @@ -8,9 +8,8 @@ export function tuiProvideOptions<T>(
): FactoryProvider {
return {
provide,
deps: [[new Optional(), new SkipSelf(), provide]],
useFactory: (parent: T | null): T => ({
...(parent || fallback),
useFactory: (): T => ({
...(inject(provide, {optional: true, skipSelf: true}) || fallback),
...options,
}),
};
Expand Down
16 changes: 15 additions & 1 deletion projects/core/components/alert/alert.tokens.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type {Type} from '@angular/core';
import type {FactoryProvider, Type} from '@angular/core';
import {inject} from '@angular/core';
import type {TuiPopover} from '@taiga-ui/cdk/services';
import {TUI_IS_MOBILE} from '@taiga-ui/cdk/tokens';
Expand Down Expand Up @@ -53,3 +53,17 @@ export const TUI_ALERTS_GROUPED = tuiCreateTokenFromFactory(() =>
}),
),
);

export function tuiAlertOptionsProvider(
options: Partial<TuiAlertOptions>,
): FactoryProvider {
return {
provide: TUI_ALERT_OPTIONS,
useFactory: (): TuiAlertOptions => ({
...TUI_ALERT_DEFAULT_OPTIONS,
...(inject(TUI_ALERT_OPTIONS, {optional: true, skipSelf: true}) ||
inject(TUI_NOTIFICATION_OPTIONS)),
...options,
}),
};
}
1 change: 1 addition & 0 deletions projects/core/components/dialog/dialog.style.less
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@

.t-heading {
margin: 0 0 0.5rem;
padding-inline-end: 2rem;
overflow-wrap: break-word;
font: var(--tui-font-heading-4);

Expand Down
2 changes: 1 addition & 1 deletion projects/core/components/link/link.options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export interface TuiLinkOptions extends TuiAppearanceOptions {
}

export const TUI_LINK_DEFAULT_OPTIONS: TuiLinkOptions = {
appearance: 'link',
appearance: 'action',
pseudo: false,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class TuiNotificationStyles {}
pseudo: true,
}),
tuiButtonOptionsProvider({
appearance: 'whiteblock',
appearance: 'outline-grayscale',
size: 's',
}),
],
Expand Down
8 changes: 6 additions & 2 deletions projects/core/components/notification/notification.options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,14 @@ export interface TuiNotificationOptions extends TuiAppearanceOptions {

const ICONS: Record<string, string> = {
info: '@tui.info',
success: '@tui.circle-check',
error: '@tui.circle-x',
positive: '@tui.circle-check',
negative: '@tui.circle-x',
warning: '@tui.circle-alert',
neutral: '@tui.info',
/* TODO @deprecated remove in v5 */
success: '@tui.circle-check',
/* TODO @deprecated remove in v5 */
error: '@tui.circle-x',
};

/** Default values for the notification options. */
Expand Down
19 changes: 13 additions & 6 deletions projects/core/directives/appearance/appearance.options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,30 @@ import {tuiCreateToken, tuiProvide} from '@taiga-ui/cdk/utils/miscellaneous';
*/
type Appearance = TuiLooseUnion<
| 'accent'
| 'destructive'
| 'error'
| 'action-destructive'
| 'action-grayscale'
| 'action'
| 'flat-destructive'
| 'flat-grayscale'
| 'flat'
| 'floating'
| 'glass'
| 'icon'
| 'info'
| 'link'
| 'negative'
| 'neutral'
| 'opposite'
| 'outline-destructive'
| 'outline-grayscale'
| 'outline'
| 'positive'
| 'primary-destructive'
| 'primary-grayscale'
| 'primary'
| 'secondary-destructive'
| 'secondary-grayscale'
| 'secondary'
| 'success'
| 'textfield'
| 'warning'
| 'whiteblock'
>;

export interface TuiAppearanceOptions {
Expand Down
2 changes: 2 additions & 0 deletions projects/core/styles/components/link.less
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* Icons, Appearance, Button
*/
[tuiLink] {
// TODO: Remove in v5
--tui-text-tertiary: var(--tui-text-secondary);

padding: 0;
Expand All @@ -27,6 +28,7 @@
text-decoration-thickness: 0.7px;
text-decoration-color: color-mix(in lch, currentColor, transparent);

// TODO: Remove in v5
&:hover {
--tui-text-secondary: var(--tui-text-primary);
}
Expand Down
2 changes: 1 addition & 1 deletion projects/core/styles/components/notification.less
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* data-size — size (default: 'l') ('s' | 'm' | 'l')
*
* @example
* <tui-notification tuiAppearance data-appearance="error">
* <tui-notification tuiAppearance data-appearance="negative">
* <span tuiTitle>
* Error
* <span tuiSubtitle>Something went wrong</span>
Expand Down
Loading

0 comments on commit c3cd8f2

Please sign in to comment.