Skip to content

Commit 0487420

Browse files
committed
compact cozy
1 parent b91f247 commit 0487420

File tree

5 files changed

+54
-25
lines changed

5 files changed

+54
-25
lines changed

packages/main/src/TreeListItem.hbs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{{>include "./ListItem.hbs"}}
22

33
{{#*inline "listItemPreContent"}}
4-
<div class="ui5-li-tree-toggle-box" style="{{styles.toggleBox}}">
4+
<div class="ui5-li-tree-toggle-box" style="padding-left: {{effectiveLevel}}rem; padding-left: calc(var(--_ui5-tree-indent-step) * {{effectiveLevel}});">
55
{{#if showToggleButton}}
66
<ui5-icon
77
class="ui5-li-tree-toggle-icon"

packages/main/src/TreeListItem.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -154,14 +154,14 @@ class TreeListItem extends ListItem {
154154
await Icon.define();
155155
}
156156

157-
get styles() {
158-
const indent = this.level * 0.5;
157+
get classes() {
158+
const allClasses = super.classes;
159+
allClasses.main["ui5-li-root-tree"] = true;
160+
return allClasses;
161+
}
159162

160-
return {
161-
toggleBox: {
162-
"padding-left": `${indent}rem`,
163-
},
164-
};
163+
get effectiveLevel() {
164+
return this.level - 1;
165165
}
166166

167167
get hasParent() {

packages/main/src/themes/TreeListItem.css

+18-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,25 @@
22
display: block;
33
}
44

5+
.ui5-li-root-tree {
6+
padding-left: 0;
7+
}
8+
59
.ui5-li-tree-toggle-box {
6-
width: 1rem;
7-
margin-right: 0.5rem;
10+
width: var(--_ui5-tree-toggle-box-width);
11+
height: var(--_ui5-tree-toggle-box-height);
12+
display: flex;
13+
align-items: center;
14+
justify-content: center;
15+
}
16+
17+
.ui5-li-tree-toggle-icon {
18+
width: var(--_ui5-tree-toggle-icon-size);
19+
height: var(--_ui5-tree-toggle-icon-size);
20+
}
21+
22+
:host([actionable]) .ui5-li-tree-toggle-icon {
23+
color: var(--sapButton_TextColor);
824
}
925

1026
:host([active][actionable]) .ui5-li-tree-toggle-icon {

packages/main/src/themes/base/sizes-parameters.css

+13-14
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
--_ui5_calendar_header_arrow_button_width: 2.5rem;
55
--_ui5_calendar_header_padding: 0.25rem 0;
66
--_ui5_checkbox_root_side_padding: .6875rem;
7-
--_ui5_checkbox_root_side_padding: .6875rem;
87
--_ui5_checkbox_icon_size: 1rem;
98
--_ui5_custom_list_item_height: 3rem;
109
--_ui5_custom_list_item_rb_min_width: 3rem;
@@ -59,6 +58,12 @@
5958

6059
/* Responsive Popover */
6160
--_ui5-responnsive_popover_header_height: 2.75rem;
61+
62+
/* Tree */
63+
--_ui5-tree-indent-step: 1.5rem;
64+
--_ui5-tree-toggle-box-width: 2.75rem;
65+
--_ui5-tree-toggle-box-height: 2.25rem;
66+
--_ui5-tree-toggle-icon-size: 1.0625rem;
6267
}
6368

6469
[data-ui5-compact-size],
@@ -74,26 +79,14 @@
7479
--_ui5_calendar_header_arrow_button_width: 2rem;
7580

7681
/* CheckBox */
77-
--_ui5_checkbox_wrapper_padding: 0;
78-
--_ui5_checkbox_root_side_padding: var(--_ui5_checkbox_wrapped_focus_padding);
7982
--_ui5_checkbox_root_side_padding: var(--_ui5_checkbox_wrapped_focus_padding);
8083
--_ui5_checkbox_wrapped_content_margin_top: var(--_ui5_checkbox_compact_wrapped_label_margin_top);
8184
--_ui5_checkbox_wrapped_focus_left_top_bottom_position: var(--_ui5_checkbox_compact_focus_position);
8285
--_ui5_checkbox_width_height: var(--_ui5_checkbox_compact_width_height);
83-
--_ui5_checkbox_width_height: var(--_ui5_checkbox_compact_width_height);
8486
--_ui5_checkbox_wrapper_padding: var(--_ui5_checkbox_compact_wrapper_padding);
8587
--_ui5_checkbox_focus_position: var(--_ui5_checkbox_compact_focus_position);
86-
--_ui5_checkbox_focus_position: var(--_ui5_checkbox_compact_focus_position);
87-
--_ui5_checkbox_focus_position: var(--_ui5_checkbox_compact_focus_position);
88-
--_ui5_checkbox_focus_position: var(--_ui5_checkbox_compact_focus_position);
89-
--_ui5_checkbox_inner_width_height: var(--_ui5_checkbox_compact_inner_size);
9088
--_ui5_checkbox_inner_width_height: var(--_ui5_checkbox_compact_inner_size);
91-
--_ui5_checkbox_inner_width_height: var(--_ui5_checkbox_compact_inner_size);
92-
--_ui5_checkbox_inner_width_height: var(--_ui5_checkbox_compact_inner_size);
93-
--_ui5_checkbox_wrapper_padding: var(--_ui5_checkbox_compact_wrapper_padding);
9489
--_ui5_checkbox_icon_size: .75rem;
95-
--_ui5_checkbox_wrapper_padding: var(--_ui5_checkbox_compact_wrapper_padding);
96-
--_ui5_checkbox_focus_position: var(--_ui5_checkbox_compact_focus_position);
9790

9891

9992
/* Custom List Item */
@@ -182,4 +175,10 @@
182175

183176
/* Responsive Popover */
184177
--_ui5-responnsive_popover_header_height: 2.5rem;
185-
}
178+
179+
/* Tree */
180+
--_ui5-tree-indent-step: 0.5rem;
181+
--_ui5-tree-toggle-box-width: 2rem;
182+
--_ui5-tree-toggle-box-height: 1.5rem;
183+
--_ui5-tree-toggle-icon-size: 0.8125rem;
184+
}

packages/main/test/pages/Tree.html

+15-1
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,12 @@
4242
</style>
4343
</head>
4444

45-
<body style="background-color: var(--sapBackgroundColor);">
45+
<body style="padding: 5px; background-color: var(--sapBackgroundColor);">
4646

47+
<ui5-segmentedbutton id="density">
48+
<ui5-togglebutton pressed>Cozy</ui5-togglebutton>
49+
<ui5-togglebutton>Compact</ui5-togglebutton>
50+
</ui5-segmentedbutton>
4751

4852
<br><br>
4953

@@ -105,6 +109,16 @@
105109
</ui5-tree>
106110

107111
<script>
112+
113+
document.getElementById("density").addEventListener("selectionChange", function(event) {
114+
var selectedButton = event.detail.selectedButton;
115+
if (selectedButton.textContent === "Compact") {
116+
document.body.classList.add("sapUiSizeCompact");
117+
} else {
118+
document.body.classList.remove("sapUiSizeCompact");
119+
}
120+
});
121+
108122
document.getElementById("tree").addEventListener("itemClick", function(event) {
109123
console.log("Item clicked: ", event.detail.item);
110124
});

0 commit comments

Comments
 (0)