This commit is contained in:
Dr Masroor Ehsan 2025-01-02 21:48:10 +06:00
parent 8ad61a9e75
commit d3994c5a00
6 changed files with 85 additions and 21 deletions

View File

@ -10,10 +10,10 @@ class ThemeHelper
public static function appClasses(): array
{
$data = config('custom.custom');
$data = config('theme.custom');
// default data array
$DefaultData = [
$defaultData = [
'myLayout' => 'vertical',
'myTheme' => 'theme-default',
'myStyle' => 'light',
@ -44,7 +44,7 @@ public static function appClasses(): array
];
// if any key missing of array from custom.php file it will be merge and set a default value from dataDefault array and store in data variable
$data = array_merge($DefaultData, $data);
$data = array_merge($defaultData, $data);
// All options available in the template
$allOptions = [
@ -70,8 +70,8 @@ public static function appClasses(): array
// if myLayout value empty or not match with default options in custom.php config file then set a default value
foreach ($allOptions as $key => $value) {
if (array_key_exists($key, $DefaultData)) {
if (gettype($DefaultData[$key]) === gettype($data[$key])) {
if (array_key_exists($key, $defaultData)) {
if (gettype($defaultData[$key]) === gettype($data[$key])) {
// data key should be string
if (is_string($data[$key])) {
// data key should not be empty
@ -81,16 +81,16 @@ public static function appClasses(): array
// ensure that passed value should be match with any of allOptions array value
$result = array_search($data[$key], $value, 'strict');
if (empty($result) && $result !== 0) {
$data[$key] = $DefaultData[$key];
$data[$key] = $defaultData[$key];
}
}
} else {
// if data key not set or
$data[$key] = $DefaultData[$key];
$data[$key] = $defaultData[$key];
}
}
} else {
$data[$key] = $DefaultData[$key];
$data[$key] = $defaultData[$key];
}
}
}
@ -98,7 +98,7 @@ public static function appClasses(): array
$styleUpdatedVal = $data['myStyle'] == 'dark' ? 'dark' : $data['myStyle'];
// Determine if the layout is admin or front based on cookies
$layoutName = $data['myLayout'];
$isAdmin = Str::contains($layoutName, 'front') ? false : true;
$isAdmin = ! Str::contains($layoutName, 'front');
$modeCookieName = $isAdmin ? 'admin-mode' : 'front-mode';
$colorPrefCookieName = $isAdmin ? 'admin-colorPref' : 'front-colorPref';
@ -143,7 +143,7 @@ public static function appClasses(): array
];
// sidebar Collapsed
if ($layoutClasses['menuCollapsed'] == true) {
if ($layoutClasses['menuCollapsed']) {
$layoutClasses['menuCollapsed'] = 'layout-menu-collapsed';
}
@ -161,17 +161,17 @@ public static function appClasses(): array
}
// Menu Fixed
if ($layoutClasses['menuFixed'] == true) {
if ($layoutClasses['menuFixed']) {
$layoutClasses['menuFixed'] = 'layout-menu-fixed';
}
// Footer Fixed
if ($layoutClasses['footerFixed'] == true) {
if ($layoutClasses['footerFixed']) {
$layoutClasses['footerFixed'] = 'layout-footer-fixed';
}
// Menu Flipped
if ($layoutClasses['menuFlipped'] == true) {
if ($layoutClasses['menuFlipped']) {
$layoutClasses['menuFlipped'] = 'layout-menu-flipped';
}
@ -181,12 +181,12 @@ public static function appClasses(): array
// }
// RTL Supported template
if ($layoutClasses['rtlSupport'] == true) {
if ($layoutClasses['rtlSupport']) {
$layoutClasses['rtlSupport'] = '/rtl';
}
// RTL Layout/Mode
if ($layoutClasses['rtlMode'] == true) {
if ($layoutClasses['rtlMode']) {
$layoutClasses['rtlMode'] = 'rtl';
$layoutClasses['textDirection'] = isset($_COOKIE['direction']) ? ($_COOKIE['direction'] === 'true' ? 'rtl' : 'ltr') : 'rtl';
@ -197,14 +197,14 @@ public static function appClasses(): array
}
// Show DropdownOnHover for Horizontal Menu
if ($layoutClasses['showDropdownOnHover'] == true) {
if ($layoutClasses['showDropdownOnHover']) {
$layoutClasses['showDropdownOnHover'] = true;
} else {
$layoutClasses['showDropdownOnHover'] = false;
}
// To hide/show display customizer UI, not js
if ($layoutClasses['displayCustomizer'] == true) {
if ($layoutClasses['displayCustomizer']) {
$layoutClasses['displayCustomizer'] = true;
} else {
$layoutClasses['displayCustomizer'] = false;

View File

@ -4,4 +4,5 @@
App\Providers\AppServiceProvider::class,
App\Providers\FortifyServiceProvider::class,
App\Providers\JetstreamServiceProvider::class,
App\Providers\MenuServiceProvider::class,
];

34
config/theme.php Normal file
View File

@ -0,0 +1,34 @@
<?php
// Custom Config
// -------------------------------------------------------------------------------------
// ! IMPORTANT: Make sure you clear the browser local storage In order to see the config changes in the template.
// ! To clear local storage: (https://www.leadshook.com/help/how-to-clear-local-storage-in-google-chrome-browser/).
return [
'custom' => [
'myLayout' => 'vertical', // Options[String]: vertical(default), horizontal
'myTheme' => 'theme-default', // Options[String]: theme-default(default), theme-bordered, theme-semi-dark
'myStyle' => 'light', // Options[String]: light(default), dark & system mode
'myRTLSupport' => true, // options[Boolean]: true(default), false // To provide RTLSupport or not
'myRTLMode' => false, // options[Boolean]: false(default), true // To set layout to RTL layout (myRTLSupport must be true for rtl mode)
'hasCustomizer' => true, // options[Boolean]: true(default), false // Display customizer or not THIS WILL REMOVE INCLUDED JS FILE. SO LOCAL STORAGE WON'T WORK
'displayCustomizer' => true, // options[Boolean]: true(default), false // Display customizer UI or not, THIS WON'T REMOVE INCLUDED JS FILE. SO LOCAL STORAGE WILL WORK
'contentLayout' => 'compact', // options[String]: 'compact', 'wide' (compact=container-xxl, wide=container-fluid)
'navbarType' => 'sticky', // options[String]: 'sticky', 'static', 'hidden' (Only for vertical Layout)
'footerFixed' => false, // options[Boolean]: false(default), true // Footer Fixed
'menuFixed' => true, // options[Boolean]: true(default), false // Layout(menu) Fixed (Only for vertical Layout)
'menuCollapsed' => false, // options[Boolean]: false(default), true // Show menu collapsed, (Only for vertical Layout)
'headerType' => 'fixed', // options[String]: 'static', 'fixed' (for horizontal layout only)
'showDropdownOnHover' => true, // true, false (for horizontal layout only)
'customizerControls' => [
'rtl',
'style',
'headerType',
'contentLayout',
'layoutCollapsed',
'layoutNavbarOptions',
'themes',
], // To show/hide customizer options
],
];

29
config/variables.php Normal file
View File

@ -0,0 +1,29 @@
<?php
// Variables
return [
'creatorName' => 'Dr. Masroor Ehsan',
'creatorUrl' => 'https://google.com',
'templateName' => 'RadSparc',
'templateSuffix' => 'RadSparc PACS',
'templateVersion' => '2.0.1',
'templateFree' => false,
'templateDescription' => 'RadSparc is the most developer friendly & highly customizable Admin Dashboard Template.',
'templateKeyword' => 'dashboard, material, material design, bootstrap 5 dashboard, bootstrap 5 design, bootstrap 5',
'licenseUrl' => 'https://themeforest.net/licenses/standard',
'livePreview' => 'https://pixinvent.com/materialize-bootstrap-laravel-admin-template/',
'productPage' => 'https://1.envato.market/materialize_admin',
'support' => 'https://pixinvent.ticksy.com/',
'moreThemes' => 'https://1.envato.market/pixinvent_portfolio',
'documentation' => 'https://demos.pixinvent.com/materialize-html-admin-template/documentation',
'generator' => '',
'changelog' => 'https://demos.pixinvent.com/materialize/changelog.html',
'repository' => 'https://github.com/pixinvent/materialize-html-laravel-admin-template',
'gitRepo' => 'materialize-html-laravel-admin-template',
'gitRepoAccess' => 'https://tools.pixinvent.com/github/github-access',
'facebookUrl' => 'https://www.facebook.com/pixinvents/',
'twitterUrl' => 'https://twitter.com/pixinvents',
'githubUrl' => 'https://github.com/pixinvent',
'dribbbleUrl' => 'https://dribbble.com/pixinvent',
'instagramUrl' => 'https://www.instagram.com/pixinvents/',
];

View File

@ -1,5 +1,5 @@
@php
$configData = Helper::appClasses();
$configData = \App\Services\ThemeHelper::appClasses();
$customizerHidden = 'customizer-hide';
@endphp

View File

@ -1,5 +1,5 @@
@php
$configData = Helper::appClasses();
$configData = \App\Services\ThemeHelper::appClasses();
$customizerHidden = 'customizer-hide';
@endphp