how to change the global variable inside a scss mixin

前端 未结 2 1301
没有蜡笔的小新
没有蜡笔的小新 2021-01-23 01:49

theme-variables.scss

//---------------------------------------------------------
//Declare a global variable and set it to red color         


        
2条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-23 02:28

    You will need a mixin function in your component.scss.

    And then have a @include in your main.scss file.

    component.scss

    @mixin text-color-mixin($theme) {
      $is-dark-theme: map-get($theme, is-dark);
      .text-color {
        color: if($is-dark-theme, red, blue);
      }
    }
    

    main.scss

    @import ...../component.scss
    ...
    
    ...
    @include  text-color-mixin($theme);
    

    To find out more on how you can structure your angular project themes you can look at https://github.com/angular/material.angular.io

    This is the official repo for the angular material io documentation site.

    EDIT

    I think this also answers your question

    How to manipulate scss variables in Angular2 components

提交回复
热议问题