Skip to content

Commit

Permalink
Mobile reports (#2624)
Browse files Browse the repository at this point in the history
* mobile reports

* notes

* header updates

* hide tooltip in mobile view

* visual updates

* padding changes

* VRT

* bottom padding

* merge fixes

* VRT

* unselectable

* merge fixes
  • Loading branch information
carkom committed Apr 24, 2024
1 parent 6ec3728 commit 469c789
Show file tree
Hide file tree
Showing 21 changed files with 239 additions and 135 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 2 additions & 9 deletions packages/desktop-client/src/components/FinancesApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,15 +163,7 @@ function FinancesAppWithoutContext() {
<Routes>
<Route path="/" element={<Navigate to="/budget" replace />} />

<Route
path="/reports/*"
element={
<NarrowNotSupported>
{/* Has its own lazy loading logic */}
<Reports />
</NarrowNotSupported>
}
/>
<Route path="/reports/*" element={<Reports />} />

<Route
path="/budget"
Expand Down Expand Up @@ -239,6 +231,7 @@ function FinancesAppWithoutContext() {
<Route path="/budget" element={<MobileNavTabs />} />
<Route path="/accounts" element={<MobileNavTabs />} />
<Route path="/settings" element={<MobileNavTabs />} />
<Route path="/reports" element={<MobileNavTabs />} />
<Route path="*" element={null} />
</Routes>
</View>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
SvgTuning,
SvgWallet,
} from '../../icons/v1';
import { SvgReports } from '../../icons/v1/Reports';
import { SvgCalendar } from '../../icons/v2';
import { useResponsive } from '../../ResponsiveProvider';
import { theme, styles, type CSSProperties } from '../../style';
Expand Down Expand Up @@ -54,6 +55,12 @@ export function MobileNavTabs() {
style: navTabStyle,
Icon: SvgPiggyBank,
},
{
name: 'Reports',
path: '/reports',
style: navTabStyle,
Icon: SvgReports,
},
{
name: 'Schedules (Soon)',
path: '/schedules/soon',
Expand Down
84 changes: 47 additions & 37 deletions packages/desktop-client/src/components/reports/Header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useLocation } from 'react-router-dom';
import * as monthUtils from 'loot-core/src/shared/months';

import { SvgArrowLeft } from '../../icons/v1';
import { useResponsive } from '../../ResponsiveProvider';
import { styles } from '../../style';
import { Button } from '../common/Button';
import { Link } from '../common/Link';
Expand Down Expand Up @@ -36,6 +37,7 @@ export function Header({
}) {
const location = useLocation();
const path = location.pathname;
const { isNarrowWidth } = useResponsive();

return (
<View
Expand All @@ -58,8 +60,8 @@ export function Header({
{path !== '/reports/custom' && (
<View
style={{
flexDirection: 'row',
alignItems: 'center',
flexDirection: isNarrowWidth ? 'column' : 'row',
alignItems: isNarrowWidth ? 'right' : 'center',
marginTop: 15,
gap: 15,
}}
Expand Down Expand Up @@ -103,45 +105,53 @@ export function Header({
/>
</View>

{filters && <FilterButton onApply={onApply} type="accounts" />}

{show1Month && (
{!isNarrowWidth && filters && (
<FilterButton onApply={onApply} type="accounts" />
)}
<View
style={{
flexDirection: 'row',
alignItems: 'center',
gap: 15,
}}
>
{show1Month && (
<Button
type="bare"
onClick={() => onChangeDates(...getLatestRange(1))}
>
1 month
</Button>
)}
<Button
type="bare"
onClick={() => onChangeDates(...getLatestRange(1))}
onClick={() => onChangeDates(...getLatestRange(2))}
>
1 month
3 months
</Button>
)}
<Button
type="bare"
onClick={() => onChangeDates(...getLatestRange(2))}
>
3 months
</Button>
<Button
type="bare"
onClick={() => onChangeDates(...getLatestRange(5))}
>
6 months
</Button>
<Button
type="bare"
onClick={() => onChangeDates(...getLatestRange(11))}
>
1 Year
</Button>
<Button
type="bare"
onClick={() =>
onChangeDates(
...getFullRange(allMonths[allMonths.length - 1].name),
)
}
>
All Time
</Button>

<Button
type="bare"
onClick={() => onChangeDates(...getLatestRange(5))}
>
6 months
</Button>
<Button
type="bare"
onClick={() => onChangeDates(...getLatestRange(11))}
>
1 Year
</Button>
<Button
type="bare"
onClick={() =>
onChangeDates(
...getFullRange(allMonths[allMonths.length - 1].name),
)
}
>
All Time
</Button>
</View>
{children || <View style={{ flex: 1 }} />}
</View>
)}
Expand Down
12 changes: 9 additions & 3 deletions packages/desktop-client/src/components/reports/Overview.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useReports } from 'loot-core/src/client/data-hooks/reports';

import { useAccounts } from '../../hooks/useAccounts';
import { useFeatureFlag } from '../../hooks/useFeatureFlag';
import { useResponsive } from '../../ResponsiveProvider';
import { styles } from '../../style';
import { Button } from '../common/Button';
import { Link } from '../common/Link';
Expand All @@ -17,6 +18,7 @@ import { NetWorthCard } from './reports/NetWorthCard';

export function Overview() {
const customReports = useReports();
const { isNarrowWidth } = useResponsive();

const location = useLocation();
sessionStorage.setItem('url', location.pathname);
Expand All @@ -28,10 +30,14 @@ export function Overview() {
<View
style={{
...styles.page,
...{ paddingLeft: 40, paddingRight: 40, minWidth: 700 },
...{
padding: 15,
paddingTop: 0,
minWidth: isNarrowWidth ? null : 700,
},
}}
>
{customReportsFeatureFlag && (
{customReportsFeatureFlag && !isNarrowWidth && (
<View
style={{
flex: '0 0 auto',
Expand All @@ -49,7 +55,7 @@ export function Overview() {
)}
<View
style={{
flexDirection: 'row',
flexDirection: isNarrowWidth ? 'column' : 'row',
flex: '0 0 auto',
}}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
import { type GroupedEntity } from 'loot-core/src/types/models/reports';

import { usePrivacyMode } from '../../../hooks/usePrivacyMode';
import { useResponsive } from '../../../ResponsiveProvider';
import { theme } from '../../../style';
import { type CSSProperties } from '../../../style';
import { AlignedText } from '../../common/AlignedText';
Expand Down Expand Up @@ -125,6 +126,7 @@ export function AreaGraph({
viewLabels,
}: AreaGraphProps) {
const privacyMode = usePrivacyMode();
const { isNarrowWidth } = useResponsive();
const dataMax = Math.max(...data.intervalData.map(i => i[balanceTypeOp]));
const dataMin = Math.min(...data.intervalData.map(i => i[balanceTypeOp]));

Expand Down Expand Up @@ -211,11 +213,13 @@ export function AreaGraph({
tickSize={0}
/>
)}
<Tooltip
content={<CustomTooltip balanceTypeOp={balanceTypeOp} />}
formatter={numberFormatterTooltip}
isAnimationActive={false}
/>
{(!isNarrowWidth || !compact) && (
<Tooltip
content={<CustomTooltip balanceTypeOp={balanceTypeOp} />}
formatter={numberFormatterTooltip}
isAnimationActive={false}
/>
)}
<defs>
<linearGradient
id={`fill${balanceTypeOp}`}
Expand Down
30 changes: 18 additions & 12 deletions packages/desktop-client/src/components/reports/graphs/BarGraph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { useAccounts } from '../../../hooks/useAccounts';
import { useCategories } from '../../../hooks/useCategories';
import { useNavigate } from '../../../hooks/useNavigate';
import { usePrivacyMode } from '../../../hooks/usePrivacyMode';
import { useResponsive } from '../../../ResponsiveProvider';
import { type CSSProperties } from '../../../style';
import { theme } from '../../../style/index';
import { AlignedText } from '../../common/AlignedText';
Expand Down Expand Up @@ -157,6 +158,7 @@ export function BarGraph({
const categories = useCategories();
const accounts = useAccounts();
const privacyMode = usePrivacyMode();
const { isNarrowWidth } = useResponsive();
const [pointer, setPointer] = useState('');

const yAxis = groupBy === 'Interval' ? 'date' : 'name';
Expand Down Expand Up @@ -261,17 +263,19 @@ export function BarGraph({
bottom: 0,
}}
>
<Tooltip
cursor={{ fill: 'transparent' }}
content={
<CustomTooltip
balanceTypeOp={balanceTypeOp}
yAxis={yAxis}
/>
}
formatter={numberFormatterTooltip}
isAnimationActive={false}
/>
{(!isNarrowWidth || !compact) && (
<Tooltip
cursor={{ fill: 'transparent' }}
content={
<CustomTooltip
balanceTypeOp={balanceTypeOp}
yAxis={yAxis}
/>
}
formatter={numberFormatterTooltip}
isAnimationActive={false}
/>
)}
{!compact && (
<>
<CartesianGrid strokeDasharray="3 3" />
Expand Down Expand Up @@ -306,7 +310,9 @@ export function BarGraph({
setPointer('pointer')
}
onClick={
!['Group', 'Interval'].includes(groupBy) && onShowActivity
!isNarrowWidth &&
!['Group', 'Interval'].includes(groupBy) &&
onShowActivity
}
>
{viewLabels && !compact && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { type RuleConditionEntity } from 'loot-core/types/models/rule';
import { useAccounts } from '../../../hooks/useAccounts';
import { useCategories } from '../../../hooks/useCategories';
import { useNavigate } from '../../../hooks/useNavigate';
import { useResponsive } from '../../../ResponsiveProvider';
import { theme, type CSSProperties } from '../../../style';
import { PrivacyFilter } from '../../PrivacyFilter';
import { Container } from '../Container';
Expand Down Expand Up @@ -203,6 +204,7 @@ export function DonutGraph({
const navigate = useNavigate();
const categories = useCategories();
const accounts = useAccounts();
const { isNarrowWidth } = useResponsive();
const [pointer, setPointer] = useState('');

const onShowActivity = item => {
Expand Down Expand Up @@ -308,7 +310,9 @@ export function DonutGraph({
}
}}
onClick={
!['Group', 'Interval'].includes(groupBy) && onShowActivity
!isNarrowWidth &&
!['Group', 'Interval'].includes(groupBy) &&
onShowActivity
}
>
{data.legend.map((entry, index) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { useAccounts } from '../../../hooks/useAccounts';
import { useCategories } from '../../../hooks/useCategories';
import { useNavigate } from '../../../hooks/useNavigate';
import { usePrivacyMode } from '../../../hooks/usePrivacyMode';
import { useResponsive } from '../../../ResponsiveProvider';
import { theme } from '../../../style';
import { type CSSProperties } from '../../../style';
import { AlignedText } from '../../common/AlignedText';
Expand Down Expand Up @@ -133,6 +134,7 @@ export function LineGraph({
const privacyMode = usePrivacyMode();
const [pointer, setPointer] = useState('');
const [tooltip, setTooltip] = useState('');
const { isNarrowWidth } = useResponsive();

const largestValue = data.intervalData
.map(c => c[balanceTypeOp])
Expand Down Expand Up @@ -206,13 +208,15 @@ export function LineGraph({
margin={{ top: 10, right: 10, left: leftMargin, bottom: 10 }}
style={{ cursor: pointer }}
>
<Tooltip
content={
<CustomTooltip compact={compact} tooltip={tooltip} />
}
formatter={numberFormatterTooltip}
isAnimationActive={false}
/>
{(!isNarrowWidth || !compact) && (
<Tooltip
content={
<CustomTooltip compact={compact} tooltip={tooltip} />
}
formatter={numberFormatterTooltip}
isAnimationActive={false}
/>
)}
{!compact && (
<>
<CartesianGrid strokeDasharray="3 3" />
Expand Down Expand Up @@ -255,6 +259,7 @@ export function LineGraph({
setTooltip('');
},
onClick: (e, payload) =>
!isNarrowWidth &&
!['Group', 'Interval'].includes(groupBy) &&
onShowActivity(e, entry.id, payload),
}}
Expand Down
Loading

0 comments on commit 469c789

Please sign in to comment.