Skip to content

Commit 6bff641

Browse files
committed
add LTR or RTL selector in customization palette
1 parent 0c966b5 commit 6bff641

File tree

3 files changed

+47
-1
lines changed

3 files changed

+47
-1
lines changed

app/Http/Middleware/Theme.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ public function handle($request, Closure $next): mixed
2626
}
2727
}
2828

29+
// Set HTML direction if exists in session
30+
if (Session::has('backpack.ui.html_direction')) {
31+
Config::set('backpack.ui.html_direction', Session::get('backpack.ui.html_direction'));
32+
}
33+
2934
return $next($request);
3035
}
3136
}

resources/views/vendor/backpack/theme-tabler/inc/topbar_right_content.blade.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,30 @@
222222
</div>
223223
</div>
224224

225+
<div id="tabler-direction-selection" class="mb-3">
226+
<p>Choose the text <strong>direction</strong> for your admin panel:</p>
227+
<div class="row">
228+
<div class="col-lg-6 col-md-6 mb-3">
229+
<label class="form-selectgroup-item cursor-pointer">
230+
<input @if(Session::get('backpack.ui.html_direction', config('backpack.ui.html_direction', 'ltr')) === 'ltr') checked @endif type="radio" name="direction" value="ltr" class="form-selectgroup-input">
231+
<div class="form-selectgroup-label border rounded p-3">
232+
<div class="form-selectgroup-title fw-bold mb-1">LTR</div>
233+
<small class="text-muted">Left to Right (Default)</small>
234+
</div>
235+
</label>
236+
</div>
237+
<div class="col-lg-6 col-md-6 mb-3">
238+
<label class="form-selectgroup-item cursor-pointer">
239+
<input @if(Session::get('backpack.ui.html_direction', config('backpack.ui.html_direction', 'ltr')) === 'rtl') checked @endif type="radio" name="direction" value="rtl" class="form-selectgroup-input">
240+
<div class="form-selectgroup-label border rounded p-3">
241+
<div class="form-selectgroup-title fw-bold mb-1">RTL</div>
242+
<small class="text-muted">Right to Left</small>
243+
</div>
244+
</label>
245+
</div>
246+
</div>
247+
</div>
248+
225249
<div id="tabler-styles-selection" class="mb-3">
226250
<p>Choose which <strong>skins</strong> to apply on top of the Tabler theme:</p>
227251
<div class="row">
@@ -289,22 +313,29 @@
289313
if (selectedTheme === 'tabler') {
290314
layoutSelection.slideDown();
291315
stylesSelection.slideDown();
316+
directionSelection.slideDown();
292317
} else {
293318
// Hide layout and styles options for CoreUI themes (coreuiv2, coreuiv4)
294319
layoutSelection.slideUp();
295320
stylesSelection.slideUp();
321+
directionSelection.slideUp();
296322
}
297323
});
298324
325+
// Get direction selection element
326+
const directionSelection = $('#tabler-direction-selection');
327+
299328
// Also handle the case when modal is opened - ensure correct initial state
300329
$('#modal-layout').on('shown.bs.modal', function () {
301330
const checkedTheme = $('.theme-choice:checked').val();
302331
if (checkedTheme === 'tabler') {
303332
layoutSelection.show();
304333
stylesSelection.show();
334+
directionSelection.show();
305335
} else {
306336
layoutSelection.hide();
307337
stylesSelection.hide();
338+
directionSelection.hide();
308339
}
309340
});
310341
</script>

routes/backpack/custom.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,17 @@
7474
Alert::success("Applied {$styleCount} style(s)")->flash();
7575
}
7676

77-
Session::put('backpack.theme-tabler.styles', $selectedStyles);
77+
// Handle direction selection
78+
if ($request->has('direction')) {
79+
$direction = $request->get('direction', 'ltr');
80+
// if the direction has changed, let's show a success message
81+
if (Session::get('backpack.ui.html_direction') !== $direction) {
82+
Alert::success('Now using direction: ' . $direction)->flash();
83+
}
84+
Session::put('backpack.ui.html_direction', $direction);
85+
}
86+
87+
Session::put('backpack.theme-tabler.styles', $selectedStyles);
7888
}
7989

8090
return Redirect::back();

0 commit comments

Comments
 (0)