Skip to content

Commit

Permalink
feat(atomic): update css to not change parent element css
Browse files Browse the repository at this point in the history
  • Loading branch information
jelmedini committed Jul 3, 2023
1 parent f5961b4 commit 4ee8afb
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ atomic-insight-result-action-bar {
}
}

.hovered {
.showActionBar {
@apply visible;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ atomic-result-section-children {
}

:host(.resultHovered) {
position: relative;
@apply relative;

.with-sections {
background-color: #f2f2f2;
}
}

:host(.withActionBar) {
:host {
.with-sections {
padding: 1.5rem;
@apply p-6;
}
}

:host(.withActionBar)::before {
margin: 0px 1.5rem !important;
:host::before {
@apply my-0 mx-6 !important;
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import {AtomicInsightStore} from '../atomic-insight-interface/store';
})
export class AtomicInsightResult {
private layout!: ResultLayout;
private resultActionBarElement?: HTMLElement | null;
@Element() host!: HTMLElement;

/**
Expand Down Expand Up @@ -125,14 +124,33 @@ export class AtomicInsightResult {
}

private handleMouseOver = () => {
this.resultActionBarElement?.classList.add('hovered');
this.resultActionBar?.classList.add('showActionBar');
this.host.classList.add('resultHovered');
};

private handleMouseOut = () => {
this.resultActionBarElement?.classList.remove('hovered');
this.resultActionBar?.classList.remove('showActionBar');
this.host.classList.remove('resultHovered');
};

private get resultActionBar() {
return this.host.shadowRoot?.querySelector(
'atomic-insight-result-action-bar'
);
}

private get resultActions() {
return this.host.shadowRoot?.querySelectorAll(
'atomic-insight-result-action'
);
}

private get firstChildActionBar() {
return this.host.parentElement
?.querySelectorAll('atomic-insight-result')[0]
.shadowRoot?.querySelector('atomic-insight-result-action-bar');
}

public render() {
return (
<Host class={resultComponentClass}>
Expand All @@ -149,31 +167,19 @@ export class AtomicInsightResult {
}

public componentDidLoad() {
this.resultActionBarElement = this.host.shadowRoot?.querySelector(
'atomic-insight-result-action-bar'
);
const resultActionElement = this.host.shadowRoot?.querySelectorAll(
'atomic-insight-result-action'
);
if (this.loadingFlag && this.store) {
this.store.unsetLoadingFlag(this.loadingFlag);
}
if (this.resultActionBarElement && resultActionElement?.length) {
this.host.parentElement!.style.padding = '0px';
this.host.parentElement
?.querySelectorAll('atomic-insight-result')[0]
.shadowRoot?.querySelector('atomic-insight-result-action-bar')
?.classList.add('firstActionBarElement');

this.host.classList.add('withActionBar');
if (this.resultActionBar && this.resultActions?.length) {
this.firstChildActionBar?.classList.add('firstActionBarElement');
this.host.addEventListener('mouseover', this.handleMouseOver);
this.host.addEventListener('mouseout', this.handleMouseOut);
}
applyFocusVisiblePolyfill(this.host);
}

public disconnectedCallback() {
if (this.resultActionBarElement) {
if (this.resultActionBar) {
this.host.removeEventListener('mouseover', this.handleMouseOver);
this.host.removeEventListener('mouseout', this.handleMouseOut);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
@import '../styles/list-display.pcss';

.list-root {
padding: 1.5rem 1.5rem 0 1.5rem;
@apply p-0;
}

0 comments on commit 4ee8afb

Please sign in to comment.