Skip to content
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

feat(kit)!: Action better customization + new API #2505

Merged
merged 5 commits into from
Aug 29, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions projects/demo/src/modules/app/app.const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const SEE_ALSO_GROUPS: ReadonlyArray<readonly string[]> = [
[`InputNumber`, `Money`],
[`InputPhone`, `InputPhoneInternational`],
[`Button`, `Action`, `Link`],
[`Action`, `Island`],
[`CheckboxBlock`, `CheckboxLabeled`, `PrimitiveCheckbox`, `Toggle`, `Checkbox`],
[`Accordion`, `Expand`],
[`Radio`, `RadioBlock`, `RadioLabeled`, `RadioList`],
Expand Down
18 changes: 18 additions & 0 deletions projects/demo/src/modules/components/action/action.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,24 @@ export class ExampleTuiActionComponent {
TypeScript: import(`./examples/2/index.ts?raw`),
};

readonly example3: TuiDocExample = {
HTML: import(`./examples/3/index.html?raw`),
LESS: import(`./examples/3/index.less?raw`),
TypeScript: import(`./examples/3/index.ts?raw`),
};

readonly example4: TuiDocExample = {
HTML: import(`./examples/4/index.html?raw`),
LESS: import(`./examples/4/index.less?raw`),
TypeScript: import(`./examples/4/index.ts?raw`),
};

readonly example5: TuiDocExample = {
HTML: import(`./examples/5/index.html?raw`),
LESS: import(`./examples/5/index.less?raw`),
TypeScript: import(`./examples/5/index.ts?raw`),
};

readonly iconVariants = [
`tuiIconPrintLarge`,
`tuiIconLoginLarge`,
Expand Down
15 changes: 13 additions & 2 deletions projects/demo/src/modules/components/action/action.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,31 @@ import {CommonModule} from '@angular/common';
import {NgModule} from '@angular/core';
import {RouterModule} from '@angular/router';
import {TuiAddonDocModule, tuiGenerateRoutes} from '@taiga-ui/addon-doc';
import {TuiActionModule} from '@taiga-ui/kit';
import {TuiActionModule, TuiMarkerIconModule} from '@taiga-ui/kit';

import {ExampleTuiActionComponent} from './action.component';
import {TuiActionExample1} from './examples/1';
import {TuiActionExample2} from './examples/2';
import {TuiActionExample3} from './examples/3';
import {TuiActionExample4} from './examples/4';
import {TuiActionExample5} from './examples/5';

@NgModule({
imports: [
CommonModule,
TuiActionModule,
TuiAddonDocModule,
TuiMarkerIconModule,
RouterModule.forChild(tuiGenerateRoutes(ExampleTuiActionComponent)),
],
declarations: [ExampleTuiActionComponent, TuiActionExample1, TuiActionExample2],
declarations: [
ExampleTuiActionComponent,
TuiActionExample1,
TuiActionExample2,
TuiActionExample3,
TuiActionExample4,
TuiActionExample5,
],
exports: [ExampleTuiActionComponent],
})
export class ExampleTuiActionModule {}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,33 @@
>
<tui-action-example-2></tui-action-example-2>
</tui-doc-example>

<tui-doc-example
id="sizes"
i18n-heading
heading="Sizes"
[content]="example3"
>
<tui-action-example-3></tui-action-example-3>
</tui-doc-example>

<tui-doc-example
id="reversed-no-shadow"
i18n-heading
heading="Reversed & No Shadow"
[content]="example4"
>
<tui-action-example-4></tui-action-example-4>
</tui-doc-example>

<tui-doc-example
id="vertical"
i18n-heading
heading="Vertical"
[content]="example5"
>
<tui-action-example-5></tui-action-example-5>
</tui-doc-example>
</ng-template>

<ng-template pageTab>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<button tuiAction>
<section>
<h3 class="header tui-text_body-s">Header</h3>
<p class="description tui-text_body-xs">Description</p>
</section>
<tui-marker-icon
size="xs"
src="tuiIconStarLarge"
class="tui-island__marker"
></tui-marker-icon>
</button>

<button tuiAction>
<section>
<h3 class="header tui-text_body-m">Header</h3>
<p class="description tui-text_body-s">Description</p>
</section>
<tui-marker-icon
size="s"
src="tuiIconBellLarge"
class="tui-island__marker"
></tui-marker-icon>
</button>

<button tuiAction>
<section>
<h3 class="header tui-text_h6">Header</h3>
<p class="description tui-text_body-m">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the
industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and
scrambled it to make a type specimen book.
</p>
</section>
<tui-marker-icon
size="m"
src="tuiIconFlagLarge"
class="tui-island__marker"
></tui-marker-icon>
</button>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[tuiAction] {
max-width: 26rem;
align-items: center;

&:not(:last-child) {
margin-bottom: 1.5rem;
}
}

.header,
.description {
margin: 0;
}

.header {
font-weight: bold;
}

.description {
color: var(--tui-text-02);
}
12 changes: 12 additions & 0 deletions projects/demo/src/modules/components/action/examples/3/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import {Component} from '@angular/core';
import {changeDetection} from '@demo/emulate/change-detection';
import {encapsulation} from '@demo/emulate/encapsulation';

@Component({
selector: `tui-action-example-3`,
templateUrl: `./index.html`,
styleUrls: [`./index.less`],
changeDetection,
encapsulation,
})
export class TuiActionExample3 {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<button tuiAction>
<tui-marker-icon
size="s"
src="tuiIconLikeLarge"
class="tui-island__marker"
></tui-marker-icon>
<section>
<h3 class="header tui-text_body-s">Header</h3>
<p class="description tui-text_body-xs">Description</p>
</section>
</button>

<button
tuiAction
class="no-shadow"
>
<tui-marker-icon
size="s"
src="tuiIconDislikeLarge"
class="tui-island__marker"
></tui-marker-icon>
<section>
<h3 class="header tui-text_body-s">Header</h3>
<p class="description tui-text_body-xs">
Use
<code>box-shadow: none</code>
</p>
</section>
</button>
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
:host {
display: flex;
flex-wrap: wrap;
column-gap: 3rem;
row-gap: 1.5rem;
}

[tuiAction] {
flex: 1;
justify-content: start;
align-items: center;
}

.no-shadow {
box-shadow: none;

&:hover {
box-shadow: none;
}
}

.header,
.description {
margin: 0;
}

.header {
font-weight: bold;
}

.description {
color: var(--tui-text-02);
}
12 changes: 12 additions & 0 deletions projects/demo/src/modules/components/action/examples/4/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import {Component} from '@angular/core';
import {changeDetection} from '@demo/emulate/change-detection';
import {encapsulation} from '@demo/emulate/encapsulation';

@Component({
selector: `tui-action-example-4`,
templateUrl: `./index.html`,
styleUrls: [`./index.less`],
changeDetection,
encapsulation,
})
export class TuiActionExample4 {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<a
tuiAction
target="_blank"
href="http://www.montypython.com"
>
<section>
<tui-marker-icon
size="s"
src="tuiIconAlignJustifyLarge"
class="tui-island__marker"
></tui-marker-icon>
<h3 class="header tui-text_body-m">Header</h3>
<p class="description tui-text_body-s">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the
industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and
scrambled it to make a type specimen book.
</p>
</section>
</a>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[tuiAction] {
max-width: 20rem;
align-items: center;
}

.header,
.description {
margin: 0;
}

.header {
margin-top: 0.5rem;
font-weight: bold;
}

.description {
color: var(--tui-text-02);
}
12 changes: 12 additions & 0 deletions projects/demo/src/modules/components/action/examples/5/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import {Component} from '@angular/core';
import {changeDetection} from '@demo/emulate/change-detection';
import {encapsulation} from '@demo/emulate/encapsulation';

@Component({
selector: `tui-action-example-5`,
templateUrl: `./index.html`,
styleUrls: [`./index.less`],
changeDetection,
encapsulation,
})
export class TuiActionExample5 {}
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,13 @@
<a
href="http://ng-web-apis.github.io/"
tuiAction
[icon]="icon"
>
Link
<tui-marker-icon
size="m"
class="tui-island__marker"
[src]="icon"
[style.color]="'red'"
></tui-marker-icon>
</a>
```
3 changes: 3 additions & 0 deletions projects/kit/components/action/action.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ import {
selector: `button[tuiAction], a[tuiAction]`,
templateUrl: `./action.template.html`,
styleUrls: [`./action.style.less`],
host: {
class: `tui-island tui-island_hoverable`,
},
changeDetection: ChangeDetectionStrategy.OnPush,
providers: [
TuiDestroyService,
Expand Down
14 changes: 3 additions & 11 deletions projects/kit/components/action/action.style.less
Original file line number Diff line number Diff line change
@@ -1,27 +1,19 @@
@import 'taiga-ui-local';

:host {
.hoverable-with-shadow();
.clearbtn();
position: relative;
display: flex;
justify-content: space-between;
font: var(--tui-font-text-m);
padding: 0.875rem;
color: var(--tui-text-01);
text-decoration: none;
border: 2px solid transparent;
border-radius: var(--tui-radius-l);
outline: none;
text-align: start;

&._focus-visible {
border-color: var(--tui-focus);
}
}

.t-icon {
margin-left: 1.25rem;
color: var(--tui-action-color, var(--tui-link));
background-color: var(--tui-action-background, var(--tui-base-02));
&:after {
display: none;
}
}
3 changes: 2 additions & 1 deletion projects/kit/components/action/action.template.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<ng-content></ng-content>
<tui-marker-icon
*ngIf="icon"
size="s"
class="t-icon"
class="tui-island__marker"
[src]="icon"
></tui-marker-icon>
15 changes: 15 additions & 0 deletions projects/styles/markup/tui-island.less
Original file line number Diff line number Diff line change
Expand Up @@ -175,4 +175,19 @@
width: ~'calc(100% + 2.375rem);'; // margin compensation
margin: @padding-large calc(-1.25rem + 1px) calc(-1.25rem + 1px); // 1px is compensations of border
}

/* Artificially increased specificity */
&__marker&__marker {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we need this all of a sudden? :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe we can instead leave those styles inside action.style.less? Since they are Action related, not Island related?

Copy link
Member Author

Choose a reason for hiding this comment

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

done ✅

color: var(--tui-action-color, var(--tui-link));
background-color: var(--tui-action-background, var(--tui-base-02));

&:first-child:not(:only-child) {
margin-right: 1.25rem;
}

&:not(:first-child),
&:only-child {
margin-left: 1.25rem;
}
}
}