-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #456 from icssc/frontend-changes-branched
Frontend changes branched
- Loading branch information
Showing
52 changed files
with
6,142 additions
and
4,898 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
20.12.1 | ||
lts/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import type { Config } from "jest"; | ||
|
||
export default { | ||
verbose: true, | ||
preset: "jest-expo", | ||
transformIgnorePatterns: [ | ||
"node_modules/(?!((jest-)?react-native|@react-native(-community)?)|expo(nent)?|@expo(nent)?/.*|@expo-google-fonts/.*|react-navigation|@react-navigation/.*|@unimodules/.*|unimodules|sentry-expo|native-base|react-native-svg)", | ||
], | ||
} satisfies Config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import React from "react"; | ||
import renderer from "react-test-renderer"; | ||
import { Logo } from "~/components"; | ||
|
||
describe("<App />", () => { | ||
it("has 1 child", () => { | ||
const tree = renderer.create(<Logo />).toJSON(); | ||
expect(tree.children.length).toBe(1); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import React, { useState } from "react"; | ||
import { Platform } from "react-native"; | ||
import DateTimePicker from "@react-native-community/datetimepicker"; | ||
import { CalendarDays } from "@tamagui/lucide-icons"; | ||
import { endOfWeek, startOfWeek } from "date-fns"; | ||
import { Button } from "tamagui"; | ||
|
||
/** | ||
* Native date picker for iOS and Android. | ||
* | ||
* Platform handling from an issue thread: | ||
* | ||
* @see https://github.com/react-native-datetimepicker/datetimepicker/issues/54 | ||
*/ | ||
export const UniversalDatePicker = ({ | ||
date, | ||
setDate, | ||
}: Readonly<{ date: Date; setDate: (date: Date) => void }>) => { | ||
const [showDatePicker, setShowDatePicker] = useState<boolean>(true); | ||
|
||
return ( | ||
<> | ||
{Platform.OS === "android" && ( | ||
<Button | ||
onPress={() => setShowDatePicker(true)} | ||
icon={CalendarDays} | ||
scaleIcon={1.5} | ||
size="$5" | ||
borderRadius="$10" | ||
pressTheme | ||
> | ||
{date.toLocaleDateString("en-US")} | ||
</Button> | ||
)} | ||
{showDatePicker && ( | ||
<DateTimePicker | ||
value={date} | ||
mode="date" | ||
minimumDate={startOfWeek(new Date())} | ||
maximumDate={endOfWeek(new Date())} | ||
onChange={(_, selectedDate) => { | ||
// hide date picker on android | ||
setShowDatePicker(Platform.OS === "ios"); | ||
if (selectedDate) { | ||
setDate(selectedDate); | ||
} | ||
}} | ||
/> | ||
)} | ||
</> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import React from "react"; | ||
import { endOfWeek, startOfWeek } from "date-fns"; | ||
import DatePicker from "react-datepicker"; | ||
|
||
import "react-datepicker/dist/react-datepicker.css"; | ||
|
||
import { CalendarDays } from "@tamagui/lucide-icons"; | ||
import { Button, ButtonProps, TamaguiElement } from "tamagui"; | ||
|
||
interface UniversalDatePickerProps { | ||
date: Date; | ||
setDate: (date: Date) => void; | ||
} | ||
|
||
interface CustomInputProps { | ||
value: HTMLInputElement["value"]; | ||
onClick: ButtonProps["onPress"]; | ||
} | ||
|
||
/** | ||
* Universal date picker for web. | ||
*/ | ||
export const UniversalDatePicker = ({ | ||
date, | ||
setDate, | ||
}: Readonly<UniversalDatePickerProps>) => { | ||
/** | ||
* Courtesy of issue thread: | ||
* @see https://github.com/Hacker0x01/react-datepicker/issues/2165#issuecomment-711032947 | ||
*/ | ||
const CustomInput = ( | ||
{ value, onClick }: CustomInputProps, | ||
ref: React.Ref<TamaguiElement>, | ||
) => ( | ||
<Button icon={CalendarDays} onPress={onClick} ref={ref}> | ||
{value} | ||
</Button> | ||
); | ||
|
||
return ( | ||
<DatePicker | ||
customInput={React.createElement(React.forwardRef(CustomInput))} | ||
selected={date} | ||
minDate={startOfWeek(new Date())} | ||
maxDate={endOfWeek(new Date())} | ||
onChange={(prev) => setDate(prev ?? new Date())} | ||
/> | ||
); | ||
}; |
Oops, something went wrong.