Skip to content

Commit

Permalink
Add color variation options for checkbox style
Browse files Browse the repository at this point in the history
  • Loading branch information
Angi-Kinas authored and jahow committed Nov 3, 2023
1 parent 0acb34a commit 217b961
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 1 deletion.
24 changes: 24 additions & 0 deletions libs/ui/inputs/src/lib/checkbox/checkbox.component.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
.default {
--gn-ui-checkbox-color: var(--color-main);
}

.secondary {
--gn-ui-checkbox-color: var(--color-secondary);
}

.primary {
--gn-ui-checkbox-color: var(--color-primary);
}

mat-checkbox {
--mdc-checkbox-selected-icon-color: var(--gn-ui-checkbox-color);
--mdc-checkbox-selected-focus-icon-color: var(--gn-ui-checkbox-color);
--mdc-checkbox-selected-hover-icon-color: var(--gn-ui-checkbox-color);
--mdc-checkbox-selected-icon-color: var(--gn-ui-checkbox-color);
--mdc-checkbox-selected-pressed-icon-color: var(--gn-ui-checkbox-color);
--mdc-checkbox-selected-focus-state-layer-color: var(--gn-ui-checkbox-color);
--mdc-checkbox-selected-hover-state-layer-color: var(--gn-ui-checkbox-color);
--mdc-checkbox-selected-pressed-state-layer-color: var(
--gn-ui-checkbox-color
);
}
2 changes: 1 addition & 1 deletion libs/ui/inputs/src/lib/checkbox/checkbox.component.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<mat-checkbox
class="cursor-pointer"
[class]="classList"
type="checkbox"
[checked]="checked"
[indeterminate]="indeterminate"
(click)="handleClick($event)"
color="primary"
></mat-checkbox>
5 changes: 5 additions & 0 deletions libs/ui/inputs/src/lib/checkbox/checkbox.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,15 @@ import {
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class CheckboxComponent {
@Input() type: 'primary' | 'secondary' | 'default' = 'default'
@Input() checked = false
@Input() indeterminate? = false
@Output() changed = new EventEmitter<boolean>()

get classList() {
return `${this.type}`
}

handleClick(event: Event) {
event.stopPropagation()
this.checked = !this.checked
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
[checked]="isAllSelected()"
[indeterminate]="isSomeSelected()"
(changed)="selectAll()"
type="default"
>
</gn-ui-checkbox>
</div>
Expand Down Expand Up @@ -153,6 +154,7 @@
<gn-ui-checkbox
[checked]="isChecked(record)"
(changed)="handleRecordSelectedChange($event, record)"
type="default"
></gn-ui-checkbox>
</div>
<div
Expand Down

0 comments on commit 217b961

Please sign in to comment.