Chakra-UI: How to set a transition time between color modes? - reactjs

Right now when I change color mode via a dark / light theme button toggle, the page background color will blend into the new background color over 0.2 seconds or so, and all other colors will instantly change to the new color. I'd either like to define a color mode switch transition time, or at least make them the same between elements.
I just set the background of everything explicitly, that way everything changes color instantly. But I'd like it if I can have the quick transition instead.

Ok so I figured it out immediately after posting this question. Pretty simple really, just pass something like transition="background-color 200ms linear" or transitionDuration="200ms" into your ui component.

Related

Is it possible to change colour palette on a per window / user control basis?

I am wondering if with the Telerik WPF library it is possible to change colour palette on a per window / usercontrol basis.
For clarity, I am not refering to basic Foreground or Background colours, I am interested in changing colours for certain visual states such mouse over or focused which is not possible to simple change on a control.
In the docs there is a sample for changing a colour palette such as FluentPalette.Palette.BasicColor = (Color)ColorConverter.ConvertFromString("#33000000");.
But this will have an effect on the whole app UI, whereas I am aiming to change the palette on a per window basis.
The way it looks to me, the only option would be to copy the specific theme for each variant (if that's possible at all) each with its colour palette tweaks for each window, which is of course overkill.
Any ideas?

How to detect background color in React

Is there a way to detect the background color at one certain point of the page dynamically? I have a website with a fixed header, and the default logo on it is white (default background is black). However, as I scroll down there are sections that have white background, so the logo would have to change colour to black.
Setting it based on scrolling position is not possible, because all sections have different heights and the height is often dependent on the content.
I have found mix-blend-color, but unfortunately its support is pretty bad across browsers. Also tried numerous npm packages, but none of them seem to pick up the background colour.
Is there another way to dynamically change the logo color without getting the background color?
Answer 1
I never tried this, but I think this might lead to the answer.
You can use document.elementFromPoint.
This will retrieve the top element at some (x, y) point.
So you can set the x and y to 1px down the border of your modal ( or some place where you know that will only have element with the background color you want) and get the element.
And check, on a scroll event listener, what is the element at that position and get it's background color.
Is this a good thing to do? Maybe not, but it works and it have good support across browsers.
Answer 2
Setting it based on scrolling position is not possible
Of course it's possible!
If your modal is with position absolute, what you can do is get the modal's ref and use element.getBoundingClientRect() to get it's position.
Then on each section, you also get the ref (you will have an array of section's ref) in the parent component, which knows the modal's refs and section's ref.
Then, on a scroll event, you use getBoundingClientRect on each section element and check if it's inside the modal logo.
To check if it's inside, you can simply use the top and bottom ( if the scroll is vertical).
This is harder to implement, but I think it's the way to go.

Why is the Designer in Codename one not reporting the attributes I set?

I started a Codename One project with the "Hello World bare bones". I used to define the styles in the Theme tab from the Designer but now it is becoming tedious.
Actually for some selectors, even if I override (unchecking the Derive box) some properties the style is not changed in the Designer (see below) or in the app itself.
However, in the list of selectors, the color is not the one I selected but the alignment seems to be it.
It seems that the theme is locked somewhere. Do I make a mistake, or should I set a constant to "unlock" the theme, or even should I clear some directories?
Please note that I am using NetBeans with designer V 1.1
.
Edit March 1st 2017
Following #Diamond's great tips, I was able to change the foreground color by setting the Border to empty (instead of NULL). However now the alignment is still not what I expect (see below). How can I do for this property ?
Any help appreciated,
In the Designer, Border is superior to background color and background image. Which means if the border image is set, a background color will have no effect unless the border is just a stroke or line.
Always solve this with these few steps:
Go to the Border tab and uncheck the override.
Click the ... button next to Border Help and a new Dialog will show.
Change the Type (First line) to Empty and click Ok.
Your background color will now have an effect.

Ellipse as mask for a label

I'm making a toggle button with a new design "material design" like. I have a problem with animation. I'm using an ellipse that expands and changes the color of the button where the mouse clicked. With color it works well but I want to make visible label as ellipse is over it and invisible the second one. I have an image to make it simplier to understand:
so the second image shows that where the green is it stills writes "Toggled" where it should already write "Untoggled" but still where blue color is, there should be writed "Toggled" then radialy changes. I have tried to use Opacity Mask but I couldn't get it to work. Anyone could help me?
Ok I did it animating EllipseGeometry, settings the label I want to display on top of the old one and clipping the top one to the EllipseGeometry.

Create a fully transparent WPF window to capture mouse events

I'm trying to trap mouse events in WPF by using a topmost, transparent non-modal window. I'm finding that this works fine if the opacity of the window is 0.01 or greater and it has a background color, but when the opacity is set to 0 it no longer receives mouse messages. Is there a way make this window look fully transparent and still get mouse input?
As far as I know, no.
When a Control or Window is fully transparent, it can then be clicked through. This is the case if you set your Window.Background="Transparent", or Opacity="0". As far as I know, this is by design in WPF.
When using an opacity of 0.01, you should barely see the window, if at all. This is likely your best bet at achieving the functionality.
Edit: Another solution, which I tried and does work, is to set the background color to an almost-transparent color. I used Background="#01000000", thus giving an alpha value of 1. This makes your window background transparent-looking, but allows you to place controls on it with the window at full opacity.
In Visual Studio 2010:
Select your window in your design view.
Set the properties of your window to:
AllowsTransparency : check it
Background : Transparent
WindowStyle : None
Just set Background=Brushes.Transparent instead of Background=null.
You don't need to use opacity at all (ie. just leave it at 100% opacity).
For example i think your control name is MyGrid and you want it be Transparent and always get MouseOverEvent.....
If (window AllowsTransparency is True and the window Background is Transparent) Then
use a color like #01777777 for MyGrid Background Or 0.01 for MyGrid Opacity.
Else
use something like #00777777 for MyGrid Background Or 0.00 for MyGrid Opacity.
Setting the opacity to 100% (or any non-zero value), and the background to Transparent (instead of null) should make most controls hittable.
Make sure to set IsHitTestVisible to true. Not all controls can be hit, even if the opacity is 100% and the background is transparent.
You might find it simpler to use Mouse.Capture.
https://msdn.microsoft.com/en-us/library/ms771301.aspx
When an object captures the mouse, all mouse related events are treated as if the object with mouse capture perform the event, even if the mouse pointer is over another object.

Resources