Override theme text color - material-components

My problem
I set my custom theme and it works fine.
But I get black text color on orange( accent) button, but I want to have white color.
My solution
In #material/theme/_variables.scss we have code like this :
$mdc-theme-primary: #3f51b5 !default; /* Indigo 500 */
$mdc-theme-accent: #ff4081 !default; /* Pink A200 */
$mdc-theme-background: #fff !default; /* White */
/* Which set of text colors to use for each main theme color (light or dark) */
$mdc-theme-primary-tone: mdc-theme-light-or-dark($mdc-theme-primary);
$mdc-theme-accent-tone: mdc-theme-light-or-dark($mdc-theme-accent);
$mdc-theme-background-tone: mdc-theme-light-or-dark($mdc-theme-background);
From the above code, we can see first three params have !default which means use this as default , if they are already declared dont override.
For that reason we can specify the custom colors.
But for properties like $mdc-theme-accent-tone we are forced to use the calculated values.
If I change the above code (source code of MDC ) to
$mdc-theme-accent-tone: mdc-theme-light-or-dark($mdc-theme-accent) !default;
and in my styles
$mdc-theme-accent-tone : "light"
It works fine. But obviously I can not change the source code. How to achieve this.

I realized this is according to the material design spec. So, expecting a provision to override is wrong.
But for all practical reasons, to override them do this :
#import "#material/theme/mdc-theme";
:root {
--mdc-theme-text-primary-on-accent: white;
}
Remember the override style should be written after importing mdc-theme

Related

Replicating color box in VScode when writing CSS

I'm currently working on a project that basically shows a map. The map, image below, has different color gradients and I'd like to replicate the effect of vscode when you set color in css and it shows a little box that displays the color. I'd display that color and write a comment beside it.(I.E green = Great economy, light green = medium economy, and very light green = poor economy).
I'd really like to replicate the color display you see in vscode when you set color properties in css like this:
Open up settings in vs code (on a Mac, press command+comma)
Search for Color Decorators and check the box
More on vs code settings https://code.visualstudio.com/docs/getstarted/settings
I think you are asking about setting custom properties/variables in your CSS?
:root {
--some-yellow-you-name-here: #ffff00;
}
.you-class-name {
background-color: var(--some-yellow-you-name-here);
}

CSS defined background color of FloatingActionButton adds an annoying "hyphen" on top of it

My CN1 app features a FloatingActionButton. I need to change its background color. My styles are all defined in CSS. So this one is :
FAB {
background-color: #80ccc4;
}
And if I create the FAB like FloatingActionButton.createFAB(FontImage.MATERIAL_POWER_SETTINGS_NEW, "FAB"); it results in a FloatingActionButton with an added "hyphen" on top of it :
On the contrary if I create the FAB without providing a style and then programmatically set the background color like fab.getAllStyles().setBgColor(0x80ccc4); then I get the expected FAB :
So what should I set in the css file to remove this unwanted "hyphen" ?
Any help appreciated!
You are styling FAB and not FloatingActionButton which is the right UIID for that. If you used setUIID that might be problematic on a FAB as the content is set later.
The reason this is happening is a bit of a problem with CSS. We get the background color of the FAB from the RoundBorder but transparency should be 0 for the icon in the center.
Unfortunately in CSS you can't express both a background color and 0 background transparency. I don't think this is solvable in the CSS so I'll add a special case to the FloatingActionButton that should workaround this.

ExtJS 4 form textfield and color (background)

There is simple form and some textfields on this form. I have to set colors
(background and font) in two of them on runtime.
I tried to do it two ways:
1) fieldInstance.addClass('aaa') with css like this
.aaa .x-form-field {
background-color: black;
color: red;
}
2) fieldInstance.setFieldStyle('font-weight: bold;color: red;background-color: black;');
both methods are working because I see the bottom age of both is
fields is thick in black color, and both fields are working the same (almost) way.
Before enter and after exit background color is white.
When I start to edit this fields, background of first
is always white, background of the second is black until
I leave the field.
Could you explain me whats wrong?
For <input> element applied many classes beside x-form-field, like x-form-text and some of them define color and background-color aswell. So I guess that some of that classes may be more specific than .aaa .x-form-field. Try to use !important within your CSS rules:
.aaa .x-form-field {
background-color: black !important;
color: red !important;
}
I think that the 1st function append a class to the Others already presents.
In the second case you replace values of style already setted.
Maybe to have the same issue you need to modify the x-form-field fields, instead of append Others.
I Always use the second option if i have to modify style on Runtime.
maybe posting other code i can see better where the problem could present

How to suffix all properties with !important

I want to suffix all my rules with !important, how can I do this with stylus?
like I have
body
width 100%
color #fff
...
and I want this as output:
body {
width: 100% !important;
color: #fff !important;
...
}
afaik stylus does'nt have built in functionality to do something like this.
I think you could achieve what you want with some simple regex maybe you should look here for some advice,
although I don't recommend overusing !important.
Some advice on !important usage
It is a task better suited for something like PostCSS, but you can do this in Stylus too, but you'll need to list all the properties you'd like to override:
make_important()
{called-from}: arguments (!important in arguments ? unquote('') : !important)
// List all the properties you'd like to override
props = background, width, height, padding-left, margin-left, color, margin-bottom, font-size, border-left, font, opacity, transition, display, padding-bottom, margin-top, border, background-position, margin, padding
for prop in props
define(''+prop, #(){
make_important(arguments)
})
Live demo: http://jsbin.com/lopora/edit?css,output

How to change the color of the titlebar in sencha touch

I need to change the color of the titlebar to white color . What is the steps to be done Without using sass. I should be able to do that without theming in sencha touch.
Here is the style which you have to add in your css file.
.x-toolbar-dark {
background-color: white !important;
background-image: none !important;
}
By adding this style, you are simply overriding the sencha titlebar's default styling and now color of titlebar will become white.
NB: I would prefer you to use SASS if possible. Comment here if you need to change your sass file. Thank you.

Resources