Skip to content

Commit 007e755

Browse files
authored
fix(ui5-switch): align 'off' text in RTL, add compact mode params (#7603)
In RTL mode the 'off' icon of `Graphical` type Switch was misaligned due to missing parameters for RTL scenario of the control. Fixes: #7522 Fixes: #7806
1 parent 1660ad4 commit 007e755

File tree

2 files changed

+38
-26
lines changed

2 files changed

+38
-26
lines changed

packages/main/src/themes/Switch.css

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@
114114

115115
.ui5-switch-handle,
116116
.ui5-switch-text {
117-
left: var(--_ui5_switch_handle_left);
117+
inset-inline-start: var(--_ui5_switch_handle_left);
118118
top: 50%;
119119
transform: translateY(-50%);
120120
}
@@ -123,8 +123,8 @@
123123
.ui5-switch-desktop.ui5-switch-root:focus::after {
124124
content: "";
125125
position: absolute;
126-
left: var(--_ui5_switch_root_outline_left);
127-
right: var(--_ui5_switch_root_outline_right);
126+
inset-inline-start: var(--_ui5_switch_root_outline_left);
127+
inset-inline-end: var(--_ui5_switch_root_outline_right);
128128
top: var(--_ui5_switch_root_outline_top);
129129
bottom: var(--_ui5_switch_root_outline_bottom);
130130
border: var(--_ui5_switch_focus_outline);
@@ -137,11 +137,12 @@
137137
/* switch hidden input */
138138
.ui5-switch-root .ui5-switch-input {
139139
position: absolute;
140-
left: 0;
140+
inset-inline-start: 0;
141141
width: 0;
142142
height: 0;
143143
margin: 0;
144144
visibility: hidden;
145+
appearance: none;
145146
-webkit-appearance: none;
146147
}
147148

@@ -160,12 +161,12 @@
160161

161162
.ui5-switch-root.ui5-switch--checked.ui5-switch--semantic .ui5-switch-text--on,
162163
.ui5-switch-root.ui5-switch--checked.ui5-switch-desktop.ui5-switch--no-label .ui5-switch-text--on {
163-
left: var(--_ui5_switch_text_active_left);
164+
inset-inline-start: var(--_ui5_switch_text_active_left);
164165
}
165166
.ui5-switch-root:not(.ui5-switch--checked).ui5-switch--semantic .ui5-switch-text--off,
166167
.ui5-switch-root:not(.ui5-switch--checked).ui5-switch-desktop.ui5-switch--no-label .ui5-switch-text--off {
167-
left: var(--_ui5_switch_text_inactive_left);
168-
right: var(--_ui5_switch_text_inactive_right);
168+
inset-inline-start: var(--_ui5_switch_text_inactive_left);
169+
inset-inline-end: var(--_ui5_switch_text_inactive_right);
169170
}
170171

171172
/* handle */
@@ -337,14 +338,14 @@
337338
color: var(--_ui5_switch_text_active_color);
338339
overflow: var(--_ui5_switch_text_overflow);
339340
text-overflow: ellipsis;
340-
left: var(--_ui5_switch_text_active_left_alternate);
341+
inset-inline-start: var(--_ui5_switch_text_active_left_alternate);
341342
}
342343
.ui5-switch-root .ui5-switch-text--off {
343344
color: var(--_ui5_switch_text_inactive_color);
344345
overflow: var(--_ui5_switch_text_overflow);
345346
text-overflow: ellipsis;
346-
left: var(--_ui5_switch_text_inactive_left_alternate);
347-
right: var(--_ui5_switch_text_inactive_right_alternate);
347+
inset-inline-start: var(--_ui5_switch_text_inactive_left_alternate);
348+
inset-inline-end: var(--_ui5_switch_text_inactive_right_alternate);
348349
}
349350

350351
.ui5-switch-root .ui5-switch-no-label-icon-on,
@@ -364,19 +365,4 @@
364365

365366
[dir="rtl"].ui5-switch-root.ui5-switch--checked .ui5-switch-slider {
366367
transform: var(--_ui5_switch_rtl_transform);
367-
}
368-
369-
[dir="rtl"].ui5-switch-root .ui5-switch-handle {
370-
left: auto;
371-
right: var(--_ui5_switch_handle_left);
372-
}
373-
374-
[dir="rtl"].ui5-switch-root .ui5-switch-text--on {
375-
right: var(--_ui5_switch_text_active_left);
376-
left: var(--_ui5_switch_text_active_right);
377-
}
378-
379-
[dir="rtl"].ui5-switch-root .ui5-switch-text--off {
380-
right: var(--_ui5_switch_text_inactive_left);
381-
left: var(--_ui5_switch_text_inactive_right);
382-
}
368+
}

packages/main/src/themes/sap_horizon_hcb/Switch-parameters.css

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,4 +143,30 @@
143143

144144
--_ui5_switch_icon_width: 1rem;
145145
--_ui5_switch_icon_height: 1rem;
146+
}
147+
148+
[data-ui5-compact-size],
149+
.ui5-content-density-compact,
150+
.sapUiSizeCompact {
151+
--_ui5_switch_width: 3rem;
152+
--_ui5_switch_min_width: none;
153+
--_ui5_switch_with_label_width: 3.75rem;
154+
--_ui5_switch_root_outline_top: 0.25rem;
155+
--_ui5_switch_root_outline_bottom: 0.25rem;
156+
--_ui5_switch_transform: translateX(100%) translateX(-1.375rem);
157+
--_ui5_switch_transform_with_label: translateX(100%) translateX(-1.875rem);
158+
--_ui5_switch_rtl_transform: translateX(1.375rem) translateX(-100%);
159+
--_ui5_switch_rtl_transform_with_label: translateX(1.875rem) translateX(-100%);
160+
--_ui5_switch_track_width: 2rem;
161+
--_ui5_switch_track_height: 1.25rem;
162+
--_ui5_switch_track_with_label_width: 2.75rem;
163+
--_ui5_switch_track_with_label_height: 1.25rem;
164+
--_ui5_switch_handle_width: 1.25rem;
165+
--_ui5_switch_handle_height: 1rem;
166+
--_ui5_switch_handle_with_label_width: 1.75rem;
167+
--_ui5_switch_handle_with_label_height: 1rem;
168+
--_ui5_switch_text_font_size: var(--sapFontSize);
169+
--_ui5_switch_text_width: 1rem;
170+
--_ui5_switch_text_active_left: 0.1875rem;
171+
--_ui5_switch_text_active_left_alternate: 0.0625rem;
146172
}

0 commit comments

Comments
 (0)