How to change color of Slider hover and active "shadow" - material-ui

I'm using Material-UI and Styled-Components. And I'm struggling with changing the color of the slider. I've been able to change the color of the thumb and track. But when hovering over and clicking the thumb, a blue haze surrounds the thumb. How do I change the color of this?
I've been able to style other parts (track, ticks, thumb etc) using the classes mentioned in the API (https://material-ui.com/api/slider/#css). But not this shadow effect.
https://codesandbox.io/s/ecstatic-satoshi-3mzrj?file=/src/App.js

The shadow effect is also a part of thumb.
You can simply use something like
& .MuiSlider-thumb:hover {
color: red;
box-shadow: 0 0 0 10px rgba(0, 255, 0, 0.3) !important;
}
or if you don't want to use !important, try to manipulate it with this class:
.MuiSlider-thumb.Mui-focusVisible, .MuiSlider-thumb:hover {
// your code here
}

Related

Making a GtkLabel in Glade fill the width

In Glade (version 3.8.5 as I am targetting gtk 2.24), I have created a label that sits in a row of a vbox. I have set the background color of the label (in Attributes) to blue, and the label appears to fill the entire row. But the blue background only extends as far as the text extent, not the entire width of the label.
How can I make the blue bar extend to the edges of the panel?
I read a while ago that Gtk labels don't actually have a color of their own, but they take whatever color their background widget has. I don't remember the source of this piece of information, but I do remember the solution, which is to put the label in a Gtk EventBox and change the color of said EventBox. I tested this solution in my gtk project with good results.
This is the function I use to change the color of the EventBox, by the way I'm using slightly older versions of Gtk and Glade, and I'm using C++ so if you're working with C you'll have to find the C equivalents of every function:
void GuiUtil::changeColor(Gtk::Widget* widget, double r, double g, double b) {
Glib::RefPtr<Gdk::Colormap> colormap = widget->get_colormap();
Glib::RefPtr<Gtk::Style> style = widget->get_style()->copy();
// STATE_NORMAL (most of the time)
{
Gdk::Color color;
color.set_rgb_p(r,g,b);
colormap->alloc_color(color);
style->set_bg(Gtk::STATE_NORMAL, color);
}
// STATE_PRELIGHT (when mouse hovers)
{
Gdk::Color color;
color.set_rgb_p(r*0.9,g*0.9,b*0.9);
colormap->alloc_color(color);
style->set_bg(Gtk::STATE_PRELIGHT, color);
}
// STATE_ACTIVE (when clicked)
{
Gdk::Color color;
color.set_rgb_p(r*0.8,g*0.8,b*0.8);
colormap->alloc_color(color);
style->set_bg(Gtk::STATE_ACTIVE, color);
}
widget->set_style(style);
}
As far as I know there isn't a way of doing this with Glade only.

GWT sprites with explicit dimensions are not scaled

We're running into a problem trying to use GWT sprites for different-sized buttons, using the same background image, like so:
#Source("background.png")
#ImageOptions(width=200,height=50)
ImageResource wideButton();
#Source("background.png")
#ImageOptions(width=100,height=50)
ImageResource narrowButton();
In the css we use the image resource like so:
#sprite .wideButton {
gwt-image: "wideButton"; }
#sprite .wideButton {
gwt-image: "narrowButton"; }
This produces DIV elements with the proper dimension, but it does not display the image properly when these dimensions are smaller than the image's original width and height: the picture is cropped to fit, rather than scaled.
Setting the width and height in the css does not solve the display problem.
#sprite .wideButton {
gwt-image: "narrowButton";
width: 100px;
height: 50px;
}
Is there a way to make this work, or were sprites simply not designed to be used in this way? Thanks in advance.

Element gets blurry after transition or animation

After I use CSS transition or animation that includes rotate the whole containing div gets a little bit blurry,
I read that it is some kind of side effect from redrawing the element, but is there a way to prevent it?
.toggle {
position: absolute;
width: 36px;
height: 36px;
bottom: 7px;
right: 94px;
z-index: 200;
background: transparent url("../img/handle-open.png") no-repeat;
-webkit-transition: all 1s cubic-bezier(0.91,0.00,1.00,1.00);
-moz-transition: all 1s cubic-bezier(0.91,0.00,1.00,1.00);
transition: all 1s cubic-bezier(0.91,0.00,1.00,1.00);
}
.toggle-closed {
-webkit-transform: rotate(180deg);
-moz-transform: rotate(180deg);
transform: rotate(180deg);
}
I tries to achieve the same with animate and got the same result
Update: I noticed something weird happening - in chrome, when the animation runs the element gets blurry and when the animation stops it return to normal,
on iOS however it happens the other way around - the image is clear while animated but gets blurry when completed! another weird #$$ bug!?
Ive seen issues such as this before after doing animations. Check the dimensions of the object after the transition, it may very well have changed in size by a few points causing blurry-ness. i,e:
Before transition: 36x36
After Transition: 36.2 x 36.8

GWT Canvas: how to change line color

Since the canvas drawing in GWT has been all over the map, let me be explicit and say I'm using this:
import com.google.gwt.canvas.client.Canvas;
The problem is that if I draw a black line and then change to red, the first line is changed to red also.
// draw line in black
context.moveTo(xScale(-0.5), yScale(0.0));
context.lineTo(xScale(15.0), yScale(0.0));
context.stroke();
// change to red
context.setStrokeStyle(CssColor.make(255,0,0));
context.moveTo(xScale(0.0), yScale(20.0));
context.lineTo(xScale(0.0), yScale(-20.0));
context.stroke();
// both lines appear in red
What is the correct method for changing pen color?
Calling context.beginPath() before each new shape/line with different color should fix your problem.
// draw line in black
context.beginPath();
context.moveTo(xScale(-0.5), yScale(0.0));
context.lineTo(xScale(15.0), yScale(0.0));
context.stroke();
context.beginPath();
// change to red
context.setStrokeStyle(CssColor.make(255,0,0));
context.moveTo(xScale(0.0), yScale(20.0));
context.lineTo(xScale(0.0), yScale(-20.0));
context.stroke();
// both lines appear in red
Basically beginPath() pushed the state

Get background-position

I'm trying to animate a canvas on three different layers on the onmousedown and ontouchstart. The three canvas go from left to right at a different speed to give a perspective effect as long as the onmouseup or ontouchend are not fired.
I am using #-webkit-keyframes css to do my animations:
#-webkit-keyframes aCarsRight
{
from{background-position: 0px 0px;}
to{background-position: 640px 0px;}
}
.cars_move_right
{
-webkit-animation-name: aCarsRight;
-webkit-animation-duration: 5s;
-webkit-animation-iteration-count: 1;
-webkit-transition-timing-function: linear;
}
What I would like to do is get the current background-position of the three layers prior to disabling the pan animation and set them manually so when I remove the .cars_move_right class from my div is stays in the same position instead of rolling back to its default position.
Is there a way to get the background-position or just a work around to get what I want? The page is meant for iPhone and iPod Touch.
Thanks !
I found something interesting. Instead of grabbing the background-position, stop the animation and set the background-position to my divs, I pause the animation.
document.getElementById('global').style.webkitAnimationPlayState = 'paused';
document.getElementById('global_cars').style.webkitAnimationPlayState = 'paused';
document.getElementById('global_car').style.webkitAnimationPlayState = 'paused';
Haven't had the chance to test it on iPhone yet.
And, here's a method that seems to work cross-browswers to get any property:
window.getComputedStyle(document.getElementById('div'))['background-position'];
Have you tried:
var blah = ele.style.backgroundPosition;
That will return it like "10px 57px"
If the css rule has a hyphen in it then afaik in Javascript the hyphen is removed and camel case applied.
I found that I can use this to get the property I couldn't get with [mydiv].style.[property]
function getProperty(property, div)
{
return window.getComputedStyle(document.getElementById(div))[property];
}