Skip to content

Commit

Permalink
add: custom theme color
Browse files Browse the repository at this point in the history
  • Loading branch information
ah-rahimi committed Jan 14, 2023
1 parent 465fb27 commit 6f24fea
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 8 deletions.
3 changes: 2 additions & 1 deletion config/panel.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@

/*
|--------------------------------------------------------------------------
| Panel Title
| Panel Title & Theme Color (hex type)
|--------------------------------------------------------------------------
*/

'title' => "پنل مدیریت",
'theme' => "#2962ff",

/*
|--------------------------------------------------------------------------
Expand Down
15 changes: 9 additions & 6 deletions resources/css/framework.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
}

:root {
--color: 41, 98, 255;
--theme-color: rgb(var(--color));
--theme-color-hover: rgb(var(--color), 0.85);
--theme-color-shadow: rgb(var(--color), 0.55);
Expand Down Expand Up @@ -101,15 +100,19 @@ p {
--bs-btn-disabled-border-color: var(--theme-color-hover);
}

.btn-theme:hover, .btn-theme:active,
.btn-outline-theme:hover, .btn-outline-theme:active {
.btn-theme:hover,
.btn-theme:active,
.btn-outline-theme:hover,
.btn-outline-theme:active {
color: var(--bs-btn-hover-color);
background-color: var(--theme-color);
border-color: var(--theme-color);
}

.btn-theme:focus, .btn-theme:active:focus,
.btn-outline-theme:focus, .btn-outline-theme:active:focus {
.btn-theme:focus,
.btn-theme:active:focus,
.btn-outline-theme:focus,
.btn-outline-theme:active:focus {
color: var(--bs-btn-hover-color);
background-color: var(--theme-color);
border-color: var(--theme-color);
Expand Down Expand Up @@ -170,4 +173,4 @@ p {
to {
transform: rotate(1turn)
}
}
}
2 changes: 1 addition & 1 deletion resources/dist/css/app.css

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions resources/views/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
@endif
{{ $config['title'] }}
</title>

<style>
:root {
--color: {{ $theme }};
}
</style>
</head>

<body>
Expand Down
11 changes: 11 additions & 0 deletions src/Controllers/Makers/Maker.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ protected function handle(array $config)

$this->fixSidebarItems();
$this->fixUserInfo();
$this->handleTheme();
}

private function fixSidebarItems()
Expand Down Expand Up @@ -83,4 +84,14 @@ private function fixUserInfo()
$user->{$params['image']} ?? null
);
}

private function handleTheme()
{
$theme = $this->data['config']['theme'] ?? "#2962ff";
$theme = str_replace('#', '', $theme);

sscanf($theme, "%02x%02x%02x", $r, $g, $b);

$this->data['theme'] = "{$r} {$g} {$b}";
}
}

0 comments on commit 6f24fea

Please sign in to comment.