I want to apply these certain styles to my react leaflet map when the user clicks a button to signal that they want a dark themed map or a light themed one but I am not entirely sure how to go about setting up the styles object properly I have created a function to determine the state being light or dark to decide what styles to apply to the map and then the function but not sure if I should have a state for the styles or if I should just have separate style objects and I am also not entirely sure how to adjust the react leaflet map to apply a dark themed to it I have looked around but cannot seem to find any resources on how to
Map component:
import react from 'react';
import { useState, useEffect} from 'react';
import { MapContainer, TileLayer, Popup} from 'react-leaflet';
import MapComp from './MapComp';
function Map() {
const [activities, setActivities] = useState([]);
const [polylines, setPolylines] = useState(null); // as empty array value is still truthy
const [isLoading, setIsLoading] = useState(true);
const [mapMode, setMapMode] = useState('light');
const [mapStyle, setMapStyle] = useState({});
/*
*/
function changeMapStyle() {
if(mapMode === 'light') {
setMapMode('dark');
}
else {
setMapMode('light');
}
}
return (
<>
<button onClick={changeMapStyle}>Change Map style</button>
<MapComp className={`${mapMode}`} style={{ width: "100%", height: "calc(100vh - 4rem)" }}/>
</>
)
}
export default Map;
unsure about this file as I do not think the styles apply correctly to the map. Styles where sourced at https://github.com/pkrasicki/issviewer/blob/master/public/css/dark-theme.css
these styles where applied to vanilla js so that is why I am unsure.
style file:
.dark {
--background: rgb(40, 44, 54);
--nav-background: rgba(0, 0, 0, 0.7);
--text: rgba(255, 255, 255, 0.85);
--link: rgb(122, 191, 255);
--link-hover: rgb(143, 200, 253);
--text-label-color: rgb(255, 95, 95);
--location-input-bg: rgba(0, 0, 0, 0.2);
--location-input-color: rgba(255, 255, 255, 0.9);
--location-input-border: transparent;
--map-background: #1f1f1f;
--map-border: rgba(255, 255, 255, 0.1);
--map-tiles-filter: brightness(0.6) invert(1) contrast(3) hue-rotate(200deg) saturate(0.3) brightness(0.7);
--map-attribution-bg: rgba(0, 0, 0, 0.6);
--map-attribution-color: rgb(161, 161, 161);
--map-zoom-bg: rgb(26, 26, 26);
--map-zoom-border-bottom: rgba(255, 255, 255, 0.3);
--brightness-bar-full: var(--primary);
--spinner-color: var(--primary);
width: "100%";
height: "calc(100vh - 4rem)"
}
.light {
width: "100%";
height: "calc(100vh - 4rem)"
}
#media(prefers-color-scheme: dark) {
:root {
--background: rgb(40, 44, 54);
--nav-background: rgba(0, 0, 0, 0.7);
--text: rgba(255, 255, 255, 0.85);
--link: rgb(122, 191, 255);
--link-hover: rgb(143, 200, 253);
--text-label-color: rgb(255, 95, 95);
--location-input-bg: rgba(0, 0, 0, 0.2);
--location-input-color: rgba(255, 255, 255, 0.9);
--location-input-border: transparent;
--map-background: #1f1f1f;
--map-border: rgba(255, 255, 255, 0.1);
--map-tiles-filter: brightness(0.6) invert(1) contrast(3) hue-rotate(200deg) saturate(0.3) brightness(0.7);
--map-attribution-bg: rgba(0, 0, 0, 0.6);
--map-attribution-color: rgb(161, 161, 161);
--map-zoom-bg: rgb(26, 26, 26);
--map-zoom-border-bottom: rgba(255, 255, 255, 0.3);
--brightness-bar-full: var(--primary);
--spinner-color: var(--primary);
}
}
Related
is there anymethod which I can Display CurrentColor with Opacity in Rgba from Colors List using SASS/SCSS?
My Colors List :
$colors: (
"transparent": (
hex: transparent,
rgb: (0, 0, 0)
),
"current": (
hex: currentColor,
rgb: (255, 255, 255)
),
"white": (
hex: #FFFFFF,
rgb: (255, 255, 255)
),
"black": (
hex: #000000,
rgb: (0, 0, 0)
),
) !default;
The result that I expected after compiling to CSS :
.color-transparent {
--color-opacity: 0;
--color-var: transparent;
color: (var(--color-var), rgba(0, 0, 0, var(--color-opacity)));
}
.color-current {
--color-opacity: 0;
--color-var: currentColor;
color: (var(--color-var), rgba(255, 255, 255, var(--color-opacity)));
}
.color-white {
--color-opacity: 0;
--color-var: #FFFFFF;
color: (var(--color-var), rgba(255, 255, 255, var(--color-opacity)));
}
.color-black {
--color-opacity: 0;
--color-var: #000000;
color: (var(--color-var), rgba(0, 0, 0, var(--color-opacity)));
}
Here's how you do it:
$colors: (
"transparent": (
hex: transparent,
rgb: (0, 0, 0)
),
"current": (
hex: currentColor,
rgb: (255, 255, 255)
),
"white": (
hex: #FFFFFF,
rgb: (255, 255, 255)
),
"black": (
hex: #000000,
rgb: (0, 0, 0)
),
) !default;
// $COLOR = KEY, $VALUE = VALUE, $COLORS = MAP
#each $color, $values in $colors {
.color-#{$color} {
--color-opacity: 0;
#each $value, $subvalue in $values {
#if $value == 'hex' {
--color-var: #{$subvalue};
} #else {
color: ( var(--color-var), rgba( #{$subvalue}, var(--color-opacity)));
}
}
}
}
CSS OUTPUT
.color-transparent {
--color-opacity: 0;
--color-var: transparent;
color: var(--color-var), rgba(0, 0, 0, var(--color-opacity));
}
.color-current {
--color-opacity: 0;
--color-var: currentColor;
color: var(--color-var), rgba(255, 255, 255, var(--color-opacity));
}
.color-white {
--color-opacity: 0;
--color-var: #FFFFFF;
color: var(--color-var), rgba(255, 255, 255, var(--color-opacity));
}
.color-black {
--color-opacity: 0;
--color-var: #000000;
color: var(--color-var), rgba(0, 0, 0, var(--color-opacity));
}
I am looking for how to create a QT button with multiple color in background color.
Button should look like this
if using a QPushButton then you can play with the stylesheet
for example setting following style to a button
background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:1, stop:0 rgba(255, 255, 255, 255), stop:0.495 rgba(255, 255, 255, 255), stop:0.505 rgba(255, 0, 0, 255), stop:1 rgba(255, 0, 0, 255));
will produce this button
I've been working on this for hours and have 0 idea what to do.
Although I think I have it right, it's saying that it is wrong. I have no idea what else to do.
The question says: The page contains a review within a block quote. Go to the Blockquote Styles section and create a style rule for the blockquote element that sets the background color to rgb(173, 189, 227) and the text color to the rgb(255, 255, 255) with an opacity of 0.65.
Here is my CSS code:
blockquote {
background-color: rgb(173, 189, 227);
color: rgb(255, 255, 255);
opacity: 0.65;
}
The problem with your solution is how you're interpreting this part: "... and the text color to the rgb(255, 255, 255) with an opacity of 0.65.". It's asking to set the opacity of the text to 0.65, not of the entire element.
Using rgba should get it right:
blockquote {
background-color: rgb(173, 189, 227);
color: rgba(255, 255, 255, 0.65);
}
This question already has answers here:
Use CSS3 transitions with gradient backgrounds
(19 answers)
Closed 8 years ago.
I have one question about transition effect. I created this fiddle
I want to add a transition effect for hover. But it is not working. Anyone can help me here ?
.h_grid_2 .gradient_c_grd_2 {
position:absolute;
width:384px;
height:200px;
z-index:1;
background: -moz-linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.8));
background: -webkit-linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.8));
background: linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.8));
-webkit-transition: 1s all;
transition: 1s all;
}
.h_grid_2:hover .gradient_c_grd_2 {
position:absolute;
width:384px;
height:200px;
z-index:1;
background: -moz-linear-gradient(rgba(255, 255, 255, 0), rgba(255, 255, 255, 0), rgba(255 255, 255, 0.2));
background: -webkit-linear-gradient(rgba(255, 255, 255, 0), rgba(255, 255, 255, 0, 0), rgba(255, 255, 255, 0.2));
background: linear-gradient(rgba(255, 255, 255, 0), rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.2));
-webkit-transition: 1s all;
transition: 1s all;
}
Checkout my way: http://jsfiddle.net/gqLgu7jw/1/
The idea is to add another div (.gradient_c_grd_3) and use styles like these:
.h_grid_2:hover .gradient_c_grd_3{
opacity: 1;
}
.h_grid_2:hover .gradient_c_grd_2 {
opacity: 0;
}
This is impossible for now! CSS transitions do not support background images yet.
But you can play with ghe background-size and background-position:
Quoted from Animating CSS3 Gradients:
... since CSS3 gradients are not really properties, but are actually
images created by the browser, they aren’t in that list of animatable
properties. But that doesn’t mean you can’t animate gradients.
Gradients, just like standard images, are subject to certain
background-related properties that are animatable. These include
background-size and background-position.
For some basic code-snippets and examples incorporating this idea, I suggest you have a look at the above website.
I need to completely remove or override specifically the gradient on the select element. I've downloaded a custom copy of Bootstrap, without the form components, and the select element appears the way i need, but everything else is obviously gone, and i only need to remove the select gradient.
Thanks.
The gradients will be on the .btn-* class (assuming you're using button dropdowns).
For example (with btn-primary):
.btn-primary {
color: #ffffff;
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
background-color: #006dcc;
*background-color: #0044cc;
background-image: -moz-linear-gradient(top, #0088cc, #0044cc);
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#0088cc), to(#0044cc));
background-image: -webkit-linear-gradient(top, #0088cc, #0044cc);
background-image: -o-linear-gradient(top, #0088cc, #0044cc);
background-image: linear-gradient(to bottom, #0088cc, #0044cc);
background-repeat: repeat-x;
border-color: #0044cc #0044cc #002a80;
border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff0088cc', endColorstr='#ff0044cc', GradientType=0);
filter: progid:DXImageTransform.Microsoft.gradient(enabled=false);
}
To remove the gradient, you'd simply remove all the background properties (including the filters at the bottom) apart from background-color;:
.btn-primary {
color: #ffffff;
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
background-color: #006dcc;
border-color: #0044cc #0044cc #002a80;
border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
}
You'd also want to finish up by using a single-color border:
.btn-primary {
color: #ffffff;
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
background-color: #006dcc;
border-color: #0044cc;
}
You'd also need to do the same for the .btn-*:hover, :focus and :active styles.
Comment by Herr_Hansen works for me.
For Safari, try adding -webkit-appearance:none; to <select> with CSS
In my case, I found the gradient styles were in the bootstrap.theme.css I was loading with my other styles. Once I removed this file, all went back to normal.