Skip to content

Commit

Permalink
Add dracula theme
Browse files Browse the repository at this point in the history
  • Loading branch information
Hasnayeen committed Sep 9, 2023
1 parent 0894a72 commit 8354db7
Show file tree
Hide file tree
Showing 23 changed files with 2,053 additions and 22 deletions.
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,21 +218,25 @@ Next add a new item to the `input` array of `vite.config.js`: `resources/css/awe

## Available Themes

Dracula (dark)

![dracula-dark](https://raw.githubusercontent.com/Hasnayeen/themes/3.x/assets/dracula-dark.png)

Nord (light)

![nord-light](https://raw.githubusercontent.com/Hasnayeen/themes/3.x/resources/dist/images/nord-light.png)
![nord-light](https://raw.githubusercontent.com/Hasnayeen/themes/3.x/assets/nord-light.png)

Nord (dark)

![nord-dark](https://raw.githubusercontent.com/Hasnayeen/themes/3.x/resources/dist/images/nord-dark.png)
![nord-dark](https://raw.githubusercontent.com/Hasnayeen/themes/3.x/assets/nord-dark.png)

Sunset (light)

![sunset-light](https://raw.githubusercontent.com/Hasnayeen/themes/3.x/resources/dist/images/sunset-light.png)
![sunset-light](https://raw.githubusercontent.com/Hasnayeen/themes/3.x/assets/sunset-light.png)

Sunset (dark)

![sunset-dark](https://raw.githubusercontent.com/Hasnayeen/themes/3.x/resources/dist/images/sunset-dark.png)
![sunset-dark](https://raw.githubusercontent.com/Hasnayeen/themes/3.x/assets/sunset-dark.png)

## Upgrading

Expand Down
File renamed without changes
File renamed without changes
Binary file added assets/dracula-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
51 changes: 51 additions & 0 deletions resources/css/dracula.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
@import '../../vendor/filament/filament/resources/css/theme.css';

@config './tailwind.nord.config.js';

body {
@apply !bg-gray-950 !text-white;
}

.fi-main-ctn {
@apply bg-gray-950;
}

.fi-sidebar, .fi-sidebar header {
@apply !bg-primary-950;
}

.fi-sidebar-header {
@apply bg-transparent !ring-0 !shadow-none;
}

.fi-logo {
@apply !text-secondary-500;
}

.fi-topbar nav {
@apply !bg-gray-950 !ring-0 !shadow-none;
}

.fi-sidebar-item a, .fi-sidebar-item svg {
@apply !text-success-200;
}

.fi-sidebar-item-active a {
@apply !bg-gray-950 dark:!text-secondary-500;
}

.fi-sidebar-item-active svg {
@apply !text-secondary-500;
}

.fi-header-heading {
@apply !text-secondary-500;
}

.fi-section-header-heading, .fi-ta-header-heading {
@apply !text-secondary-500;
}

.fi-breadcrumbs li a {
@apply !text-success-500;
}
8 changes: 0 additions & 8 deletions resources/css/nord.css
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,3 @@
.fi-tenant-menu {
@apply rounded-lg mt-4;
}

.fi-btn {
@apply dark:!bg-custom-400 dark:text-black;
}

.fi-btn-label {
@apply text-primary-950 dark:text-black;
}
1 change: 1 addition & 0 deletions resources/dist/dracula.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion resources/dist/nord.css

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions resources/lang/ar/themes.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@
'primary_color_set' => 'تم تعيين اللون الأساسي إلى',
'theme_set_to' => 'تم تعيين الثيم إلى',
'appearance' => 'المظهر',
'no_light_mode' => 'هذا الموضوع لا يدعم الوضع الخفيف',
'no_dark_mode' => 'هذا الموضوع لا يدعم الوضع المظلم',
];
2 changes: 2 additions & 0 deletions resources/lang/en/themes.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@
'primary_color_set' => 'Theme primary color set to',
'theme_set_to' => 'Theme set to',
'appearance' => 'Appearance',
'no_light_mode' => 'This theme does not support light mode.',
'no_dark_mode' => 'This theme does not support dark mode.',
];
3 changes: 3 additions & 0 deletions resources/views/filament/pages/themes-footer.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<p class="pt-4 text-sm font-semibold text-gray-600 dark:text-gray-400 border-t">
Hasnayeen/Themes: {{ \Composer\InstalledVersions::getPrettyVersion('hasnayeen/themes') }}
</p>
24 changes: 18 additions & 6 deletions resources/views/filament/pages/themes.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<label for="custom">{{ __('themes::themes.custom') }}</label>
</div>
@else
<p class="text-gray-700">{{ __('themes::themes.no_changing_primary_color') }}</p>
<p class="text-gray-700 dark:text-gray-400">{{ __('themes::themes.no_changing_primary_color') }}</p>
@endif
</div>
</section>
Expand All @@ -33,7 +33,7 @@
<header class="flex items-center gap-x-3 overflow-hidden py-4">
<div class="grid flex-1 gap-y-1">
<h3 class="fi-section-header-heading text-base font-semibold leading-6 text-gray-950 dark:text-white">
{{ $this->getTitle() }}
{{ __('themes::themes.themes') }}
</h3>

<p class="fi-section-header-description text-sm text-gray-500 dark:text-gray-400">
Expand All @@ -58,15 +58,27 @@
</x-filament::button>
</x-slot>

@php
$noLightMode = in_array(\Hasnayeen\Themes\Contracts\HasOnlyDarkMode::class, class_implements($theme));
$noDarkMode = in_array(\Hasnayeen\Themes\Contracts\HasOnlyLightMode::class, class_implements($theme));
@endphp
<div class="grid grid-cols-2 gap-4">
<div>
<h3 class="text-sm font-semibold text-gray-600 pb-4">{{ __('themes::themes.light') }}</h3>
<img src="{{ asset('vendor/themes/images/'.$name.'-light.png') }}" alt="{{ $name }} theme preview (light version)" class="border dark:border-gray-700 rounded-lg">
@if ($noLightMode)
<h3 class="text-sm font-semibold text-gray-600 pb-4">{{ __('themes::themes.no_light_mode') }}</h3>
@else
<h3 class="text-sm font-semibold text-gray-600 pb-4">{{ __('themes::themes.light') }}</h3>
<img src="{{ url('https://raw.githubusercontent.com/Hasnayeen/themes/3.x/assets/'.$name.'-light.png') }}" alt="{{ $name }} theme preview (light version)" class="border dark:border-gray-700 rounded-lg">
@endif
</div>

<div>
<h3 class="text-sm font-semibold text-gray-600 pb-4">{{ __('themes::themes.dark') }}</h3>
<img src="{{ asset('vendor/themes/images/'.$name.'-dark.png') }}" alt="{{ $name }} theme preview (dark version)" class="border dark:border-gray-700 rounded-lg">
@if ($noDarkMode)
<h3 class="text-sm font-semibold text-gray-600 pb-4">{{ __('themes::themes.no_dark_mode') }}</h3>
@else
<h3 class="text-sm font-semibold text-gray-600 pb-4">{{ __('themes::themes.dark') }}</h3>
<img src="{{ url('https://raw.githubusercontent.com/Hasnayeen/themes/3.x/assets/'.$name.'-dark.png') }}" alt="{{ $name }} theme preview (dark version)" class="border dark:border-gray-700 rounded-lg">
@endif
</div>
</div>
</x-filament::section>
Expand Down
8 changes: 8 additions & 0 deletions src/Contracts/HasOnlyDarkMode.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

namespace Hasnayeen\Themes\Contracts;

interface HasOnlyDarkMode
{

}
8 changes: 8 additions & 0 deletions src/Contracts/HasOnlyLightMode.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

namespace Hasnayeen\Themes\Contracts;

interface HasOnlyLightMode
{

}
6 changes: 6 additions & 0 deletions src/Filament/Pages/Themes.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Filament\Pages\Page;
use Filament\Support\Colors\Color;
use Hasnayeen\Themes\ThemesPlugin;
use Illuminate\Contracts\View\View;
use Illuminate\Contracts\Support\Htmlable;
use Illuminate\Support\Arr;

Expand Down Expand Up @@ -83,4 +84,9 @@ public static function shouldRegisterNavigation(): bool
{
return false;
}

public function getFooter(): ?View
{
return view('themes::filament.pages.themes-footer');
}
}
16 changes: 13 additions & 3 deletions src/Http/Middleware/SetTheme.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@
use Filament\Support\Facades\FilamentAsset;
use Filament\Support\Facades\FilamentColor;
use Hasnayeen\Themes\Contracts\CanModifyPanelConfig;
use Hasnayeen\Themes\Contracts\HasOnlyDarkMode;
use Hasnayeen\Themes\Contracts\HasOnlyLightMode;
use Hasnayeen\Themes\Filament\Pages\Themes as ThemesPage;
use Hasnayeen\Themes\Themes;
use Hasnayeen\Themes\Themes\DefaultTheme;
use Hasnayeen\Themes\Themes\Dracula;
use Hasnayeen\Themes\Themes\Nord;
use Hasnayeen\Themes\Themes\Sunset;
use Hasnayeen\Themes\ThemesPlugin;
Expand All @@ -38,16 +41,23 @@ public function handle(Request $request, Closure $next): Response
->url(ThemesPage::getUrl()),
] : []
);

FilamentColor::register($themes->getCurrentThemeColor());

$currentTheme = $themes->getCurrentTheme();
FilamentAsset::register([
match (get_class($themes->getCurrentTheme())) {
match (get_class($currentTheme)) {
Dracula::class => Css::make(Dracula::getName(), Dracula::getPath()),
Nord::class => Css::make(Nord::getName(), Nord::getPath()),
Sunset::class => Css::make(Sunset::getName(), Sunset::getPath()),
default => Css::make(DefaultTheme::getName(), DefaultTheme::getPath()),
},
], 'hasnayeen/themes');
if ($themes->getCurrentTheme() instanceof CanModifyPanelConfig) {
$themes->getCurrentTheme()->modifyPanelConfig($panel);

$panel->darkMode(! $currentTheme instanceof HasOnlyLightMode, $currentTheme instanceof HasOnlyDarkMode);

if ($currentTheme instanceof CanModifyPanelConfig) {
$currentTheme->modifyPanelConfig($panel);
}

return $next($request);
Expand Down
2 changes: 2 additions & 0 deletions src/Themes.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Hasnayeen\Themes\Contracts\HasChangeableColor;
use Hasnayeen\Themes\Contracts\Theme;
use Hasnayeen\Themes\Themes\DefaultTheme;
use Hasnayeen\Themes\Themes\Dracula;
use Hasnayeen\Themes\Themes\Nord;
use Hasnayeen\Themes\Themes\Sunset;
use Illuminate\Support\Arr;
Expand All @@ -19,6 +20,7 @@ public function __construct()
{
$this->collection = collect([
DefaultTheme::getName() => DefaultTheme::class,
Dracula::getName() => Dracula::class,
Nord::getName() => Nord::class,
Sunset::getName() => Sunset::class,
]);
Expand Down
32 changes: 32 additions & 0 deletions src/Themes/Dracula.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace Hasnayeen\Themes\Themes;

use Hasnayeen\Themes\Contracts\HasOnlyDarkMode;
use Hasnayeen\Themes\Contracts\Theme;

class Dracula implements Theme, HasOnlyDarkMode
{
public static function getName(): string
{
return 'dracula';
}

public static function getPath(): string
{
return __DIR__ . '/../../resources/dist/dracula.css';
}

public function getThemeColor(): array
{
return [
'primary' => '#9580ff',
'custom' => '#6932f5',
'secondary' => '#ff80bf',
'info' => '#80ffea',
'success' => '#8aff80',
'warning' => '#f9f06b',
'danger' => '#ff9580',
];
}
}
Loading

0 comments on commit 8354db7

Please sign in to comment.