diff --git a/CHANGELOG.md b/CHANGELOG.md index b628e57..78b2a81 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Features - Allow loading environment variables from files using the _FILE suffix (#20) +- All activity grids (calendar heatmaps) are now configurable ## Enhancements diff --git a/client/app/components/ActivityGrid.tsx b/client/app/components/ActivityGrid.tsx index c1778d3..16953df 100644 --- a/client/app/components/ActivityGrid.tsx +++ b/client/app/components/ActivityGrid.tsx @@ -50,11 +50,6 @@ export default function ActivityGrid({ const [color, setColor] = useState(getPrimaryColor()) const [stepState, setStep] = useState(step) const [rangeState, setRange] = useState(range) - - // sometimes, a little bit of a lie for the sake of better design is necessary - if (rangeState === 365) { - setRange(rangeState - 1) - } const { isPending, isError, data, error } = useQuery({ queryKey: [ diff --git a/client/app/components/ActivityOptsSelector.tsx b/client/app/components/ActivityOptsSelector.tsx index dfca078..53a84c1 100644 --- a/client/app/components/ActivityOptsSelector.tsx +++ b/client/app/components/ActivityOptsSelector.tsx @@ -17,17 +17,15 @@ export default function ActivityOptsSelector({ disableCache = false, }: Props) { const stepPeriods = ['day', 'week', 'month', 'year']; - const rangePeriods = [105, 182, 365]; - + const rangePeriods = [105, 182, 364]; const [collapsed, setCollapsed] = useState(true); - const stepDisplay = (str: string): string => - str.split('_').map(w => - w.split('').map((char, index) => - index === 0 ? char.toUpperCase() : char).join('') - ).join(' '); - - const rangeDisplay = (r: number): string => `${r}`; + const setMenuOpen = (val: boolean) => { + setCollapsed(val) + if (!disableCache) { + localStorage.setItem('activity_configuring_' + window.location.pathname.split('/')[1], String(!val)); + } + } const setStep = (val: string) => { stepSetter(val); @@ -49,57 +47,60 @@ export default function ActivityOptsSelector({ if (cachedRange) rangeSetter(cachedRange); const cachedStep = localStorage.getItem('activity_step_' + window.location.pathname.split('/')[1]); if (cachedStep) stepSetter(cachedStep); + const cachedConfiguring = localStorage.getItem('activity_configuring_' + window.location.pathname.split('/')[1]); + if (cachedStep) setMenuOpen(cachedConfiguring !== "true"); } }, []); return ( -
Step:
- {stepPeriods.map((p, i) => ( -Range:
- {rangePeriods.map((r, i) => ( -