Kendo Angular 2 Themes

£可爱£侵袭症+ 提交于 2019-12-19 10:35:17

问题


I'm trying to figure out how to customize a theme as outlined here:

http://www.telerik.com/kendo-angular-ui/components/styling/

What I can't figure out is under the section Custom Themes. It describes being able to change the scss variables directly in your own application, but this isn't working for me. Exactly what references do I need in place so I can do this?

$accent: #ff69b4;

@import "~@progress/kendo-theme-default/scss/all";

I can put this in my component style file... but I'm still missing something (it does nothing).

What is the "correct path to modules" that they reference here?

@Component({
  selector: 'my-app',
  styleUrls: [
    // load the default theme (use correct path to modules)
    'styles.scss'

回答1:


Due to style encapsulation, if you put this in a component it's going go be applied only to your component's own html.

You want your theme to be applied to the whole html, so you can either put this on your root component (usually app component) with ViewEncapsulation set to none, or put this in a global scss file declared in your <head>.

Here's some code for the first option (the cleanest, in my opinion) :

app.component.ts :

@Component({
    selector: 'app',
    template: require('./app.component.html'),
    encapsulation: ViewEncapsulation.None,
    styles: [require('./app.component.scss')]
})

app.component.scss :

/* Redefine here all the kendo theme variables you want */
$accent: red;

@import "~@progress/kendo-theme-default/scss/all";

Now, this means you have to be able to use scss on your project. For example, with webpack, you can do this:

module: {
    loaders: [
        { test: /\.scss$/, loader: 'to-string!css!sass' },
        ...

You will need to use css-loader and sass-loader npm packages.

You can find all the variables you can customize in the _variables.scss file : https://github.com/telerik/kendo-theme-default/blob/master/scss/_variables.scss



来源:https://stackoverflow.com/questions/41856955/kendo-angular-2-themes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!