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

refactor(module:typography): refactor #4819

Merged
merged 2 commits into from
Mar 2, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
33 changes: 17 additions & 16 deletions components/typography/demo/basic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,27 @@ import { Component } from '@angular/core';
selector: 'nz-demo-typography-basic',
template: `
<article nz-typography>
<h1 nz-title>Introduction</h1>
<p nz-paragraph>
<h1 nz-typography>Introduction</h1>
<p nz-typography>
In the process of internal desktop applications development, many different design specs and implementations would be involved,
which might cause designers and developers difficulties and duplication and reduce the efficiency of development.
</p>
<p nz-paragraph>
<p nz-typography>
After massive project practice and summaries, Ant Design, a design language for backgroundapplications, is refined by Ant UED Team,
which aims to
<span nz-text
<span nz-typography
><strong
>uniform the user interface specs for internal background projects, lower the unnecessary cost of design differences and
implementation and liberate the resources ofdesign and front-end development</strong
></span
>.
</p>
<h2 nz-title>Guidelines and Resources</h2>
<p nz-paragraph>
We supply a series of design principles, practical patterns and high quality design resources (<span nz-text
<h2 nz-typography>Guidelines and Resources</h2>
<p nz-typography>
We supply a series of design principles, practical patterns and high quality design resources (<span nz-typography
><code>Sketch</code></span
>
and <span nz-text><code>Axure</code></span
and <span nz-typography><code>Axure</code></span
>), to help people create their product prototypes beautifully and efficiently.
</p>
<article nz-typography>
Expand All @@ -41,23 +41,24 @@ import { Component } from '@angular/core';
</ul>
</article>
<nz-divider></nz-divider>
<h1 nz-title>介绍</h1>
<p nz-paragraph>
<h1 nz-typography>介绍</h1>
<p nz-typography>
蚂蚁的企业级产品是一个庞大且复杂的体系。这类产品不仅量级巨大且功能复杂,而且变动和并发频繁,常常需要设计与开发能够快速的做出响应。
同时这类产品中有存在很多类似的页面以及组件,可以通过抽象得到一些稳定且高复用性的内容。
</p>
<p nz-paragraph>
<p nz-typography>
随着商业化的趋势,越来越多的企业级产品对更好的用户体验有了进一步的要求。带着这样的一个终极目标,我们(蚂蚁金服体验技术部)
经过大量的项目实践和总结,逐步打磨出一个服务于企业级产品的设计体系 Ant Design。 基于<span nz-text
经过大量的项目实践和总结,逐步打磨出一个服务于企业级产品的设计体系 Ant Design。 基于<span nz-typography
><mark>『确定』和『自然』</mark></span
>的设计价值观,通过模块化的解决方案,降低冗余的生产成本, 让设计者专注于<span nz-text><strong>更好的用户体验</strong></span
>的设计价值观,通过模块化的解决方案,降低冗余的生产成本, 让设计者专注于<span nz-typography><strong>更好的用户体验</strong></span
>。
</p>
<h2 nz-title>
<h2 nz-typography>
设计资源
</h2>
<p nz-paragraph>
我们提供完善的设计原则、最佳实践和设计资源文件 (<span nz-text><code>Sketch</code></span> 和 <span nz-text><code>Axure</code></span
<p nz-typography>
我们提供完善的设计原则、最佳实践和设计资源文件 (<span nz-typography><code>Sketch</code></span> 和
<span nz-typography><code>Axure</code></span
>),来帮助业务快速设计出高质 量的产品原型。
</p>
<article nz-typography>
Expand Down
6 changes: 3 additions & 3 deletions components/typography/demo/ellipsis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@ import { Component } from '@angular/core';
@Component({
selector: 'nz-demo-typography-ellipsis',
template: `
<p nz-paragraph nzEllipsis>
<p nz-typography nzEllipsis>
Ant Design, a design language for background applications, is refined by Ant UED Team. Ant Design, a design language for background
applications, is refined by Ant UED Team. Ant Design, a design language for background applications, is refined by Ant UED Team. Ant
Design, a design language for background applications, is refined by Ant UED Team. Ant Design, a design language for background
applications, is refined by Ant UED Team. Ant Design, a design language for background applications, is refined by Ant UED Team.
</p>
<br />
<p nz-paragraph nzEllipsis nzExpandable [nzEllipsisRows]="3">
<p nz-typography nzEllipsis nzExpandable [nzEllipsisRows]="3">
Ant Design, a design language for background applications, is refined by Ant UED Team. Ant Design, a design language for background
applications, is refined by Ant UED Team. Ant Design, a design language for background applications, is refined by Ant UED Team. Ant
Design, a design language for background applications, is refined by Ant UED Team. Ant Design, a design language for background
applications, is refined by Ant UED Team. Ant Design, a design language for background applications, is refined by Ant UED Team.
</p>
<br />
<p nz-paragraph nzEllipsis nzEditable [nzEllipsisRows]="2" [nzContent]="dynamicContent" (nzContentChange)="onChange($event)"></p>
<p nz-typography nzEllipsis nzEditable [nzEllipsisRows]="2" [nzContent]="dynamicContent" (nzContentChange)="onChange($event)"></p>
`
})
export class NzDemoTypographyEllipsisComponent {
Expand Down
6 changes: 3 additions & 3 deletions components/typography/demo/interactive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { Component } from '@angular/core';
@Component({
selector: 'nz-demo-typography-interactive',
template: `
<p nz-paragraph nzEditable [(nzContent)]="editStr"></p>
<p nz-paragraph nzCopyable nzEditable [(nzContent)]="copyStr"></p>
<p nz-paragraph nzCopyable nzCopyText="Hello, Ant Design!">Replace copy text.</p>
<p nz-typography nzEditable [(nzContent)]="editStr"></p>
<p nz-typography nzCopyable nzEditable [(nzContent)]="copyStr"></p>
<p nz-typography nzCopyable nzCopyText="Hello, Ant Design!">Replace copy text.</p>
`
})
export class NzDemoTypographyInteractiveComponent {
Expand Down
2 changes: 1 addition & 1 deletion components/typography/demo/suffix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Component } from '@angular/core';
selector: 'nz-demo-typography-suffix',
template: `
<nz-slider [(ngModel)]="rows" [nzMax]="10" [nzMin]="1"></nz-slider>
<p nz-paragraph nzEllipsis nzExpandable [attr.title]="content + suffix" [nzEllipsisRows]="rows" [nzSuffix]="suffix">
<p nz-typography nzEllipsis nzExpandable [attr.title]="content + suffix" [nzEllipsisRows]="rows" [nzSuffix]="suffix">
{{ content }}
</p>
`
Expand Down
20 changes: 10 additions & 10 deletions components/typography/demo/text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,25 @@ import { Component } from '@angular/core';
@Component({
selector: 'nz-demo-typography-text',
template: `
<span nz-text>Ant Design</span>
<span nz-typography>Ant Design</span>
<br />
<span nz-text nzType="secondary">Ant Design</span>
<span nz-typography nzType="secondary">Ant Design</span>
<br />
<span nz-text nzType="warning">Ant Design</span>
<span nz-typography nzType="warning">Ant Design</span>
<br />
<span nz-text nzType="danger">Ant Design</span>
<span nz-typography nzType="danger">Ant Design</span>
<br />
<span nz-text nzDisabled>Ant Design</span>
<span nz-typography nzDisabled>Ant Design</span>
<br />
<span nz-text><mark>Ant Design</mark></span>
<span nz-typography><mark>Ant Design</mark></span>
<br />
<span nz-text><code>Ant Design</code></span>
<span nz-typography><code>Ant Design</code></span>
<br />
<span nz-text><u>Ant Design</u></span>
<span nz-typography><u>Ant Design</u></span>
<br />
<span nz-text><del>Ant Design</del></span>
<span nz-typography><del>Ant Design</del></span>
<br />
<span nz-text><strong>Ant Design</strong></span>
<span nz-typography><strong>Ant Design</strong></span>
`,
styles: []
})
Expand Down
8 changes: 4 additions & 4 deletions components/typography/demo/title.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import { Component } from '@angular/core';
@Component({
selector: 'nz-demo-typography-title',
template: `
<h1 nz-title>h1. Ant Design</h1>
<h2 nz-title>h2. Ant Design</h2>
<h3 nz-title>h3. Ant Design</h3>
<h4 nz-title>h4. Ant Design</h4>
<h1 nz-typography>h1. Ant Design</h1>
<h2 nz-typography>h2. Ant Design</h2>
<h3 nz-typography>h3. Ant Design</h3>
<h4 nz-typography>h4. Ant Design</h4>
`,
styles: []
})
Expand Down
2 changes: 0 additions & 2 deletions components/typography/doc/index.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ Basic text writing, including headings, body text, lists, and more.

### [nz-typography]

> `p[nz-paragraph]`, `span[nz-text]`, `h1[nz-title]`, `h2[nz-title]`, `h3[nz-title]`, `h4[nz-title]` are used in the same way as the `[nz-typography]`

| Property | Description | Type | Default | Global Config |
| -------- | ----------- | ---- | ------- | ------------- |
| `[nzContent]` | Component content | `string` | - ||
Expand Down
2 changes: 0 additions & 2 deletions components/typography/doc/index.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ cols: 1

### [nz-typography]

> `p[nz-paragraph]`, `span[nz-text]`, `h1[nz-title]`, `h2[nz-title]`, `h3[nz-title]`, `h4[nz-title]` 的使用方法与 `[nz-typography]` 相同

| 参数 | 说明 | 类型 | 默认值 | 全局配置 |
| --- | --- | --- | --- | --- |
| `[nzContent]` | 组件内容 | `string` | - |
Expand Down
10 changes: 0 additions & 10 deletions components/typography/nz-text-copy.component.html

This file was deleted.

25 changes: 0 additions & 25 deletions components/typography/nz-text-edit.component.html

This file was deleted.

43 changes: 0 additions & 43 deletions components/typography/nz-typography.component.html

This file was deleted.

8 changes: 4 additions & 4 deletions components/typography/public-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
*/

export { NzTypographyModule } from './nz-typography.module';
export { NzTypographyComponent } from './nz-typography.component';
export { NzTextCopyComponent } from './nz-text-copy.component';
export { NzTextEditComponent } from './nz-text-edit.component';
export { NzTypographyModule } from './typography.module';
export { NzTypographyComponent } from './typography.component';
export { NzTextCopyComponent } from './text-copy.component';
export { NzTextEditComponent } from './text-edit.component';
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,18 @@ import { takeUntil } from 'rxjs/operators';
@Component({
selector: 'nz-text-copy',
exportAs: 'nzTextCopy',
templateUrl: './nz-text-copy.component.html',
template: `
<button
nz-tooltip
nz-trans-button
[nzTitle]="copied ? locale?.copied : locale?.copy"
class="ant-typography-copy"
[class.ant-typography-copy-success]="copied"
(click)="onClick()"
>
<i nz-icon [nzType]="copied ? 'check' : 'copy'"></i>
</button>
`,
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
preserveWhitespaces: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,26 @@ import { NzAutosizeDirective } from 'ng-zorro-antd/input';
@Component({
selector: 'nz-text-edit',
exportAs: 'nzTextEdit',
templateUrl: './nz-text-edit.component.html',
template: `
<button *ngIf="!editing" [nzTitle]="locale?.edit" nz-tooltip nz-trans-button class="ant-typography-edit" (click)="onClick()">
<i nz-icon nzType="edit"></i>
</button>
<ng-container *ngIf="editing">
<textarea
#textarea
nz-input
nzAutosize
(input)="onInput($event)"
(blur)="confirm()"
(keydown.esc)="onCancel()"
(keydown.enter)="onEnter($event)"
>
</textarea>
<button nz-trans-button class="ant-typography-edit-content-confirm" (click)="confirm()">
<i nz-icon nzType="enter"></i>
</button>
</ng-container>
`,
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
preserveWhitespaces: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ import {
} from 'ng-zorro-antd/core';
import { NzI18nService } from 'ng-zorro-antd/i18n';

import { NzTextCopyComponent } from './nz-text-copy.component';
import { NzTextEditComponent } from './nz-text-edit.component';
import { NzTextCopyComponent } from './text-copy.component';
import { NzTextEditComponent } from './text-edit.component';

const NZ_CONFIG_COMPONENT_NAME = 'typography';
const EXPAND_ELEMENT_CLASSNAME = 'ant-typography-expand';
Expand All @@ -61,7 +61,29 @@ const EXPAND_ELEMENT_CLASSNAME = 'ant-typography-expand';
h1[nz-title], h2[nz-title], h3[nz-title], h4[nz-title]
`,
exportAs: 'nzTypography',
templateUrl: './nz-typography.component.html',
template: `
<ng-template #contentTemplate let-content="content">
<ng-content *ngIf="!content"></ng-content>
{{ content }}
</ng-template>

<ng-container *ngIf="!editing">
<ng-container *ngIf="expanded || (!nzExpandable && !nzSuffix && nzEllipsisRows === 1) || canCssEllipsis">
<ng-template [ngTemplateOutlet]="contentTemplate" [ngTemplateOutletContext]="{ content: nzContent }"></ng-template>
</ng-container>
<ng-container *ngIf="(nzEllipsis && !expanded && (nzEllipsisRows > 1 || nzExpandable)) || nzSuffix">
<span #ellipsisContainer *ngIf="!expanded"></span>
<ng-container *ngIf="isEllipsis">{{ ellipsisStr }}</ng-container>
<ng-container *ngIf="nzSuffix">{{ nzSuffix }}</ng-container>
<a #expandable *ngIf="nzExpandable && isEllipsis" class="ant-typography-expand" (click)="onExpand()">{{ locale?.expand }}</a>
</ng-container>
</ng-container>

<nz-text-edit *ngIf="nzEditable" [text]="nzContent" (endEditing)="onEndEditing($event)" (startEditing)="onStartEditing()">
</nz-text-edit>

<nz-text-copy *ngIf="nzCopyable && !editing" [text]="copyText" (textCopy)="onTextCopy($event)"></nz-text-copy>
`,
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
preserveWhitespaces: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import { NzIconModule } from 'ng-zorro-antd/icon';
import { NzInputModule } from 'ng-zorro-antd/input';
import { NzToolTipModule } from 'ng-zorro-antd/tooltip';

import { NzTextCopyComponent } from './nz-text-copy.component';
import { NzTextEditComponent } from './nz-text-edit.component';
import { NzTypographyComponent } from './nz-typography.component';
import { NzTextCopyComponent } from './text-copy.component';
import { NzTextEditComponent } from './text-edit.component';
import { NzTypographyComponent } from './typography.component';

@NgModule({
imports: [CommonModule, NzIconModule, NzToolTipModule, NzInputModule, NzI18nModule, NzTransButtonModule, NzCopyToClipboardServiceModule],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { ComponentFixture, fakeAsync, flush, TestBed, tick } from '@angular/core
import { createKeyboardEvent, dispatchFakeEvent, typeInElement } from 'ng-zorro-antd/core';
import { NzIconTestModule } from 'ng-zorro-antd/icon/testing';

import { NzTypographyComponent } from './nz-typography.component';
import { NzTypographyModule } from './nz-typography.module';
import { NzTypographyComponent } from './typography.component';
import { NzTypographyModule } from './typography.module';

// tslint:disable-next-line no-any
declare const viewport: any;
Expand Down