neuralglitch/bootstrap-theme-switch

Bootstrap 主题切换包

v0.1.1 2024-05-07 23:32 UTC

This package is auto-updated.

Last update: 2024-09-08 00:39:52 UTC


README

license coverage

Bootstrap 5 主题切换器

实现亮、暗和系统默认模式的无缝切换。

bootstrap-theme-switch

php symfony bootstrap

安装

按照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