Increase stroke width on hover
This commit is contained in:
1 parent
daa1e07ef8
commit
e8cb09c168
6 files changed
+27
-13
No files matched your search
@@ -10,7 +10,7 @@ import {
|
|||||||
} from "recharts";
|
} from "recharts";
|
||||||
import { Box, Stack, Typography } from "@mui/material";
|
import { Box, Stack, Typography } from "@mui/material";
|
||||||
import { useTheme } from "@emotion/react";
|
import { useTheme } from "@emotion/react";
|
||||||
import { useMemo } from "react";
|
import { useMemo, useState } from "react";
|
||||||
import { useSelector } from "react-redux";
|
import { useSelector } from "react-redux";
|
||||||
import { formatDateWithTz } from "../../../Utils/timeUtils";
|
import { formatDateWithTz } from "../../../Utils/timeUtils";
|
||||||
import "./index.css";
|
import "./index.css";
|
||||||
@@ -112,6 +112,7 @@ CustomTick.propTypes = {
|
|||||||
const MonitorDetailsAreaChart = ({ checks }) => {
|
const MonitorDetailsAreaChart = ({ checks }) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const memoizedChecks = useMemo(() => checks, [checks[0]]);
|
const memoizedChecks = useMemo(() => checks, [checks[0]]);
|
||||||
|
const [isHovered, setIsHovered] = useState(false);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ResponsiveContainer width="100%" minWidth={25} height={220}>
|
<ResponsiveContainer width="100%" minWidth={25} height={220}>
|
||||||
@@ -125,6 +126,8 @@ const MonitorDetailsAreaChart = ({ checks }) => {
|
|||||||
left: 0,
|
left: 0,
|
||||||
bottom: 0,
|
bottom: 0,
|
||||||
}}
|
}}
|
||||||
|
onMouseMove={() => setIsHovered(true)}
|
||||||
|
onMouseLeave={() => setIsHovered(false)}
|
||||||
>
|
>
|
||||||
<CartesianGrid
|
<CartesianGrid
|
||||||
stroke={theme.palette.border.light}
|
stroke={theme.palette.border.light}
|
||||||
@@ -160,13 +163,14 @@ const MonitorDetailsAreaChart = ({ checks }) => {
|
|||||||
<Tooltip
|
<Tooltip
|
||||||
cursor={{ stroke: theme.palette.border.light }}
|
cursor={{ stroke: theme.palette.border.light }}
|
||||||
content={<CustomToolTip />}
|
content={<CustomToolTip />}
|
||||||
|
wrapperStyle={{ pointerEvents: "none" }}
|
||||||
/>
|
/>
|
||||||
<Area
|
<Area
|
||||||
type="monotone"
|
type="monotone"
|
||||||
dataKey="responseTime"
|
dataKey="responseTime"
|
||||||
stroke={theme.palette.primary.main}
|
stroke={theme.palette.primary.main}
|
||||||
fill="url(#colorUv)"
|
fill="url(#colorUv)"
|
||||||
strokeWidth={1.5}
|
strokeWidth={isHovered ? 2.5 : 1.5}
|
||||||
activeDot={{ stroke: theme.palette.background.main, r: 5 }}
|
activeDot={{ stroke: theme.palette.background.main, r: 5 }}
|
||||||
/>
|
/>
|
||||||
</AreaChart>
|
</AreaChart>
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ export const ChartBox = styled(Stack)(({ theme }) => ({
|
|||||||
},
|
},
|
||||||
"& path": {
|
"& path": {
|
||||||
transition: "fill 300ms ease",
|
transition: "fill 300ms ease",
|
||||||
|
transition: "stroke-width 400ms ease",
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|||||||
@@ -40,9 +40,9 @@ const useUtils = () => {
|
|||||||
"& h2": { color: theme.palette.error.main },
|
"& h2": { color: theme.palette.error.main },
|
||||||
},
|
},
|
||||||
paused: {
|
paused: {
|
||||||
backgroundColor: theme.palette.warning.light,
|
backgroundColor: theme.palette.warning.bg,
|
||||||
background: `linear-gradient(340deg, ${theme.palette.warning.dark} -60%, ${theme.palette.warning.light} 35%)`,
|
background: `linear-gradient(340deg, ${theme.palette.warning.light} -60%, ${theme.palette.warning.bg} 35%)`,
|
||||||
borderColor: theme.palette.warning.dark,
|
borderColor: theme.palette.warning.light,
|
||||||
"& h2": { color: theme.palette.warning.main },
|
"& h2": { color: theme.palette.warning.main },
|
||||||
},
|
},
|
||||||
pending: {
|
pending: {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import {
|
|||||||
Text,
|
Text,
|
||||||
} from "recharts";
|
} from "recharts";
|
||||||
import { useTheme } from "@emotion/react";
|
import { useTheme } from "@emotion/react";
|
||||||
import { useMemo } from "react";
|
import { useMemo, useState } from "react";
|
||||||
import { Box, Stack, Typography } from "@mui/material";
|
import { Box, Stack, Typography } from "@mui/material";
|
||||||
import { formatDateWithTz } from "../../../../Utils/timeUtils";
|
import { formatDateWithTz } from "../../../../Utils/timeUtils";
|
||||||
import { useSelector } from "react-redux";
|
import { useSelector } from "react-redux";
|
||||||
@@ -215,6 +215,7 @@ CustomTick.propTypes = {
|
|||||||
|
|
||||||
const PagespeedDetailsAreaChart = ({ data, interval, metrics }) => {
|
const PagespeedDetailsAreaChart = ({ data, interval, metrics }) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
|
const [isHovered, setIsHovered] = useState(false);
|
||||||
const memoizedData = useMemo(
|
const memoizedData = useMemo(
|
||||||
() => processDataWithGaps(data, interval),
|
() => processDataWithGaps(data, interval),
|
||||||
[data[0]]
|
[data[0]]
|
||||||
@@ -234,6 +235,8 @@ const PagespeedDetailsAreaChart = ({ data, interval, metrics }) => {
|
|||||||
height="100%"
|
height="100%"
|
||||||
data={memoizedData}
|
data={memoizedData}
|
||||||
margin={{ top: 10 }}
|
margin={{ top: 10 }}
|
||||||
|
onMouseMove={() => setIsHovered(true)}
|
||||||
|
onMouseLeave={() => setIsHovered(false)}
|
||||||
>
|
>
|
||||||
<CartesianGrid
|
<CartesianGrid
|
||||||
stroke={theme.palette.border.light}
|
stroke={theme.palette.border.light}
|
||||||
@@ -281,7 +284,7 @@ const PagespeedDetailsAreaChart = ({ data, interval, metrics }) => {
|
|||||||
dataKey={key}
|
dataKey={key}
|
||||||
stackId={1}
|
stackId={1}
|
||||||
stroke={strokeColor}
|
stroke={strokeColor}
|
||||||
strokeWidth={1.5}
|
strokeWidth={isHovered ? 2.5 : 1.5}
|
||||||
fill={`url(#${filteredConfig[key].id})`}
|
fill={`url(#${filteredConfig[key].id})`}
|
||||||
activeDot={{ stroke: bgColor, fill: strokeColor, r: 4.5 }}
|
activeDot={{ stroke: bgColor, fill: strokeColor, r: 4.5 }}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -36,6 +36,9 @@ export const ChartBox = styled(Stack)(({ theme }) => ({
|
|||||||
backgroundColor: theme.palette.background.main,
|
backgroundColor: theme.palette.background.main,
|
||||||
background: `linear-gradient(325deg, ${theme.palette.background.accent} 20%, ${theme.palette.background.main} 45%)`,
|
background: `linear-gradient(325deg, ${theme.palette.background.accent} 20%, ${theme.palette.background.main} 45%)`,
|
||||||
},
|
},
|
||||||
|
"& path": {
|
||||||
|
transition: "stroke-width 400ms ease",
|
||||||
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
export const IconBox = styled(Box)(({ theme }) => ({
|
export const IconBox = styled(Box)(({ theme }) => ({
|
||||||
|
|||||||
@@ -13,12 +13,9 @@ import {
|
|||||||
Tooltip,
|
Tooltip,
|
||||||
} from "recharts";
|
} from "recharts";
|
||||||
import { useSelector } from "react-redux";
|
import { useSelector } from "react-redux";
|
||||||
import {
|
import { formatDateWithTz, formatDurationSplit } from "../../Utils/timeUtils";
|
||||||
formatDateWithTz,
|
|
||||||
formatDurationRounded,
|
|
||||||
formatDurationSplit,
|
|
||||||
} from "../../Utils/timeUtils";
|
|
||||||
import useUtils from "../Monitors/utils";
|
import useUtils from "../Monitors/utils";
|
||||||
|
import { useState } from "react";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CustomToolTip displays a tooltip with formatted date and score information.
|
* CustomToolTip displays a tooltip with formatted date and score information.
|
||||||
@@ -127,6 +124,7 @@ const processData = (data) => {
|
|||||||
*/
|
*/
|
||||||
const PagespeedAreaChart = ({ data, status }) => {
|
const PagespeedAreaChart = ({ data, status }) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
|
const [isHovered, setIsHovered] = useState(false);
|
||||||
const { pagespeedStyles } = useUtils();
|
const { pagespeedStyles } = useUtils();
|
||||||
|
|
||||||
const formattedData = processData(data);
|
const formattedData = processData(data);
|
||||||
@@ -139,6 +137,8 @@ const PagespeedAreaChart = ({ data, status }) => {
|
|||||||
data={formattedData}
|
data={formattedData}
|
||||||
margin={{ top: 10, bottom: -5 }}
|
margin={{ top: 10, bottom: -5 }}
|
||||||
style={{ cursor: "pointer" }}
|
style={{ cursor: "pointer" }}
|
||||||
|
onMouseMove={() => setIsHovered(true)}
|
||||||
|
onMouseLeave={() => setIsHovered(false)}
|
||||||
>
|
>
|
||||||
<CartesianGrid
|
<CartesianGrid
|
||||||
stroke={theme.palette.border.light}
|
stroke={theme.palette.border.light}
|
||||||
@@ -174,7 +174,7 @@ const PagespeedAreaChart = ({ data, status }) => {
|
|||||||
<Area
|
<Area
|
||||||
dataKey="score"
|
dataKey="score"
|
||||||
stroke={pagespeedStyles[status].stroke}
|
stroke={pagespeedStyles[status].stroke}
|
||||||
strokeWidth={1.5}
|
strokeWidth={isHovered ? 2.5 : 1.5}
|
||||||
fill={`url(#pagespeed-chart-${status})`}
|
fill={`url(#pagespeed-chart-${status})`}
|
||||||
activeDot={{
|
activeDot={{
|
||||||
stroke: pagespeedStyles[status].light,
|
stroke: pagespeedStyles[status].light,
|
||||||
@@ -230,6 +230,9 @@ const Card = ({ monitor }) => {
|
|||||||
"&:hover": {
|
"&:hover": {
|
||||||
backgroundColor: theme.palette.background.accent,
|
backgroundColor: theme.palette.background.accent,
|
||||||
},
|
},
|
||||||
|
"& path": {
|
||||||
|
transition: "stroke-width 400ms ease",
|
||||||
|
},
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<IconBox>
|
<IconBox>
|
||||||
|
|||||||
Reference in new issue
Block a user