我正在尝试按照文档https://doc.oroinc.com/frontend/storefront/theming/创建自定义主题
CustomThemeBundle 和 FrontendBundle 中的源代码也被用作参考实现。
而且我还没有弄清楚: 如何替换顶栏的字体颜色和大小?
所有其他更改都正常工作:徽标、图标和主要主色。
- 我的捆绑文件夹结构
# bundle
src/MyCompany/Bundle/ThemeBundle
src/MyCompany/Bundle/ThemeBundle/MyCompanyThemeBundle.php
# config
src/MyCompany/Bundle/ThemeBundle/Resources/config/oro/bundles.yml
# assets
src/MyCompany/Bundle/ThemeBundle/Resources/public/my_theme/favicons/favicon.ico
src/MyCompany/Bundle/ThemeBundle/Resources/public/my_theme/images/logo.svg
# styles
src/MyCompany/Bundle/ThemeBundle/Resources/public/my_theme/scss/components/top-bar.scss
src/MyCompany/Bundle/ThemeBundle/Resources/public/my_theme/scss/settings/_colors.scss
src/MyCompany/Bundle/ThemeBundle/Resources/public/my_theme/scss/settings/global-settings.scss
src/MyCompany/Bundle/ThemeBundle/Resources/public/my_theme/scss/variables/top-bar-config.scss
src/MyCompany/Bundle/ThemeBundle/Resources/public/my_theme/scss/styles.scss
# assets config
src/MyCompany/Bundle/ThemeBundle/Resources/views/layouts/my_theme/config/assets.yml
# theme definition
src/MyCompany/Bundle/ThemeBundle/Resources/views/layouts/my_theme/theme.yml
- 主题扩展默认。徽标和网站图标加载正常
这是主题定义的代码:Resources/views/layouts/my_theme/theme.yml
parent: default
logo: bundles/mycompanytheme/my_theme/images/logo.svg
icon: bundles/mycompanytheme/my_theme/favicons/favicon.ico
label: My Company Marketplace
description: My Company Marketplace Theme.
groups: [ commerce ]
这是资产配置的代码:Resources/views/layouts/my_theme/config/assets.yml
styles:
inputs:
- bundles/mycompanytheme/my_theme/scss/settings/global-settings.scss
- bundles/mycompanytheme/my_theme/scss/variables/top-bar-config.scss
- bundles/mycompanytheme/my_theme/scss/styles.scss
output: css/styles.css
- 我使用 CustomThemeBundle 作为参考,只更改了主要的原色。有用
这是global-settings.scss导入的颜色的代码:Resources/public/my_theme/scss/settings/_colors.scss
/* @theme: my_theme; */
$custom-color-palette: (
'primary': (
'main': #0165AD, # that was the only color changed and it overrides the default as expected.
'base': #fd302b,
'light': #ff7a76,
'dark': #ce0500
),
'secondary': (
# all the same from CustomTheme
),
'additional': (
# all the same from CustomTheme
),
'ui': (
# all the same from CustomTheme
)
);
$color-palette: map_merge($color-palette, $custom-color-palette);
- 现在我尝试覆盖顶部栏的颜色和字体大小,但它不起作用
这是top-bar变量的代码:Resources/public/my_theme/scss/variables/top-bar-config.scss
该文件由assets.yml导入
/* @theme: my_theme; */
$top-bar-font-size: 14px; #it doens't change the font size
$top-bar-background: get-color('primary', 'main') !default; # it doenn't change the color
这是顶部栏组件的代码:Resources/public/my_theme/scss/components/top-bar.scss
此文件由styles.scss导入
/* @theme: my_theme; */
.topbar {
background: $top-bar-background; # this is the background color I am trying to override
...
# the entiry file content is an exact copy of the default theme from the FrontendBundle
...
这是样式的代码:Resources/public/my_theme/scss/styles.scss
该文件由assets.yml导入
/* @theme: my_theme; */
@import './components/top-bar';
- 代码有什么问题?
用于部署主题包的命令:
php bin/console cache:clear
php bin/console assets:install --symlink
php bin/console oro:assets:build my_theme