Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(addon-doc): add fade in animation for tab content
- Loading branch information
Showing
11 changed files
with
163 additions
and
79 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
projects/addon-doc/src/components/tab-content/tab-content.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import {ChangeDetectionStrategy, Component, Inject, Input} from '@angular/core'; | ||
import {TUI_IS_CYPRESS} from '@taiga-ui/cdk'; | ||
|
||
@Component({ | ||
selector: 'tui-tab-content', | ||
templateUrl: './tab-content.template.html', | ||
styleUrls: ['./tab-content.template.less'], | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class TuiTabContentComponent { | ||
@Input() isActiveTab: boolean = false; | ||
@Input() code?: string; | ||
|
||
constructor(@Inject(TUI_IS_CYPRESS) private readonly isCypress: boolean) {} | ||
|
||
get useAnimation() { | ||
return !this.isCypress && !this.isActiveTab; | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
projects/addon-doc/src/components/tab-content/tab-content.module.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import {ClipboardModule} from '@angular/cdk/clipboard'; | ||
import {CommonModule} from '@angular/common'; | ||
import {NgModule} from '@angular/core'; | ||
import {TuiDocCodeModule, TuiDocCopyModule} from '@taiga-ui/addon-doc'; | ||
|
||
import {TuiTabContentComponent} from './tab-content.component'; | ||
|
||
@NgModule({ | ||
imports: [CommonModule, TuiDocCodeModule, TuiDocCopyModule, ClipboardModule], | ||
declarations: [TuiTabContentComponent], | ||
exports: [TuiTabContentComponent], | ||
}) | ||
export class TuiTabContentModule {} |
17 changes: 17 additions & 0 deletions
17
projects/addon-doc/src/components/tab-content/tab-content.template.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<div [class.t-use-fade-animate]="useAnimation"> | ||
<div | ||
*ngIf="isActiveTab; else codeSection" | ||
automation-id="tui-doc-example" | ||
class="t-demo" | ||
> | ||
<ng-content></ng-content> | ||
</div> | ||
|
||
<ng-template #codeSection> | ||
<tui-doc-copy | ||
class="t-copy-code" | ||
[cdkCopyToClipboard]="code" | ||
></tui-doc-copy> | ||
<tui-doc-code [code]="code"></tui-doc-code> | ||
</ng-template> | ||
</div> |
34 changes: 34 additions & 0 deletions
34
projects/addon-doc/src/components/tab-content/tab-content.template.less
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
@import 'taiga-ui-local'; | ||
|
||
@keyframes fadeIn { | ||
0% { | ||
opacity: 0; | ||
} | ||
|
||
100% { | ||
opacity: 1; | ||
} | ||
} | ||
|
||
.t-use-fade-animate { | ||
will-change: opacity; | ||
animation: fadeIn ease-in 500ms; | ||
animation-fill-mode: forwards; | ||
animation-iteration-count: 1; | ||
} | ||
|
||
.t-demo { | ||
.customize-scroll(); | ||
padding: 2rem; | ||
overflow-x: auto; | ||
|
||
@media @mobile-m { | ||
padding: 1rem; | ||
} | ||
} | ||
|
||
.t-copy-code { | ||
position: absolute; | ||
top: 4.375rem; | ||
right: 1rem; | ||
} |