Angular material md-switch - angularjs

i want to customize the color of md-switch without writing alot of angular/js if possible
here how i want it
i was able to get the first , mainly becuse the main theme is solid gren and i used this to make the body of the switch light green
<md-switch ng-change="$ctrl.updateAsset($ctrl.asset,
'disabled')" ng-model="$ctrl.asset.disabled"></md-switch>
md-switch.md-checked .md-bar {
background-color: rgb(212, 255, 186); //light green
}
how would i change the head color (round)? how would i change the color of both head and body of the switch when the switch is off?

What you call the "head" is an element with class md-thumb; the bar, as you note, has class md-bar. Both are colored by their background-color property.
The md-checked class is active when the switch is "on".
md-switch .md-thumb {
background-color: darkgrey;
}
md-switch .md-bar {
background-color: lightgray;
}
md-switch.md-checked .md-thumb {
background-color: darkgreen;
}
md-switch.md-checked .md-bar {
background-color: lightgreen'
}
Obviously you should use the exact colors you want.
You could simplify the above if you're using SASS or LESS, and you may want to look at custom theming if you're planning to change more than this one component.
Edited to add:
To reverse the direction, use the transform property, e.g.
md-switch .md-thumb-container {
transform: translate3d(100%, 0, 0);
}
md-switch.md-checked .md-thumb-container {
transform: translate3d(0, 0, 0);
}
Add vendor prefixes as necessary for your browser support requirements.

Related

Apply rowStyleClass to every row in PrimeReact DataTable

I have data and each row/user is formatted something like this:
{
first: <string>
active: <bool>
}
I wish to apply a background color to the entire row if active property is false. Currently I have this, to try to get style applied to every row
rowClassName = (rowData) => {
return {'greyed' : true}; //will be {'greyed': !rowData.active} but this is for demonstration
}
<DataTable value={this.props.users.toJS()} //in render
selectionMode="single"
selection={user}
onSelectionChange={this.props.dispatch.editAccount}
rowClassName={this.rowClassName}
>
<Column field="first" header="First" filter={true}/>
</DataTable>
.greyed{ //in css
background-color: red;
}
which is only applying the style to every other row (see picture)
Any ideas on what I should try? i posted this question on the primeFaces forum 3 days ago and never got a response: https://forum.primefaces.org/viewtopic.php?f=57&t=58605
I just ran into this problem while trying out PrimeReact. My issue turned out to be that the default selector that sets the row background was more specific than my own.
This is the default:
body .p-datatable .p-datatable-tbody > tr:nth-child(even) {
background-color: #f9f9f9;
}
so just having
.specialRowColor { background-color: 'blue' }
is not specific enough to override the default. Instead I needed to do this in my css:
.p-datatable .p-datatable-tbody .specialRowColor {
background-color: blue;
}
Solved by overriding the css like this
.ui-datatable tbody > tr.ui-widget-content.greyed {
background-color: #808080;
}

How to define a group of variables in stylus?

I was wondering if there was a way to switch between two groups of variable definitions. For example, to change the color theme:
$my-blue = #1876d3
$my-white = #f6f6f6
blue-on-white()
$primary-color = $my-blue
$secondary-color = $my-white
white-on-blue()
$primary-color = $my-white
$secondary-color = $my-blue
// Now I could go back and forth between both schemes to see which one I prefer
blue-on-white()
// white-on-blue()
I've tried the above approach using mixins, but it doesn't work with variables.
Maybe there is another or better way to do but I found a solution using hashes: http://stylus-lang.com/docs/hashes.html.
Stylus
blue = #1876d3
white = #f6f6f6
blue-on-white = {
primary-color : blue,
secondary-color : white
}
white-on-blue = {
primary-color : white,
secondary-color : blue
}
h1
color blue-on-white[primary-color];
background-color blue-on-white[secondary-color];
h2
color white-on-blue[primary-color];
background-color white-on-blue[secondary-color];
Compiled CSS
h1 {
color: #1876d3;
background-color: #f6f6f6;
}
h2 {
color: #f6f6f6;
background-color: #1876d3;
}

How to use begin with selector in Less

I'm going to create a less code that will give different background-color to element depending on it's class. This will be for list of attachments, so class name is based on attachment extension.
I do support some typical extensions:
.label{
&.label-pdf{
background-color: #c70000;
}
&.label-doc, &.label-docx, &.label-odt{
background-color: #157efb;
}
&.label-xls, &.label-xlsx, &.label-calc{
background-color: #069e00;
}
&.label-ppt, &.label-pptx, &.label-odp{
background-color: #9e3c15;
}
&.label-jpg, &.label-png, &.label-gif, &.label-png, &.label-ttf{
background-color: #95009e;
}
}
but the problem is with some unusual extensions, or even files like: jpg, jpeg, doc, docx, this is why I would like to use expression from CSS. In pure CSS I could use:
.label.[class^="label-"]{
background-color: rgba(0,37,100,0.4);
}
And put this code at the beginning so other classes could override this one.
But unfortunately this sign ^ (I suppose) is breaking my Less compilation. I have been trying to do something like this:
~".label.[class^='label-']{
background-color: rgba(0,37,100,0.4);
}"
AND
.label{
&.~"[class^='label-']"{
background-color: rgba(0,37,100,0.4);
}
}
But still not working. So is it possible to use this selector?
It is not working because your syntax seems to be wrong and not because of any issues with Less.
The below code is invalid because of the . present between the label and the class^="label-"]. Attribute selectors do not require a . before them. It is necessary only for class selectors.
.label.[class^="label-"]{
background-color: rgba(0,37,100,0.4);
}
The correct version would be the following:
.label[class^="label-"]{
background-color: rgba(0,37,100,0.4);
}
and so in Less terms, if you want nesting, it would be as follows:
.label{
&[class^='label-']{
background-color: rgba(0,37,100,0.4);
}
}
.label.[class^="label-"] { /* this won't work */
background-color: rgba(0, 37, 100, 0.4);
}
.label[class^="label-"] { /* this will */
color: green;
}
<label class='label-a label'>Label A</label>
<label class='label-b label'>Label B</label>
Another thing to note is that the ^= is a starts with selector and so when your element has more than one class, the class that resembles label- should be the first class in the list and not the label. If we make the label as the first class then (like seen in below snippet) it won't work because then the class doesn't start with label-.
If the first class in the list is indeed label then you should consider using the *= (contains) selector. But be careful when using the contains selector because it will sometimes select unintended elements like those with class label-not, not-label etc.
.label.[class^="label-"] { /* this won't work */
background-color: rgba(0, 37, 100, 0.4);
}
.label[class^="label-"] { /* this won't too */
color: green;
}
.label[class*="label-"] { /* this will */
border: 1px solid green;
}
<label class='label label-a'>Label A</label>
<label class='label label-b'>Label B</label>
I have same problem. I use this in less file.
[class^="customForm-"] { ... }
But for my HTML it does not works.
<div class="form form-01 customForm-radioList">...</div>
The problem is in tha fact that string "form form-01 customForm-radioList" does not starts with "customForm-" it starts with "form".
Solution
Use contains selector W3 school.
[class*="customForm-"] { ... }

Change font size of chart (n3-charts/line-chart)

I am using https://github.com/n3-charts/line-chart library to generate charts. Is it possible to change font size of axis labels? I could not find such option in official documentation.
Something like this on the CSS would work
.tick text {
font-size: 120%;
}
Edit: The appearance of many SVG elements can be configured using CSS, just inspect them in the browser and try modifying them.
When the chart is generated it has it's own classes that you can take advantage of overwriting... Here are all the axis for example:
// X-Axis Font
.x-axis {
font-size: 120%;
}
// Left Y-Axis
.y-axis {
font-size: 130%;
}
// Right Y-Axis
.y2-axis {
font-size: 140%;
}
Hope that helps.

JavaFx combobox dropdown list design issue

I am trying to change the background color and text color for combbox and is using following style
.root
{
//-back:#152635;
-darker:#272B30;
-dark:#3A3F44;
-normal:#52575C; // #555
-light:#7A8288; // #999
-lighter:#999; // #eee
-primary:-light;
-success:#62c462;
-info:#5bc0de;
-warning:#f89406;
-danger:#ee5f5b;
-fore-color:#C8C8C8;
-fx-background-color:-darker ;
-focused-color:#64c8c8;
-border-color:derive(-darker,50%);
-fx-text-fill:-fore-color;
-fx-font-size: 14px;
-fx-font-weight:100;
-fx-font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}
.combo-box-base {
-fx-background-color:-dark;
-fx-text-fill:-fore-color;
-fx-min-width:150px; }
.combo-box-base *.arrow-button {
-fx-background-color:derive(-dark,-10%); }
.combo-box-base *.arrow {
-fx-background-color:-normal; }
.combo-box *.list-view {
-fx-background-color:-normal;
-fx-text-fill:-fore-color; }
Design looks good in Scene builder but in my application, font and background color of drop down list is not changed which is little bit surprised to me. Please help me to find out what is wrong in my css.
While #James_D solution works, if you override the background color you won't see hover, filled or selected pseudo classes.
This will give you the chance to define your styling for them too:
.combo-box-popup > .list-view {
-fx-background-color: -normal; // or define other color to highlight the border
}
.combo-box-popup *.list-cell {
-fx-background: -normal;
-fx-selection-bar: -light; // filled:hover
-fx-cell-focus-inner-border: -dark; // filled:selected:hover
-fx-text-fill: -fore-color;
}
You need to apply the style to the list cells, not the list view:
.combo-box *.list-view .list-cell {
-fx-background-color:-normal;
-fx-text-fill:-fore-color; }

Resources