Skip to content

Commit

Permalink
Separate grid and table layout styles from item-table
Browse files Browse the repository at this point in the history
  • Loading branch information
raviks789 committed Jun 20, 2023
1 parent b1654ee commit 7e746e2
Show file tree
Hide file tree
Showing 4 changed files with 117 additions and 117 deletions.
14 changes: 8 additions & 6 deletions public/css/common.less
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
padding-right: 0;

.list-item,
.table-row {
.table-layout .table-row {
padding-left: 1em;
padding-right: 1em;
}
Expand Down Expand Up @@ -311,12 +311,14 @@ div.show-more {
}

.item-table {
&.hostgroup-table {
--columns: 2;
}
&.table-layout {
&.hostgroup-table {
--columns: 2;
}

&.servicegroup-table {
--columns: 1;
&.servicegroup-table {
--columns: 1;
}
}

&.user-table, // TODO: make them lists.....
Expand Down
69 changes: 1 addition & 68 deletions public/css/list/item-table.less
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,6 @@

ul.item-table {
list-style-type: none;

li:not(:last-of-type) {
.col {
border-bottom: 1px solid @gray-light;
}

.visual {
border-bottom: 1px solid @default-bg;
}
}
}

div.item-table {
Expand Down Expand Up @@ -54,10 +44,6 @@ div.item-table {

// Layout

.item-table {
--columns: 1;
}

.table-row {
.title {
display: flex;
Expand Down Expand Up @@ -87,70 +73,17 @@ div.item-table {
ul.item-table {
display: grid;

grid-template-columns: 1fr repeat(var(--columns), auto);

> .table-row {
&:not(:last-of-type) .title .visual {
margin-bottom: ~"calc(-.5em - 1px)";
}

.col:not(.title) {
display: grid;
align-items: center;
}

.col {
padding: .5em 0;
}

.col:not(:last-child) {
padding-right: 1em;
}
}
}

ul.item-table {
margin: 0;
padding: 0;

> li {
display: contents;

&:hover,
&.active {
.col, &::before, &::after {
// The li might get a background on hover. Though, this won't be visible
// as it has no box model since we apply display:contents to it.
background-color: inherit;
}
}
}
}

.content.full-width ul.item-table {
// Again, since the li has no box model, it cannot have padding. So the first
// and last child need to get the left and right padding respectively.
// But we don't want to have a border that spans to the very right or left,
// so pseudo elements are required. We could add empty cells instead, but
// that would require hard coding the width here, which I'd like to avoid.

grid-template-columns: ~"auto 1fr repeat(calc(var(--columns) + 1), auto)";

> li.table-row {
&::before, &::after {
display: inline-block;
content: '\00a0';
margin-bottom: 1px;
}

&::before {
padding-left: inherit;
}

&::after {
padding-right: inherit;
}
}
margin: 0;
}

div.item-table {
Expand Down
79 changes: 36 additions & 43 deletions public/css/widget/group-grid.less
Original file line number Diff line number Diff line change
@@ -1,49 +1,42 @@
// HostGroup- and -ServiceGroupGrid styles
.content.full-width {
ul.item-table {
&.group-grid {

margin-left: 1em;
grid-template-columns: repeat(auto-fit, 15em);
column-gap: 2em;

li.group-grid-cell {
.title {
border: unset;
align-items: center;

> .visual {
margin-right: 1em;

.state-badge {
width: 2.5em;
height: 2.5em;
padding: unset;
line-height: 2.5;

&.state-empty {
background-color: @gray-light;
}
}
}

> .content a {
line-height: 2;
display: inline-block;
max-width: 10em;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
text-align: center;
}
}
}

> li.table-row::before,
> li.table-row::after {
padding: unset;
content: unset;
ul.item-table.group-grid {
grid-template-columns: repeat(auto-fit, 15em);
grid-gap: 1em 2em;

.table-row {
margin: -.25em;
padding: .25em;
border-radius: .5em;
}

li.group-grid-cell {
.title {
align-items: center;
}

.visual {
margin-right: 1em;
}

.content {
line-height: 1;

a {
display: inline-block;
max-width: 10em;
text-align: center;
}
}

.state-badge {
width: 2.5em;
height: 2.5em;
line-height: 2;
}
}
}

.content.full-width ul.item-table.group-grid {
margin: 0 1em;
}
72 changes: 72 additions & 0 deletions public/css/widget/table-layout.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
// HostGroup- and -ServiceGroupTable styles

.item-table.table-layout {
--columns: 1;
}

ul.item-table.table-layout {
grid-template-columns: 1fr repeat(var(--columns), auto);

> li {
display: contents;

&:hover,
&.active {
.col, &::before, &::after {
// The li might get a background on hover. Though, this won't be visible
// as it has no box model since we apply display:contents to it.
background-color: inherit;
}
}
}

li:not(:last-of-type) {
.col {
border-bottom: 1px solid @gray-light;
}

.visual {
border-bottom: 1px solid @default-bg;
}
}

> .table-row {
&:not(:last-of-type) .title .visual {
margin-bottom: ~"calc(-.5em - 1px)";
}

.col {
padding: .5em 0;
}

.col:not(:last-child) {
padding-right: 1em;
}
}
}

.content.full-width ul.item-table.table-layout {
// Again, since the li has no box model, it cannot have padding. So the first
// and last child need to get the left and right padding respectively.
// But we don't want to have a border that spans to the very right or left,
// so pseudo elements are required. We could add empty cells instead, but
// that would require hard coding the width here, which I'd like to avoid.

grid-template-columns: ~"auto 1fr repeat(calc(var(--columns) + 1), auto)";

> li.table-row {
&::before, &::after {
display: inline-block;
content: '\00a0';
margin-bottom: 1px;
}

&::before {
padding-left: inherit;
}

&::after {
padding-right: inherit;
}
}
}

0 comments on commit 7e746e2

Please sign in to comment.