[英]How to use custom theme/colors for Svelte Material UI (SMUI) components in Sapper project?
I've followed the instructions for using Svelte Material UI (SMUI) in a Sapper project.我已按照在 Sapper 项目中使用 Svelte Material UI (SMUI)的说明进行操作。
I can import and use SMUI components with the default theme/colors if I leave src/theme/_smui-theme.scss
blank.如果我将
src/theme/_smui-theme.scss
留空,我可以导入和使用具有默认主题/颜色的 SMUI 组件。 When I include the following code suggested by SMUI in this file to use custom colors, it tells me Can't find stylesheet to import.
当我在此文件中包含 SMUI 建议的以下代码以使用自定义 colors 时,它告诉我
Can't find stylesheet to import.
@use "@material/theme" with (
$primary: #5466F9,
$secondary: #14a564,
$surface: #fff,
$background: #fff
);
I can confirm that the @material/theme
directory does exist inside of node_modules.我可以确认
@material/theme
目录确实存在于 node_modules 中。 Can anyone help me understand why this would be causing such an error?谁能帮我理解为什么这会导致这样的错误? Thanks!
谢谢!
Svelte Material UI was recently updated (improved performance!) and the latest install instructions work well for Sapper. Svelte Material UI 最近更新了(提高了性能!),最新的安装说明适用于 Sapper。 If you are dealing with a similar error in a Sapper app, I would recommend the following steps:
如果您正在处理 Sapper 应用程序中的类似错误,我建议您执行以下步骤:
npm uninstall @smui/textfield
npm uninstall @smui/textfield
npm install --save-dev @smui/textfield
npm install --save-dev @smui/textfield
This fixed it for me to allow me to provide a custom theme in src/theme/_smui-theme.scss
这为我修复了它,允许我在
src/theme/_smui-theme.scss
中提供自定义主题
For non-sapper projects this may work .对于非工兵项目,这可能有效。 It was the inspiration beyond this fix above for sapper.
这是 sapper 的上述修复之外的灵感。 Thanks to Hunter, the creator of SMUI, for his help in fixing this and for an awesome library!
感谢 SMUI 的创建者 Hunter 帮助解决了这个问题并提供了一个很棒的库!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.