Skip to content

Commit

Permalink
feat: now button at budget page (#3703)
Browse files Browse the repository at this point in the history
* feat: now button on budget

* Update VRT

* chore: change to icon

* chore: rename to today

* chore: fix not being centered on multiple months

* Update VRT

* Update VRT

* Trigger Build

* fix: keep now button with monthpicker not left

* Update VRT

* fix: center MonthPicker

* Update VRT

* Trigger Build

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
UnderKoen and github-actions[bot] authored Dec 23, 2024
1 parent 8976ffc commit bd126b4
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 3 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.
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,16 @@ type BudgetPageHeaderProps = {

export const BudgetPageHeader = memo<BudgetPageHeaderProps>(
({ startMonth, onMonthSelect, numMonths, monthBounds }) => {
const offsetMultipleMonths = numMonths === 1 ? 4 : 0;
return (
<View style={{ marginLeft: 200 + 5, flexShrink: 0 }}>
<View style={{ marginRight: 5 + getScrollbarWidth() }}>
<View
style={{ marginLeft: 200 + 5 - offsetMultipleMonths, flexShrink: 0 }}
>
<View
style={{
marginRight: 5 + getScrollbarWidth() - offsetMultipleMonths,
}}
>
<MonthPicker
startMonth={startMonth}
numDisplayed={numMonths}
Expand Down
31 changes: 30 additions & 1 deletion packages/desktop-client/src/components/budget/MonthPicker.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
// @ts-strict-ignore
import { type CSSProperties, useState } from 'react';
import React, { type CSSProperties, useState } from 'react';
import { useTranslation } from 'react-i18next';

import * as monthUtils from 'loot-core/src/shared/months';

import { useResizeObserver } from '../../hooks/useResizeObserver';
import { SvgCalendar } from '../../icons/v2';
import { styles, theme } from '../../style';
import { Link } from '../common/Link';
import { View } from '../common/View';

import { type MonthBounds } from './MonthsContext';
Expand All @@ -24,6 +27,7 @@ export const MonthPicker = ({
style,
onSelect,
}: MonthPickerProps) => {
const { t } = useTranslation();
const [hoverId, setHoverId] = useState(null);
const [targetMonthCount, setTargetMonthCount] = useState(12);

Expand Down Expand Up @@ -78,6 +82,24 @@ export const MonthPicker = ({
justifyContent: 'center',
}}
>
<Link
variant="button"
buttonVariant="bare"
onPress={() => onSelect(currentMonth)}
style={{
padding: '3px 3px',
marginRight: '12px',
}}
>
<View title={t('Today')}>
<SvgCalendar
style={{
width: 16,
height: 16,
}}
/>
</View>
</Link>
{range.map((month, idx) => {
const monthName = monthUtils.format(month, 'MMM');
const selected =
Expand Down Expand Up @@ -184,6 +206,13 @@ export const MonthPicker = ({
</View>
);
})}
{/*Keep range centered*/}
<span
style={{
width: '22px',
marginLeft: '12px',
}}
/>
</View>
</View>
);
Expand Down
6 changes: 6 additions & 0 deletions upcoming-release-notes/3703.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Enhancements
authors: [UnderKoen]
---

Add button to go to current month in budget view

0 comments on commit bd126b4

Please sign in to comment.