Skip to content
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
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
@import 'color-palette';
@import 'font';

:host {
.toggle-switch {
display: flex;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No host styling please. Here, it's being used as a scope due to the also-problematic abuse of ng-deep, but we're not applying host styles.

The problem with host styling is that's breaking encapsulation - the parent is responsible for applying styles at the host level, and applying them inside the component can introduce non-obvious conflicts.

Please try to accomplish the same thing with regular css classes inside the component.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Encapsulated it inside a div

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't we need to add align-items:center too ?

Copy link
Contributor Author

@23nobody 23nobody Feb 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

align-items: center;

::ng-deep {
.mat-slide-toggle {
&.disabled {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,17 @@ import { ToggleSwitchSize } from './toggle-switch-size';
styleUrls: ['./toggle-switch.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<mat-slide-toggle
color="primary"
[checked]="this.checked"
[ngClass]="{ 'small-slide-toggle': this.size === '${ToggleSwitchSize.Small}', disabled: this.disabled }"
[disabled]="this.disabled"
(change)="this.onToggle($event)"
>
<div class="label">{{ this.label }}</div>
</mat-slide-toggle>
<div class="toggle-switch">
<mat-slide-toggle
color="primary"
[checked]="this.checked"
[ngClass]="{ 'small-slide-toggle': this.size === '${ToggleSwitchSize.Small}', disabled: this.disabled }"
[disabled]="this.disabled"
(change)="this.onToggle($event)"
>
<div class="label">{{ this.label }}</div>
</mat-slide-toggle>
</div>
`
})
export class ToggleSwitchComponent {
Expand Down