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

Supported icons in select component options #386

Merged
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
16 changes: 16 additions & 0 deletions projects/composition/src/app/api-data/cps-select.json
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,22 @@
"default": "info",
"description": "Name of the info field of an option, shows the additional information text."
},
{
"name": "optionIcon",
"optional": false,
"readonly": false,
"type": "string",
"default": "icon",
"description": "Name of the icon field of an option, shows the icon."
},
{
"name": "optionIconColor",
"optional": false,
"readonly": false,
"type": "string",
"default": "iconColor",
"description": "Name of the icon color field of an option, sets the icon color."
},
{
"name": "hideDetails",
"optional": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@
prefixIcon="plus"
[value]="[options[5]]">
</cps-select>
<cps-select
label="Single select with options icons"
[options]="statusOptions"
optionLabel="name"
optionIconColor="color"
placeholder="Select a status">
</cps-select>
<div class="sync-val-example">
<cps-select
width="500"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ export class SelectPageComponent implements OnInit {
{ name: 'Berlin', data: { code: 'BER' } }
];

statusOptions = [
{ name: 'Success', icon: 'circle', color: 'success' },
{ name: 'Pending', icon: 'circle', color: 'info' },
{ name: 'Warning', icon: 'circle', color: 'warn' },
{ name: 'Failed', icon: 'circle', color: 'error' }
];

syncOptions = [
{ title: 'Amazon', val: 'AMZN', ticker: 'AMZN' },
{ title: 'Apple', val: 'AAPL', ticker: 'AAPL' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,14 @@

<span
class="cps-select-options-option-right"
[class.virtual-row]="virtualScroll"
>{{ item[optionInfo] }}</span
>
[class.virtual-row]="virtualScroll">
{{ item[optionInfo] }}
<cps-icon
*ngIf="item[optionIcon]"
[icon]="item[optionIcon]"
[color]="item[optionIconColor] || 'text-light'"
class="cps-select-options-option-right-icon">
</cps-icon>
</span>
</div>
</ng-template>
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,11 @@ $hover-transition-duration: 0.2s;

&-right {
color: $select-option-info-color;
text-align: right;
display: flex;
align-items: center;
&-icon {
margin-left: 8px;
}
}

&-check {
Expand All @@ -261,7 +265,8 @@ $hover-transition-duration: 0.2s;
box-sizing: border-box;
position: relative;
flex-shrink: 0;
transition: border-color 90ms cubic-bezier(0, 0, 0.2, 0.1),
transition:
border-color 90ms cubic-bezier(0, 0, 0.2, 0.1),
background-color 90ms cubic-bezier(0, 0, 0.2, 0.1);
margin-right: 8px;
opacity: 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,18 @@ export class CpsSelectComponent
*/
@Input() optionInfo = 'info';

/**
* Name of the icon field of an option, shows the icon.
* @group Props
*/
@Input() optionIcon = 'icon';

/**
* Name of the icon color field of an option, sets the icon color.
* @group Props
*/
@Input() optionIconColor = 'iconColor';

/**
* Hides hint and validation errors.
* @group Props
Expand Down
Loading