A local-first personal finance app
Implement responsive DateSelect component for mobile view (#5607)
Matiss Janis Aboltinse8d93fb79764
diff --git a/packages/desktop-client/src/components/select/DateSelect.tsx b/packages/desktop-client/src/components/select/DateSelect.tsxindex 14f1f10c81..dc2b520750 100644--- a/packages/desktop-client/src/components/select/DateSelect.tsx+++ b/packages/desktop-client/src/components/select/DateSelect.tsx@@ -12,6 +12,7 @@ import React, {type RefObject,} from 'react';+import { useResponsive } from '@actual-app/components/hooks/useResponsive';import { Input } from '@actual-app/components/input';import { Popover } from '@actual-app/components/popover';import { styles, type CSSProperties } from '@actual-app/components/styles';@@ -29,8 +30,6 @@ import {} from 'date-fns';import Pikaday from 'pikaday';-import 'pikaday/css/pikaday.css';-import {getDayMonthFormat,getDayMonthRegex,@@ -39,9 +38,12 @@ import {currentDate,} from 'loot-core/shared/months';+import 'pikaday/css/pikaday.css';+import DateSelectLeft from './DateSelect.left.png';import DateSelectRight from './DateSelect.right.png';+import { InputField } from '@desktop-client/components/mobile/MobileForms';import { useLocale } from '@desktop-client/hooks/useLocale';import { useSyncedPref } from '@desktop-client/hooks/useSyncedPref';@@ -239,7 +241,7 @@ type DateSelectProps = {onSelect: (selectedDate: string) => void;};-export function DateSelect({+function DateSelectDesktop({id,containerProps,inputProps,@@ -459,3 +461,28 @@ export function DateSelect({</View>);}++function DateSelectMobile(props: DateSelectProps) {+ return (+ <InputField+ id={props.id}+ type="date"+ value={props.value ?? ''}+ onChange={event => {+ props.onSelect(event.target.value);+ }}+ style={{ height: 28 }}+ {...props.inputProps}+ />+ );+}++export function DateSelect(props: DateSelectProps) {+ const { isNarrowWidth } = useResponsive();++ if (isNarrowWidth) {+ return <DateSelectMobile {...props} />;+ }++ return <DateSelectDesktop {...props} />;+}diff --git a/upcoming-release-notes/5607.md b/upcoming-release-notes/5607.mdnew file mode 100644index 0000000000..6cbec13726--- /dev/null+++ b/upcoming-release-notes/5607.md@@ -0,0 +1,6 @@+---+category: Enhancements+authors: [MatissJanis]+---++Mobile friendly DateSelect component