neuralglitch / bootstrap-theme-switch
Bootstrap 主题切换包
v0.1.1
2024-05-07 23:32 UTC
Requires
- php: >=8.0
- symfony/config: ^5.4|^6.0|^7.0
- symfony/dependency-injection: ^5.4|^6.0|^7.0
- symfony/framework-bundle: ^5.4|^6.0|^7.0
- symfony/yaml: ^5.4|^6.0|^7.0
Requires (Dev)
README
Bootstrap 5 主题切换器
实现亮、暗和系统默认模式的无缝切换。
安装
按照Symfony 文档中的说明,将我的食谱仓库端点添加到项目中的 composer.json
。
{ "extra": { "symfony": { "endpoint": [ "https://api.github.com/repos/neuralglitch/symfony-recipes/contents/index.json", "flex://defaults" ] } } }
警告
如果不这样做,Composer 将不会使用此包的 Symfony Flex 食谱,您需要遵循这些手动安装说明。
技巧
可能已经在您的 composer.json
中存在 extra.symfony
键。在这种情况下,将 endpoint
键添加到现有的 extra.symfony
条目中。
composer require neuralglitch/bootstrap-theme-switch
如有必要,执行适当的命令以构建前端。
用法
修改基本模板
templates/base.html.twig
<html data-bs-theme="{{ app.session.get('_theme', 'light') }}" data-system-theme="{{ app.session.get('_is_system_theme', '0') }}">
在任意位置包含一个部分模板
例如 templates/partials/footer.html.twig
... {% include '@BootstrapThemeSwitch/button.html.twig' %} ...
或者
... {% include '@BootstrapThemeSwitch/select.html.twig' %} ...
如果还不够,请参阅高级使用说明。
现在开始,无需故障,在您的应用程序中切换 Bootstrap 主题。
卸载
警告
没有 Symfony Flex 食谱,Composer 不会完全删除该包,您需要遵循这些手动删除说明。
composer remove neuralglitch/bootstrap-theme-switch
如有必要,执行适当的命令以构建前端。
接下来是什么?
版权所有 (c) neuralglit.ch