yepsua/filament-themes
Composer 安装命令:
composer require yepsua/filament-themes
包简介
Manage filament themes from the config files
README 文档
README
Configurable theme manager for filament.
We recommend reading the official documentation about how to create themes on the Filament web site
Features
- Change the filament theme color from the config file.
- Supports Mix and Vite bundlers
Installation
You can install the package via composer:
composer require yepsua/filament-themes
You can publish the config file with:
php artisan vendor:publish --tag="yepsua-filament-themes-config"
Usage
Notice: The next steps assume the .css file is located in the folder '/resources/css/app.css' but you can change the name and location of this file, just take into account if you copy and paste some code on this guide.
- Install the assets from the plugin:
php artisan vendor:publish --tag="yepsua-filament-themes-assets"
- Configure the tailwind resource using css variables:
tailwind.config.js:
const colors = require('tailwindcss/colors') const defaultTheme = require('tailwindcss/defaultTheme') function withOpacityValue(variable) { return ({ opacityValue }) => { if (opacityValue === undefined) { return `rgb(var(${variable}))` } return `rgb(var(${variable}) / ${opacityValue})` } } module.exports = { content: [ './resources/**/*.blade.php', './vendor/filament/**/*.blade.php', ], darkMode: 'class', theme: { extend: { colors: { primary: { '50': withOpacityValue('--color-primary-50'), '100': withOpacityValue('--color-primary-100'), '200': withOpacityValue('--color-primary-200'), '300': withOpacityValue('--color-primary-300'), '400': withOpacityValue('--color-primary-400'), '500': withOpacityValue('--color-primary-500'), '600': withOpacityValue('--color-primary-600'), '700': withOpacityValue('--color-primary-700'), '800': withOpacityValue('--color-primary-800'), '900': withOpacityValue('--color-primary-900') }, danger: colors.red, success: colors.green, warning: colors.amber, }, fontFamily: { sans: ['DM Sans', ...defaultTheme.fontFamily.sans], }, }, }, plugins: [ require('@tailwindcss/forms'), require('@tailwindcss/typography'), ], }
- Make sure you have in your
resources/css/app.cssthe next content:
resources/css/app.css:
@import './../../vendor/filament/filament/resources/css/app.css';
Steps for Laravel Mix
- Configure the postCss in the webpack.mix.js to use tailwindcss and autoprefixer
webpack.mix.js:
... mix.js('resources/js/app.js', 'public/js') .postCss('resources/css/app.css', 'public/css', [ require('tailwindcss'), require('autoprefixer'), ]); ...
Steps for Laravel Vite
- If you are using vite instead of mix, you must set 'enable_vite' to true. The 'theme_public_path' will be rendered using vite() instead of mix()
config/filament-themes.php
[
...
'enable_vite' => true,
...
]
- Configure the postCss in the postcss.config.js to use tailwindcss and autoprefixer
postcss.config.js:
module.exports = { plugins: { tailwindcss: {}, autoprefixer: {}, }, };
- Configure the vite.config.js
vite.config.js
import { defineConfig } from 'vite'; import laravel from 'laravel-vite-plugin'; export default defineConfig({ plugins: [ laravel({ input: [ 'resources/css/app.css', 'resources/js/app.js' ], refresh: true, }), ], });
Last steps
- Update the config file to change the theme color:
config/filament-themes.php:
[
...
'color_public_path' => 'vendor/yepsua-filament-themes/css/red.css',
...
]
Available colors (based on the tailwind color pallet):
- slate: slate.css
- gray: gray.css
- zinc: zinc.css
- neutral neutral.css
- stone: stone.css
- red: red.css
- orange: orange.css
- amber: amber.css
- yellow: yellow.css
- lime: lime.css
- green: green.css
- emerald: emerald.css
- teal: teal.css
- cyan: cyan.css
- sky: sky.css
- blue: blue.css
- indigo: indigo.css
- violet: violet.css
- purple: purple.css
- fuchsia: fuchsia.css
- pink: pink.css
- rose: rose.css
- Compile the assets
npm run dev
__
Now, you should see the app using the color defined in your config file. You can change the color without recompiling the resources, just updating the config file.
Notice: The theme manager uses the Mix or Vite to import the css resources. If you need to change the default behavior, you can do it by the next way:
-
Disable the auto_register in the config file
filament-themes.php: -
Register the theme inside your AppServiceProvider
use Yepsua\Filament\Themes\Facades\FilamentThemes; public function boot() { ... FilamentThemes::register(function($path) { // Using Vite: return app(\Illuminate\Foundation\Vite::class)('resources/' . $path); // Using Mix: return app(\Illuminate\Foundation\Mix::class)($path); // Using asset() return asset($path); }); ... }
Notice:
Finally, as you can see, you don't need a package to get this functionality, You just need to configure tailwind using css variables and add new styles defining the primary color variables, however just installing this plugin is pretty easy to manage the themes colors from a config file.
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.
yepsua/filament-themes 适用场景与选型建议
yepsua/filament-themes 是一款 基于 CSS 开发的 Composer 扩展包,目前已累计 24.35k 次下载、GitHub Stars 达 33, 最近一次更新时间为 2022 年 05 月 02 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「themes」 「laravel」 「filament」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 yepsua/filament-themes 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 yepsua/filament-themes 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 yepsua/filament-themes 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Laravel Themes
WordPress mu-plugin to register the theme directory for the default WordPress themes.
This is twig version of Flow Theme for OXID eShop.
Test theme for Altis DXP, based on Automattic/_s starter theme.
This is a Smarty version of Admin Theme for OXID eShop.
Themes module of YajraCMS.
统计信息
- 总下载量: 24.35k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 33
- 点击次数: 18
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-05-02