Skip to content

Commit

Permalink
fix(instance-switcher): prevent style collisions
Browse files Browse the repository at this point in the history
closes #2056
  • Loading branch information
andrew-frueh committed Feb 23, 2023
1 parent 094552f commit 69a5f73
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 68 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<div class="sample-container">
<div #buttonContainer class="button-container">
<em class="sample-container-empty" *ngIf="buttons.length === 0">No buttons added</em>
<hc-measurable
*ngFor="let button of buttons"
[itemKey]="button.key">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ hc-measurable {
}
}

.sample-container-empty {
line-height: 35px;
}

button.hc-button hc-icon.hc-icon {
margin-left: 10px;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { animate, state, style, transition, trigger } from '@angular/animations';
import {ChangeDetectorRef, Component, ElementRef, HostListener, OnDestroy, QueryList, ViewChild, ViewChildren} from '@angular/core';
import { AfterViewInit, ChangeDetectorRef, Component, ElementRef, HostListener, OnDestroy, QueryList, ViewChild, ViewChildren } from '@angular/core';
import { HcPopoverAnchorDirective, MeasurableComponent, MeasurableService } from '@healthcatalyst/cashmere';
import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
Expand Down Expand Up @@ -31,18 +31,8 @@ interface ButtonData {
])
]
})
export class MeasurableOverviewExampleComponent implements OnDestroy {
buttons: ButtonData[] = [
{
key: 'button1',
text: 'Button 1'
},
{
key: 'button2',
text: 'Button 2'
}
];

export class MeasurableOverviewExampleComponent implements AfterViewInit, OnDestroy {
buttons: ButtonData[] = [];
moreButtons: ButtonData[] = [];
moreSelected = false;

Expand All @@ -52,7 +42,7 @@ export class MeasurableOverviewExampleComponent implements OnDestroy {

private unsubscribe$ = new Subject<void>();

private currentId = 3;
private currentId = 1;

@ViewChildren(MeasurableComponent)
buttonComponents: QueryList<MeasurableComponent>;
Expand All @@ -63,12 +53,7 @@ export class MeasurableOverviewExampleComponent implements OnDestroy {
@ViewChild('buttonContainer')
containerRef: ElementRef;

@HostListener('window:load')
setupButtons(): void {
setTimeout(() => {
this.refreshButtons();
});

ngAfterViewInit(): void {
this.buttonComponents.changes.pipe(
takeUntil(this.unsubscribe$)
).subscribe(() => this.refreshButtons());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

.button-container {
height: 305px;
padding: 5px;
border: 1px solid $slate-gray-300;
}

hc-measurable button {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { animate, state, style, transition, trigger } from '@angular/animations';
import {ChangeDetectorRef, Component, ElementRef, HostListener, QueryList, ViewChild, ViewChildren} from '@angular/core';
import { AfterViewInit, ChangeDetectorRef, Component, ElementRef, HostListener, OnDestroy, QueryList, ViewChild, ViewChildren } from '@angular/core';
import { HcPopoverAnchorDirective, MeasurableComponent, MeasurableService } from '@healthcatalyst/cashmere';
import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
Expand Down Expand Up @@ -31,17 +31,8 @@ interface ButtonData {
])
]
})
export class MeasurableVerticalExampleComponent {
buttons: ButtonData[] = [
{
key: 'button1',
text: 'Button 1'
},
{
key: 'button2',
text: 'Button 2'
}
];
export class MeasurableVerticalExampleComponent implements AfterViewInit, OnDestroy {
buttons: ButtonData[] = [];

moreButtons: ButtonData[] = [];
moreSelected = false;
Expand All @@ -52,7 +43,7 @@ export class MeasurableVerticalExampleComponent {

private unsubscribe$ = new Subject<void>();

private currentId = 3;
private currentId = 1;

@ViewChildren(MeasurableComponent)
buttonComponents: QueryList<MeasurableComponent>;
Expand All @@ -63,12 +54,7 @@ export class MeasurableVerticalExampleComponent {
@ViewChild('buttonContainer')
containerRef: ElementRef;

@HostListener('window:load')
setupButtons(): void {
setTimeout(() => {
this.refreshButtons();
});

ngAfterViewInit(): void {
this.buttonComponents.changes.pipe(
takeUntil(this.unsubscribe$)
).subscribe(() => this.refreshButtons());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,39 @@
@import '../sass/instance-switcher.scss';
@import '../../lib/sass/cashmere.scss';

.hc-instance-switcher {
@include hc-instance-switcher();

hc-measurable {
@include hc-instance-switcher-measurable();
}

.hc-chip.hc-chip-padding {
@include hc-instance-chip-padding();
}

button.hc-button.hc-instance-switcher-more {
@include hc-instance-more-button();

hc-icon {
@include hc-instance-button-icon();
}
}

button.hc-button.hc-instance-switcher-add {
@include hc-instance-add-button();
}

button.hc-icon-button.hc-instance-switcher-hide {
@include hc-instance-hide-button();
}

button.hc-menu-item.hc-instance-switcher-more-menu-item {
@include hc-instance-switcher-more();

hc-icon.hc-menu-icon.hc-instance-switcher-more-close {
@include hc-instance-switcher-more-close();
}
}
}

.hc-instance-container {
Expand Down Expand Up @@ -44,31 +71,3 @@
@include hc-instance-edit();
}
}

.hc-chip.hc-chip-padding {
@include hc-instance-chip-padding();
}

button.hc-button.hc-instance-switcher-more {
@include hc-instance-more-button();

hc-icon {
@include hc-instance-button-icon();
}
}

button.hc-button.hc-instance-switcher-add {
@include hc-instance-add-button();
}

button.hc-icon-button.hc-instance-switcher-hide {
@include hc-instance-hide-button();
}

button.hc-menu-item.hc-instance-switcher-more-menu-item {
@include hc-instance-switcher-more();

hc-icon.hc-menu-icon.hc-instance-switcher-more-close {
@include hc-instance-switcher-more-close();
}
}

0 comments on commit 69a5f73

Please sign in to comment.