-
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 #146 from GTBitsOfGood/holiday_banner
Add holiday banner
- Loading branch information
Showing
4 changed files
with
73 additions
and
0 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
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,62 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
import { View, Text, StyleSheet } from 'react-native'; | ||
import { HOLIDAYS } from '../../utils/types'; | ||
|
||
const HolidayBanner = () => { | ||
const [holidayBanner, setHolidayBanner] = useState<{ name: string, message: string } | null>(null); | ||
|
||
useEffect(() => { | ||
function checkForHoliday() { | ||
const today = new Date(); | ||
const holiday = HOLIDAYS.find( | ||
(holiday) => | ||
holiday.month === today.getMonth() && holiday.day === today.getDate() | ||
); | ||
if (holiday) { | ||
setHolidayBanner({ name: holiday.name, message: holiday.message }); | ||
} else { | ||
setHolidayBanner(null); | ||
} | ||
} | ||
|
||
checkForHoliday(); | ||
}, []); | ||
|
||
if (!holidayBanner) return null; | ||
|
||
return ( | ||
<View style={styles.holidayBanner}> | ||
<Text style={styles.holidayTitle}>{holidayBanner.name}!</Text> | ||
{holidayBanner.message ? ( | ||
<Text style={styles.holidayMessage}>{holidayBanner.message}</Text> | ||
) : null} | ||
</View> | ||
); | ||
}; | ||
|
||
const styles = StyleSheet.create({ | ||
holidayBanner: { | ||
borderRadius: 10, | ||
backgroundColor: "#3F3BED", | ||
marginBottom: 10, | ||
padding: 10, | ||
display: "flex", | ||
flexDirection: "column", | ||
gap: 5, | ||
opacity: 0.9 | ||
}, | ||
holidayTitle: { | ||
color: "white", | ||
fontSize: 14, | ||
fontWeight: "700", | ||
textAlign: "center" | ||
}, | ||
holidayMessage: { | ||
color: "white", | ||
fontSize: 12, | ||
fontWeight: "400", | ||
textAlign: "center" | ||
}, | ||
}); | ||
|
||
export default HolidayBanner; |
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