|
|
|
@ -1,28 +1,10 @@
|
|
|
|
import { useQuery } from "@tanstack/react-query"
|
|
|
|
import { useQuery } from "@tanstack/react-query"
|
|
|
|
import { getActivity, type getActivityArgs, type ListenActivityItem } from "api/api"
|
|
|
|
import { getActivity, type getActivityArgs, type ListenActivityItem } from "api/api"
|
|
|
|
import Popup from "./Popup"
|
|
|
|
import Popup from "./Popup"
|
|
|
|
import { useEffect, useState } from "react"
|
|
|
|
import { useState } from "react"
|
|
|
|
import { useTheme } from "~/hooks/useTheme"
|
|
|
|
import { useTheme } from "~/hooks/useTheme"
|
|
|
|
import ActivityOptsSelector from "./ActivityOptsSelector"
|
|
|
|
import ActivityOptsSelector from "./ActivityOptsSelector"
|
|
|
|
|
|
|
|
import { themes } from "~/styles/themes.css"
|
|
|
|
function getPrimaryColor(): string {
|
|
|
|
|
|
|
|
const value = getComputedStyle(document.documentElement)
|
|
|
|
|
|
|
|
.getPropertyValue('--color-primary')
|
|
|
|
|
|
|
|
.trim();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const rgbMatch = value.match(/^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/);
|
|
|
|
|
|
|
|
if (rgbMatch) {
|
|
|
|
|
|
|
|
const [, r, g, b] = rgbMatch.map(Number);
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
|
|
|
'#' +
|
|
|
|
|
|
|
|
[r, g, b]
|
|
|
|
|
|
|
|
.map((n) => n.toString(16).padStart(2, '0'))
|
|
|
|
|
|
|
|
.join('')
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return value;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
interface Props {
|
|
|
|
interface Props {
|
|
|
|
step?: string
|
|
|
|
step?: string
|
|
|
|
@ -47,7 +29,6 @@ export default function ActivityGrid({
|
|
|
|
configurable = false,
|
|
|
|
configurable = false,
|
|
|
|
}: Props) {
|
|
|
|
}: Props) {
|
|
|
|
|
|
|
|
|
|
|
|
const [color, setColor] = useState(getPrimaryColor())
|
|
|
|
|
|
|
|
const [stepState, setStep] = useState(step)
|
|
|
|
const [stepState, setStep] = useState(step)
|
|
|
|
const [rangeState, setRange] = useState(range)
|
|
|
|
const [rangeState, setRange] = useState(range)
|
|
|
|
|
|
|
|
|
|
|
|
@ -69,14 +50,8 @@ export default function ActivityGrid({
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const { theme } = useTheme();
|
|
|
|
const { theme } = useTheme();
|
|
|
|
useEffect(() => {
|
|
|
|
const currentTheme = themes.find(t => t.name === theme);
|
|
|
|
const raf = requestAnimationFrame(() => {
|
|
|
|
const color = currentTheme?.primary || '#f5a97f';
|
|
|
|
const color = getPrimaryColor()
|
|
|
|
|
|
|
|
setColor(color);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return () => cancelAnimationFrame(raf);
|
|
|
|
|
|
|
|
}, [theme]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (isPending) {
|
|
|
|
if (isPending) {
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
|