Skip to content

Commit

Permalink
feat(layout): Title add new component (#5743)
Browse files Browse the repository at this point in the history
  • Loading branch information
waterplea authored Oct 25, 2023
1 parent aa0297d commit 93b51ff
Show file tree
Hide file tree
Showing 32 changed files with 399 additions and 9 deletions.
8 changes: 8 additions & 0 deletions projects/demo/src/modules/app/app.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,14 @@ export const ROUTES: Routes = [
title: `BlockStatus`,
},
},
{
path: `layout/title`,
loadChildren: async () =>
(await import(`../directives/title/title.module`)).ExampleTuiTitleModule,
data: {
title: `Title`,
},
},
{
path: `experimental/avatar`,
loadChildren: async () =>
Expand Down
6 changes: 6 additions & 0 deletions projects/demo/src/modules/app/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,12 @@ export const pages: TuiDocPages = [
keywords: `блок, статус, block, status, block-status, blockstatus, layout`,
route: `/layout/block-status`,
},
{
section: `Layout`,
title: `Title`,
keywords: `subtitle, заголовок, caption, description, подзаголовок`,
route: `/layout/title`,
},
{
section: `Components`,
title: `Button`,
Expand Down
17 changes: 17 additions & 0 deletions projects/demo/src/modules/directives/title/examples/1/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<h2 tuiTitle>I am a title</h2>

<h2 tuiTitle>
I am a title
<div tuiSubtitle>I'm a subtitle</div>
</h2>

<h2 tuiTitle>
<div tuiSubtitle>Caption</div>
I am a title
</h2>

<h2 tuiTitle>
<div tuiSubtitle>Caption</div>
I am a title
<div tuiSubtitle>I'm a subtitle</div>
</h2>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
:host {
display: flex;
flex-direction: column;
gap: 2rem;
}
12 changes: 12 additions & 0 deletions projects/demo/src/modules/directives/title/examples/1/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-title-example-1',
templateUrl: './index.html',
styleUrls: ['./index.less'],
changeDetection,
encapsulation,
})
export class TuiTitleExample1 {}
15 changes: 15 additions & 0 deletions projects/demo/src/modules/directives/title/examples/2/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<h2 tuiTitle="s">
<div tuiSubtitle>Caption</div>
I am a title
<div tuiSubtitle>I'm a subtitle</div>
</h2>

<h2 tuiTitle="m">
<div tuiSubtitle>Caption</div>
I am a title
</h2>

<h2 tuiTitle="l">
I am a title
<div tuiSubtitle>I'm a subtitle</div>
</h2>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
:host {
display: flex;
flex-direction: column;
gap: 2rem;
}
12 changes: 12 additions & 0 deletions projects/demo/src/modules/directives/title/examples/2/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-title-example-2',
templateUrl: './index.html',
styleUrls: ['./index.less'],
changeDetection,
encapsulation,
})
export class TuiTitleExample2 {}
36 changes: 36 additions & 0 deletions projects/demo/src/modules/directives/title/examples/3/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<h2 tuiTitle>
<b>I am a title</b>
<div
tuiSubtitle
[style.color]="'var(--tui-text-02)'"
>
I'm a subtitle
</div>
</h2>

<a
href="https://github.com/taiga-family/taiga-ui"
tuiLink
tuiTitle
[style.font-size.rem]="1"
[style.line-height.rem]="1.25"
>
Taiga UI — GitHub
<div
tuiSubtitle
[style.font]="'var(--tui-font-text-s)'"
>
Drop us a star!
</div>
</a>

<label class="flex">
<tui-avatar
size="s"
src="/assets/images/avatar.jpg"
></tui-avatar>
<div tuiTitle="s">
<strong>Alex Inkin</strong>
<div tuiSubtitle>Available</div>
</div>
</label>
14 changes: 14 additions & 0 deletions projects/demo/src/modules/directives/title/examples/3/index.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
:host {
display: flex;
flex-direction: column;
gap: 2rem;
}

.flex {
display: flex;
gap: 0.5rem;

[tuiSubtitle] {
color: var(--tui-positive);
}
}
12 changes: 12 additions & 0 deletions projects/demo/src/modules/directives/title/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-title-example-3',
templateUrl: './index.html',
styleUrls: ['./index.less'],
changeDetection,
encapsulation,
})
export class TuiTitleExample3 {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
```ts
import {TuiTitleModule} from '@taiga-ui/layout';

// ...

@NgModule({
imports: [
// ...
TuiTitleModule,
],
// ...
})
export class MyModule {}
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
```html
<tui-block-status [card]="card">
<img
tuiSlot="top"
src="src"
/>
<h4>Title</h4>
Description
<button
tuiButton
tuiItem
>
Button
</button>
</tui-block-status>
```
29 changes: 29 additions & 0 deletions projects/demo/src/modules/directives/title/title.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import {Component} from '@angular/core';
import {changeDetection} from '@demo/emulate/change-detection';
import {TuiDocExample} from '@taiga-ui/addon-doc';

@Component({
selector: 'example-title',
templateUrl: './title.template.html',
changeDetection,
})
export class ExampleTuiTitleComponent {
readonly exampleModule = import('./examples/import/import-module.md?raw');
readonly exampleHtml = import('./examples/import/insert-template.md?raw');

readonly example1: TuiDocExample = {
TypeScript: import('./examples/1/index.ts?raw'),
HTML: import('./examples/1/index.html?raw'),
};

readonly example2: TuiDocExample = {
TypeScript: import('./examples/2/index.ts?raw'),
HTML: import('./examples/3/index.html?raw'),
};

readonly example3: TuiDocExample = {
TypeScript: import('./examples/3/index.ts?raw'),
HTML: import('./examples/3/index.html?raw'),
LESS: import('./examples/3/index.less?raw'),
};
}
31 changes: 31 additions & 0 deletions projects/demo/src/modules/directives/title/title.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import {CommonModule} from '@angular/common';
import {NgModule} from '@angular/core';
import {tuiGetDocModules} from '@taiga-ui/addon-doc';
import {TuiLinkModule, TuiWrapperModule} from '@taiga-ui/core';
import {TuiAvatarModule, TuiCheckboxModule} from '@taiga-ui/experimental';
import {TuiTitleModule} from '@taiga-ui/layout';

import {TuiTitleExample1} from './examples/1';
import {TuiTitleExample2} from './examples/2';
import {TuiTitleExample3} from './examples/3';
import {ExampleTuiTitleComponent} from './title.component';

@NgModule({
imports: [
CommonModule,
TuiTitleModule,
tuiGetDocModules(ExampleTuiTitleComponent),
TuiLinkModule,
TuiCheckboxModule,
TuiWrapperModule,
TuiAvatarModule,
],
declarations: [
ExampleTuiTitleComponent,
TuiTitleExample1,
TuiTitleExample2,
TuiTitleExample3,
],
exports: [ExampleTuiTitleComponent],
})
export class ExampleTuiTitleModule {}
55 changes: 55 additions & 0 deletions projects/demo/src/modules/directives/title/title.template.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<tui-doc-page
header="Title"
package="LAYOUT"
type="components"
>
<ng-template pageTab>
<p>A directive for title with optional subtitle</p>

<tui-doc-example
id="base"
heading="Basic"
[content]="example1"
>
<tui-title-example-1></tui-title-example-1>
</tui-doc-example>

<tui-doc-example
id="sizes"
heading="Sizes"
[content]="example2"
>
<tui-title-example-2></tui-title-example-2>
</tui-doc-example>

<tui-doc-example
id="custom"
heading="Custom"
[content]="example3"
>
<tui-title-example-3></tui-title-example-3>
</tui-doc-example>
</ng-template>

<ng-template pageTab="Setup">
<ol class="b-demo-steps">
<li>
<p>Import module:</p>

<tui-doc-code
filename="myComponent.module.ts"
[code]="exampleModule"
></tui-doc-code>
</li>

<li>
<p>Add to the template:</p>

<tui-doc-code
filename="myComponent.template.html"
[code]="exampleHtml"
></tui-doc-code>
</li>
</ol>
</ng-template>
</tui-doc-page>
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
<ng-template pageTab>
<ol class="b-demo-steps">
<li>
<p>Import module</p>
<p>Import module:</p>

<tui-doc-code
filename="myComponent.module.ts"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
<ng-template pageTab>
<ol class="b-demo-steps">
<li>
<p>Import into a module</p>
<p>Import module:</p>

<tui-doc-code
filename="myComponent.module.ts"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
<ng-template pageTab>
<ol class="b-demo-steps">
<li>
<p>Import into a module</p>
<p>Import module:</p>

<tui-doc-code
filename="myComponent.module.ts"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
<ng-template pageTab>
<ol class="b-demo-steps">
<li>
<p>Import into a module</p>
<p>Import module:</p>

<tui-doc-code
filename="myComponent.module.ts"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<ng-template pageTab="Setup">
<ol class="b-demo-steps">
<li>
<p>Import module</p>
<p>Import module:</p>

<tui-doc-code
filename="myComponent.module.ts"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
<ng-template pageTab>
<ol class="b-demo-steps">
<li>
<p>Import module</p>
<p>Import module:</p>

<tui-doc-code
filename="myComponent.module.ts"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<ng-template pageTab="Setup">
<ol class="b-demo-steps">
<li>
<p>Import module</p>
<p>Import module:</p>

<tui-doc-code
filename="myComponent.module.ts"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
<ng-template pageTab>
<ol class="b-demo-steps">
<li>
<p>Import into a module</p>
<p>Import module:</p>

<tui-doc-code
filename="myComponent.module.ts"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<ng-template pageTab="Setup">
<ol class="b-demo-steps">
<li>
<p>Import module</p>
<p>Import module:</p>

<tui-doc-code
filename="myComponent.module.ts"
Expand Down
1 change: 1 addition & 0 deletions projects/layout/components/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from '@taiga-ui/layout/components/block-status';
export * from '@taiga-ui/layout/components/title';
Loading

0 comments on commit 93b51ff

Please sign in to comment.