Skip to content

Commit

Permalink
Enhancements for better wrapping of Status Area icons
Browse files Browse the repository at this point in the history
- WIP, but is working!
- TODOs:
  - Make sure this is a good way to do things.
  - Cleanup code.
  - Tests.
  • Loading branch information
charlesh88 committed Sep 19, 2024
1 parent f06b629 commit 9e15443
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 15 deletions.
24 changes: 20 additions & 4 deletions src/ui/layout/AppLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,20 @@
:class="{
'l-shell__head--expanded': headExpanded,
'l-shell__head--minify-indicators': !headExpanded,
'l-shell__head--indicators-single-line': !indicatorsMultiline
'l-shell__head--indicators-single-line': !indicatorsMultiline,
'--indicators-overflowing': indicatorsOverflowing
}"
>
<CreateButton class="l-shell__create-button" />
<GrandSearch ref="grand-search" />
<StatusIndicators />
<StatusIndicators
:listen-for-overflow="!indicatorsMultiline"
:content-updated="headExpanded || indicatorsMultiline"
@indicators-overflowing="indicatorsOverflowUpdate"
/>
<button
class="l-shell__head__button c-icon-button"
:class="indicatorsMultiline ? 'icon-singleline' : 'icon-multiline'"
class="l-shell__head__button"
:class="[indicatorsMultilineCssClass, indicatorsOverflowingCssClass]"
:aria-label="`Display as ${indicatorsMultiline ? 'single line' : 'multiple lines'}`"
:title="`Display as ${indicatorsMultiline ? 'single line' : 'multiple lines'}`"
@click="toggleIndicatorsMultiline"
Expand Down Expand Up @@ -221,6 +226,7 @@ export default {
triggerReset: false,
headExpanded,
indicatorsMultiline,
indicatorsOverflowing: false,
isResizing: false,
disableClearButton: false
};
Expand All @@ -231,6 +237,12 @@ export default {
},
resizingClass() {
return this.isResizing ? 'l-shell__resizing' : '';
},
indicatorsMultilineCssClass() {
return this.indicatorsMultiline ? 'icon-singleline' : 'icon-multiline';
},
indicatorsOverflowingCssClass() {
return this.indicatorsOverflowing ? 'c-button c-button--major' : 'c-icon-button';
}
},
mounted() {
Expand Down Expand Up @@ -335,6 +347,10 @@ export default {
},
setClearButtonDisabled(isDisabled) {
this.disableClearButton = isDisabled;
},
indicatorsOverflowUpdate(isOverflowing) {
console.log('indicatorsOverflowUpdate', isOverflowing);
this.indicatorsOverflowing = isOverflowing;
}
}
};
Expand Down
4 changes: 4 additions & 0 deletions src/ui/layout/layout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,10 @@
margin-left: auto; // Mimics justify-content: flex-end when in single line mode.
}
}

&.--is-overflowing {
background: rgba(deeppink, 0.1);
}
}

/******************************* MAIN AREA */
Expand Down
52 changes: 41 additions & 11 deletions src/ui/layout/status-bar/StatusIndicators.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,26 @@

<script>
import { shallowRef } from 'vue';
export default {
inject: ['openmct'],
props: {
contentUpdated: {
type: String,
required: true
},
listenForOverflow: {
type: Boolean,
required: false,
default() {
return false;

Check warning on line 44 in src/ui/layout/status-bar/StatusIndicators.vue

View check run for this annotation

Codecov / codecov/patch

src/ui/layout/status-bar/StatusIndicators.vue#L44

Added line #L44 was not covered by tests
}
}
},
emits: ['indicators-overflowing'],
data() {
return {
indicators: this.openmct.indicators.getIndicatorObjectsByPriority().map(shallowRef),
indicatorsOverflowing: false
indicators: this.openmct.indicators.getIndicatorObjectsByPriority().map(shallowRef)
};
},
computed: {
Expand All @@ -46,13 +60,34 @@ export default {
return [...this.indicators].sort((a, b) => b.value.priority - a.value.priority);
}
},
watch: {
contentUpdated() {
// console.log('content updated');
// this.checkOverflow();
}
},
mounted() {
this.checkOverflow();
window.addEventListener('resize', this.checkOverflow);
if (this.listenForOverflow) {
window.addEventListener('load', this.checkOverflow);
window.addEventListener('resize', this.checkOverflow);
}
},
beforeUnmount() {
this.openmct.indicators.off('addIndicator', this.addIndicator);
window.removeEventListener('resize', this.checkOverflow);
if (this.listenForOverflow) {
window.removeEventListener('load', this.checkOverflow);
window.removeEventListener('resize', this.checkOverflow);
}
},
updated() {
// console.log('updated');
if (this.listenForOverflow) {
window.addEventListener('resize', this.checkOverflow);
this.checkOverflow();
} else {
window.removeEventListener('resize', this.checkOverflow);
this.checkOverflow();

Check warning on line 89 in src/ui/layout/status-bar/StatusIndicators.vue

View check run for this annotation

Codecov / codecov/patch

src/ui/layout/status-bar/StatusIndicators.vue#L88-L89

Added lines #L88 - L89 were not covered by tests
}
},
created() {
this.openmct.indicators.on('addIndicator', this.addIndicator);
Expand All @@ -63,12 +98,7 @@ export default {
},
checkOverflow() {
const element = this.$refs.indicators;
const sizes = {
spaceNeeded: element.scrollWidth,
spaceAvail: element.clientWidth
};
this.indicatorsOverflowing = sizes.spaceNeeded > sizes.spaceAvail;
console.log('checkOverflow', this.indicatorsOverflowing, sizes.spaceNeeded, sizes.spaceAvail);
this.$emit('indicators-overflowing', element.scrollWidth > element.clientWidth);
}
}
};
Expand Down

0 comments on commit 9e15443

Please sign in to comment.