Skip to content

Commit b7b5581

Browse files
authored
ui: Grid: Added indentation and chevrons to grid cells (#3901)
This change adds a new feature to `GridCell`s which allows indentations and expand/collapse chevrons to be injected. Note: This doesn't manage data-loading or even storing the collapsed/expanded states, it simply provides the raw building blocks that can be used to build tree-like components based on `Grid`. Example screenshot from the demo page: <img width="622" height="529" alt="image" src="https://github.com/user-attachments/assets/cb3188a5-a807-4f2a-be8e-f8e94cba5656" />
1 parent 4874bcc commit b7b5581

File tree

3 files changed

+556
-40
lines changed

3 files changed

+556
-40
lines changed

ui/src/assets/widgets/grid.scss

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ $border-2: 1px solid var(--pf-color-border-secondary);
1919
$border-3: 2px solid var(--pf-color-border);
2020
$inline-padding: 0.5em;
2121
$block-padding: 0.3em;
22+
$indent-size: 16px;
23+
$indent-guide-offset: 12px;
2224

2325
.pf-grid-header-cell {
2426
display: flex;
@@ -73,17 +75,32 @@ $block-padding: 0.3em;
7375
.pf-grid-cell {
7476
display: flex;
7577
flex-direction: row;
78+
align-items: baseline;
79+
overflow: hidden;
7680
--pf-cell-padding-block: 0;
7781
--pf-cell-padding-inline: 0;
82+
--pf-grid-cell-indent: 0;
7883

7984
&__menu-button {
8085
// Eliminate the extra space between the menu button and the cell content added by the content padding.
8186
margin-left: calc(-1 * var(--pf-cell-padding-inline));
8287
}
8388

89+
&__indent {
90+
flex-shrink: 0;
91+
}
92+
93+
&__chevron {
94+
flex-shrink: 0;
95+
margin-right: calc(var(--pf-cell-padding-inline) * -1);
96+
97+
&--leaf {
98+
visibility: hidden;
99+
}
100+
}
101+
84102
&__content {
85103
flex: 1 1 auto;
86-
87104
padding: var(--pf-cell-padding-block) var(--pf-cell-padding-inline);
88105
align-items: baseline;
89106
overflow: hidden;
@@ -97,15 +114,14 @@ $block-padding: 0.3em;
97114
}
98115

99116
&--align-right {
100-
// Move the menu button to the left when right-aligned.
101-
flex-direction: row-reverse;
102-
103117
.pf-grid-cell__menu-button {
104118
margin-left: 0;
105119
margin-right: calc(-1 * var(--pf-cell-padding-inline));
120+
order: 2;
106121
}
107122

108123
.pf-grid-cell__content {
124+
order: 3;
109125
text-align: right;
110126
}
111127
}

0 commit comments

Comments
 (0)