Skip to content

Commit

Permalink
feat(module:segmented): now supports segmented with icon only (#8368)
Browse files Browse the repository at this point in the history
* feat(module:segmented): now supports segmented with icon only

* feat(module:segmented): now supports segmented with icon only
  • Loading branch information
ParsaArvanehPA committed Mar 11, 2024
1 parent 18b898e commit e8dea7a
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 3 deletions.
14 changes: 14 additions & 0 deletions components/segmented/demo/with-icon-only.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
order: 11
title:
zh-CN: 只设置图标
en-US: With Icon only
---

## zh-CN

在 Segmented Item 选项中只设置 Icon。

## en-US

Set `icon` without `label` for Segmented Item.
14 changes: 14 additions & 0 deletions components/segmented/demo/with-icon-only.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Component } from '@angular/core';

import { NzSegmentedOptions } from 'ng-zorro-antd/segmented';

@Component({
selector: 'nz-demo-segmented-with-icon-only',
template: `<nz-segmented [nzOptions]="options"></nz-segmented>`
})
export class NzDemoSegmentedWithIconOnlyComponent {
options: NzSegmentedOptions = [
{ value: 'List', icon: 'bars' },
{ value: 'Kanban', icon: 'appstore' }
];
}
14 changes: 11 additions & 3 deletions components/segmented/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,21 @@
* found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
*/

export interface NzSegmentedOption {
label: string;
export type NzSegmentedOption = {
value: string | number;
useTemplate?: boolean;
icon?: string;
disabled?: boolean;
className?: string;
} & (NzSegmentedWithLabel | NzSegmentedWithIcon);

export interface NzSegmentedWithLabel {
label: string;
icon?: string;
}

export interface NzSegmentedWithIcon {
icon: string;
label?: string;
}

export type NzSegmentedOptions = Array<NzSegmentedOption | string | number>;
Expand Down

0 comments on commit e8dea7a

Please sign in to comment.