- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我想使用 Material Design Lite“主题”的“自定义版本”。
MDL基本上是提取用于 Web 应用程序的 Material Design 的 CSS 和 JS 元素。 MDL 有一个 Web 界面,通过它可以使用他们的自定义主题颜色变体之一生成 CSS 文件,但我们想使用我们自己的颜色。
我已经用 Bower 安装了 MDL并使用 SASS 编译 components .
除了更改 MDL 文件本身之外,如何/在何处可以覆盖以下变量:
$color-primary: $palette-red-500 !default;
$color-primary-dark: $palette-red-700 !default;
$color-accent: $palette-pink-A200 !default;
// Our primary is dark, so use $color-dark-contrast for overlaid text.
$color-primary-contrast: $palette-green-700 !default;
// Our accent is dark, so use $color-dark-contrast for overlaid text.
$color-accent-contrast: $palette-green-700 !default;
更多细节:
在 MDL 代码库中,bower_components/material-design-lite/src/_variables.scss
文件包含“theme declaration”变量(如上所示),我当然可以更改这些变量,但是我认为有一种方法可以从组件外部覆盖它们。
我尝试将以下内容添加到我自己的 assets/styles/common/_variables.scss
文件中,但我认为组件中声明的变量 已经被使用按时间创建样式 Gulp到达此文档:
@import "../../bower_components/material-design-lite/src/color-definitions";
//@import "functions";
$trim-color-classes: false !default;
// Use color primarily for emphasis. Choose colors that fit with
// your brand and provide good contrast between visual components.
$color-primary: $palette-red-500 !default;
$color-primary-dark: $palette-red-700 !default;
$color-accent: $palette-pink-A200 !default;
// Our primary is dark, so use $color-dark-contrast for overlaid text.
$color-primary-contrast: $palette-green-700 !default;
// Our accent is dark, so use $color-dark-contrast for overlaid text.
$color-accent-contrast: $palette-green-700 !default;
我不确定 bower 引入组件 CSS 的方式(作为单个文件)是否需要更改:
"material-design-lite": {
"main": [
"./src/material-design-lite.scss",
"./src/mdlComponentHandler.js"
]
}
常见的方法是简单地更改 MDL 源 _variables.scss
文件吗?
如果它对其他使用自定义 Material Design 颜色托盘的人有用:
我用了angular-md-color.com/#/ ,它实际上根据自定义十六进制值生成 Angular 代码块格式的十六进制值:
angular.module('myApp', ['ngMaterial']).config(function ($mdThemingProvider, palettes) {
var customPrimary = {
'50': '#ffffff',
'100': '#ffffff',
'200': '#ffffff',
'300': '#ffffff',
'400': '#fbfaf8',
'500': '#f2efe8',
'600': '#e9e4d8',
'700': '#e0d8c7',
'800': '#d6cdb7',
'900': '#cdc2a7',
'A100': '#ffffff',
'A200': '#ffffff',
'A400': '#ffffff',
'A700': '#c4b697'
};
$mdThemingProvider
.definePalette('customPrimary',
customPrimary);
var customAccent = {
'50': '#233f95',
'100': '#2847a9',
'200': '#2d50be',
'300': '#355bcf',
'400': '#4a6bd4',
'500': '#5e7cd9',
'600': '#889ee3',
'700': '#9cafe8',
'800': '#b1bfed',
'900': '#c6d0f1',
'A100': '#889ee3',
'A200': '#738dde',
'A400': '#5e7cd9',
'A700': '#dae1f6'
};
$mdThemingProvider
.definePalette('customAccent',
customAccent);
var customWarn = {
'50': '#ffb280',
'100': '#ffa266',
'200': '#ff934d',
'300': '#ff8333',
'400': '#ff741a',
'500': '#ff6400',
'600': '#e65a00',
'700': '#cc5000',
'800': '#b34600',
'900': '#993c00',
'A100': '#ffc199',
'A200': '#ffd1b3',
'A400': '#ffe0cc',
'A700': '#803200'
};
$mdThemingProvider
.definePalette('customWarn',
customWarn);
var customBackground = {
'50': '#989794',
'100': '#8c8a87',
'200': '#7f7d7b',
'300': '#72716e',
'400': '#656462',
'500': '#585755',
'600': '#4b4a48',
'700': '#3e3d3c',
'800': '#31312f',
'900': '#242423',
'A100': '#a5a4a1',
'A200': '#b1b0ae',
'A400': '#bebdbb',
'A700': '#171716'
};
$mdThemingProvider
.definePalette('customBackground',
customBackground);
$mdThemingProvider.theme('default')
.primaryPalette('customPrimary')
.accentPalette('customAccent')
.warnPalette('customWarn')
.backgroundPalette('customBackground')
});
根据您最终想要的格式,您可以使用类似 HSL Color Picker 的工具得到相应的值(rgb,hsl)。
我正在覆盖 Material Design Gray 以匹配客户请求的 Benjamin Moore Paint 值:
$palette-grey:
"152, 151, 148"
"140, 138, 135"
"127, 125, 123"
"114, 113, 110"
"101, 100, 98"
"88, 87, 85"
"75, 74, 72"
"62, 61, 60"
"49, 49, 47"
"36, 36, 35"
"165, 164, 161"
"177, 176, 174"
"190, 189, 187"
"23, 23, 22";
$palette-grey-50: nth($palette-grey, 1);
$palette-grey-100: nth($palette-grey, 2);
$palette-grey-200: nth($palette-grey, 3);
$palette-grey-300: nth($palette-grey, 4);
$palette-grey-400: nth($palette-grey, 5);
$palette-grey-500: nth($palette-grey, 6);
$palette-grey-600: nth($palette-grey, 7);
$palette-grey-700: nth($palette-grey, 8);
$palette-grey-800: nth($palette-grey, 9);
$palette-grey-900: nth($palette-grey, 10);
$palette-grey-A100: nth($palette-grey, 11);
$palette-grey-A200: nth($palette-grey, 12);
$palette-grey-A400: nth($palette-grey, 13);
$palette-grey-A700: nth($palette-grey, 14);
// Grey
.mdl-color-text--grey {
color: unquote("rgb(#{$palette-grey-500})") !important;
}
.mdl-color--grey {
background-color: unquote("rgb(#{$palette-grey-500})") !important;
}
.mdl-color-text--grey-50 {
color: unquote("rgb(#{$palette-grey-50})") !important;
}
.mdl-color--grey-50 {
background-color: unquote("rgb(#{$palette-grey-50})") !important;
}
.mdl-color-text--grey-100 {
color: unquote("rgb(#{$palette-grey-100})") !important;
}
.mdl-color--grey-100 {
background-color: unquote("rgb(#{$palette-grey-100})") !important;
}
.mdl-color-text--grey-200 {
color: unquote("rgb(#{$palette-grey-200})") !important;
}
.mdl-color--grey-200 {
background-color: unquote("rgb(#{$palette-grey-200})") !important;
}
.mdl-color-text--grey-300 {
color: unquote("rgb(#{$palette-grey-300})") !important;
}
.mdl-color--grey-300 {
background-color: unquote("rgb(#{$palette-grey-300})") !important;
}
.mdl-color-text--grey-400 {
color: unquote("rgb(#{$palette-grey-400})") !important;
}
.mdl-color--grey-400 {
background-color: unquote("rgb(#{$palette-grey-400})") !important;
}
.mdl-color-text--grey-500 {
color: unquote("rgb(#{$palette-grey-500})") !important;
}
.mdl-color--grey-500 {
background-color: unquote("rgb(#{$palette-grey-500})") !important;
}
.mdl-color-text--grey-600 {
color: unquote("rgb(#{$palette-grey-600})") !important;
}
.mdl-color--grey-600 {
background-color: unquote("rgb(#{$palette-grey-600})") !important;
}
.mdl-color-text--grey-700 {
color: unquote("rgb(#{$palette-grey-700})") !important;
}
.mdl-color--grey-700 {
background-color: unquote("rgb(#{$palette-grey-700})") !important;
}
.mdl-color-text--grey-800 {
color: unquote("rgb(#{$palette-grey-800})") !important;
}
.mdl-color--grey-800 {
background-color: unquote("rgb(#{$palette-grey-800})") !important;
}
.mdl-color-text--grey-900 {
color: unquote("rgb(#{$palette-grey-900})") !important;
}
.mdl-color--grey-900 {
background-color: unquote("rgb(#{$palette-grey-900})") !important;
}
.mdl-color--grey-A100 {
background-color: unquote("rgb(#{$palette-grey-A100})") !important;
}
.mdl-color--grey-A200 {
background-color: unquote("rgb(#{$palette-grey-A200})") !important;
}
.mdl-color--grey-A400 {
background-color: unquote("rgb(#{$palette-grey-A400})") !important;
}
.mdl-color--grey-A700 {
background-color: unquote("rgb(#{$palette-grey-A700})") !important;
}
现在我可以做这样的事情:
<header class="mdl-layout__header mdl-color--grey-800 mdl-color-text--grey-100">
并获取自定义颜色。
最佳答案
原来,according to the MDL docs您必须“在导入默认变量之前定义变量。”
所以我的 _variables.scss
如上:
@import "../../bower_components/material-design-lite/src/color-definitions";
//@import "functions";
$trim-color-classes: false !default;
// Use color primarily for emphasis. Choose colors that fit with
// your brand and provide good contrast between visual components.
$color-primary: $palette-grey-500 !default;
$color-primary-dark: $palette-grey-700 !default;
$color-accent: $palette-indigo-A200 !default;
// Our primary is dark, so use $color-dark-contrast for overlaid text.
$color-primary-contrast: $palette-yellow-500 !default;
// Our accent is dark, so use $color-dark-contrast for overlaid text.
$color-accent-contrast: $palette-yellow-500 !default;
在 Bower 将 Material 设计组件导入到我的 main.scss
文件中之前, 需要调用该文件:
@import "common/_variables";
// Automatically injected Bower dependencies via wiredep (never manually edit this block)
// bower:scss
@import "../../bower_components/material-design-lite/src/material-design-lite.scss";
// endbower
// more import statements here
为了查看我的自定义颜色,我将其放在页面中:
<div class="content-grid mdl-grid" style="height:300px">
<div class="mdl-cell mdl-cell--1-col mdl-color--grey-50">
50
</div>
<div class="mdl-cell mdl-cell--1-col mdl-color--grey-100">
100
</div>
<div class="mdl-cell mdl-cell--1-col mdl-color--grey-200">
200
</div>
<div class="mdl-cell mdl-cell--1-col mdl-color--grey-300">
300
</div>
<div class="mdl-cell mdl-cell--1-col mdl-color--grey-400">
400
</div>
<div class="mdl-cell mdl-cell--1-col mdl-color--grey-500">
500
</div>
<div class="mdl-cell mdl-cell--1-col mdl-color--grey-600">
600
</div>
<div class="mdl-cell mdl-cell--1-col mdl-color--grey-700">
700
</div><div class="mdl-cell mdl-cell--1-col mdl-color--grey-A100">
A100
</div>
<div class="mdl-cell mdl-cell--1-col mdl-color--grey-A200">
A200
</div>
<div class="mdl-cell mdl-cell--1-col mdl-color--grey-A400">
A400
</div>
<div class="mdl-cell mdl-cell--1-col mdl-color--grey-A700">
A700
</div>
</div>
关于css - 使用 Gulp、Sass 在 Material Design Lite 主题上定制变体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36900710/
我是 angular 的新手,想动态地更改 angular Material 主题,我知道如何通过制作 scss 文件来制作不同的主题,定义 3 种颜色,包括 mat 属性和功能,但后来我在 angu
我猜,是不允许在 Material 网格(嵌套网格)中放置 Material 网格吗? 有人可以确认我的假设吗? (我正在使用 Angular Material 6。) l
已结束。此问题正在寻求书籍、工具、软件库等的推荐。它不满足Stack Overflow guidelines 。目前不接受答案。 我们不允许提出寻求书籍、工具、软件库等推荐的问题。您可以编辑问题,以便
我一直在 material-ui react 库中看到对名为“LeftNav ”的组件的引用(例如: Material UI - Open LeftNav / Drawer on AppBar cli
我正在使用 mat-list而且我无法在移动设备上滚动它。 它是一个 mat-nav-list,里面有一些 mat-list-item,我的列表结构类似于: dashboard
我是网络开发的新手,正在尝试使用 material-ui。我看到一些演示代码使用 withStyle,还有一些使用 withTheme。它们之间有什么区别吗?非常感谢! 最佳答案 我认为接受的答案没有
我正在研究 Material 设计和 Material 设计中描述的一些指南。 我似乎遗漏了一个部分(不确定是否应该涵盖),即 Google 如何处理 Fieldsets。该文档确实涵盖了各个输入,但
我正在根据到目前为止所学的知识使用 Material 设计创建一个示例应用程序,但我注意到 Material 设计的开箱即用字体对于不同的组件是不同的。对于 Material 对话框中的 Materi
我确实有角度 6,尽管 ng generate @angular/material:material-nav --name home不工作 得到类似的错误 Collection "@angular/m
我正在使用图书馆 material-table对于我的应用程序中的数据表。我将数据 Prop 设置为使用来自 this.state.data 的数据,并且添加行将通过使用 setState 在我的表上
如何在 Angular Material Design 中设置工具栏下方的侧导航?这样 sidenav 就不会越过工具栏.. 最佳答案 这是一个布局问题。只需使用此页面结构:
我使用的是角 Material 2,但我认为这也适用于角 Material 1。 假设我想使用角度 Material 选项卡,但我想隐藏选项卡或向其添加一些特定样式。 所以我有以下 html/angu
我安装了 material-ui“^1.0.0-beta.36”。文档说有日期选择器。 但我在 node_modules\material-ui 和任何子文件夹中都找不到它。 更改日志表明计划在未来版
从一小时前开始,我在 Material 设计图标 cdn 上不断收到网络错误,因为错误名称未解析。 http://cdn.materialdesignicons.com/5.4.55/css/mate
如何在不失去波纹效果的情况下更改角 Material 开关按钮的颜色? 请在此处查看代码笔:http://codepen.io/shyambhiogade/pen/LpNGBP 我已将颜色更改为 #0
对于textfield并选择,我看到我们具有以下选项来添加variant =“ outlined”。 但是,我看不到material-ui / DatePicker。有人可以建议如何使用实质性UI将v
在 3.1.0 版本中使用“@material-ui/core” 全局覆盖步进器图标的颜色非常容易全局 createMuiTheme({ overrides: { MuiStepIco
我在我的应用程序脚本插件中使用 materializecss,当我尝试动态添加工具提示时,提示不会使用新标签更新。我尝试了几种变体,甚至仔细检查了小费是否正在改变,确实如此。问题是它似乎没有用更新的文
有谁知道当模式确定时如何在 Material 进度微调器中显示不完整的部分。现在我是这样的 . 但我想要这样 最佳答案 这可以做到,但它主要是一个黑客。这个想法是使用一个带有与微调器匹配的边框的 di
我今天发现了这个很棒的 UI 框架,并花了很多时间浏览文档,我必须说,我已经爱上了它。现在我想将它用于一个中等规模的项目,但我有两个顾虑: 我找不到任何网格系统,我该如何进行布局? 如何让它响应? 我
我是一名优秀的程序员,十分优秀!