Skip to content
32 changes: 32 additions & 0 deletions QualityControl/public/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -155,3 +155,35 @@
.cursor-pointer {
cursor: pointer;
}

.header-layout {
&.edit {
display: flex;
}

/*
* Hack to center content: `justify-content: center` fails with `overflow-x: auto`
* (see https://stackoverflow.com/questions/62288432/problem-when-using-with-overflow-x-scroll-and-justify-content-center).
* Adding flex: 1 auto-margins on ::before/::after centers the content correctly for scrolling.
*/
&::after,
&::before {
content: '';
flex: 1;
}
}

.header-layout-tabs {
display: flex;
overflow-x: auto;
overflow-y: hidden;
padding-bottom: 2px;
}

.flex-fixed {
flex: 0 0 auto;
}

.whitespace-nowrap {
white-space: nowrap;
}
3 changes: 2 additions & 1 deletion QualityControl/public/common/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,15 @@ import { filtersPanel } from './filters/filterViews.js';
*/
export default (model) => {
const specific = headerSpecific(model) || {};
const { centerCol, rightCol } = specific;
const { centerCol, rightCol, subRow } = specific;

return h('.flex-col', [
h('.flex-row.p2.items-center', { id: 'qcg-header' }, [
commonHeader(model),
centerCol || h('.flex-grow'),
rightCol || h('.w-25'),
]),
subRow && h('.p2', [subRow]),
filterSpecific(model),
]);
};
Expand Down
25 changes: 14 additions & 11 deletions QualityControl/public/layout/view/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,21 @@ const toolbarViewMode = (layout, filterModel) => {
const { isOfficial, owner_id, name } = layoutItem;

return {
centerCol: h('.flex-grow.text-center', [h('.header-layout', [tabViewLinks(layoutItem, layout)])]),
centerCol: h('b.f4.items-center.flex-grow.text-center', [isOfficial ? iconBadge() : '', layoutItem.name]),
rightCol: h('.w-25.text-right.g2.flex-row.justify-end.flex-wrap', [
h('b.f4.items-center', [isOfficial ? iconBadge() : '', layoutItem.name]),
' ',
filterPanelToggleButton(filterModel),
h('.btn-group.flex-wrap', [
' ',
newLayoutButton(layout),
jsonExportButton(layoutItem, name),
layout.ownsLayout(owner_id) && [editDropdown(layout), deleteButton(layout)],
]),
]),
subRow: h(
'.flex-grow.text-center',
[h('.header-layout.header-layout-tabs', [tabViewLinks(layoutItem, layout)])],
),
};
};

Expand All @@ -75,7 +79,7 @@ const toolbarViewModeTab = (layout, tab, i) => {
const selectTab = () => layout.selectTab(i);

return [
h('button.br-pill.ph2.btn.btn-tab', { id: `tab-${i}`, class: linkClass, onclick: selectTab }, tab.name),
h('button.br-pill.ph2.btn.btn-tab.flex-fixed', { id: `tab-${i}`, class: linkClass, onclick: selectTab }, tab.name),
' ',
];
};
Expand All @@ -91,9 +95,9 @@ const toolbarEditMode = (layout) => {
};

return {
centerCol: h('.flex-grow.text-center', [
h('div', { class: 'header-layout' }, [
h('span', editTabLinks(layout)),
subRow: h('.flex-grow.text-center', [
h('.header-layout.edit', [
h('span.header-layout-tabs', editTabLinks(layout)),
h('.btn-group', [
tabBtn({
title: 'Add new tab to this layout',
Expand All @@ -108,7 +112,7 @@ const toolbarEditMode = (layout) => {
]),
]),
]),
rightCol: h('.w-33.text-right.flex-row.justify-end', [
rightCol: h('.w-25.text-right.flex-row.justify-end', [
h('input.form-control.form-inline', {
type: 'text',
value: layout.item.name,
Expand Down Expand Up @@ -140,8 +144,8 @@ const toolbarEditModeTab = (layout, tab, i) => {
const selectTab = () => layout.selectTab(i);

return [
h('.btn-group', [
h('button.br-pill.ph2.btn.btn-tab', { class: linkClass, onclick: selectTab }, tab.name),
h('.btn-group.flex-fixed', [
h('button.br-pill.ph2.btn.btn-tab.whitespace-nowrap', { class: linkClass, onclick: selectTab }, tab.name),
selected && [
editTabButton(layout, linkClass, tab, i),
resizeGridTabDropDown(layout, tab),
Expand All @@ -159,8 +163,7 @@ const toolbarEditModeTab = (layout, tab, i) => {
* @returns {vnode} - virtual node element
*/
const resizeGridTabDropDown = (layout, tab) =>
h('select.form-control.select-tab', {
style: 'cursor: pointer',
h('select.form-control.select-tab.cursor-pointer', {
title: 'Resize grid of the tab',
onchange: (e) => layout.resizeGridByXY(e.target.value),
}, [1, 2, 3, 4, 5].map((i) =>
Expand Down
Loading