Skip to content

Commit affd077

Browse files
committed
Allow for ultrawide-specific tips
1 parent f39d160 commit affd077

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/components/basket/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ const Basket = observer(() => {
4949
const isUltrawide = useBreakpointValue({base: false, '4xl': true});
5050
const wasPreviouslyUltrawide = usePrevious(isUltrawide);
5151

52-
const onShowBasketTip = useTip('Tap the floating bar at the bottom, then \'Create a new basket\' to enable the add-to-basket buttons on courses and sections.');
52+
const onShowBasketTip = useTip('Tap the floating bar at the bottom, then \'Create a new basket\' to enable the add-to-basket buttons on courses and sections.', 'Tap \'Create a new basket\' to enable the add-to-basket buttons on courses and sections.');
5353

5454
useTimeout(() => {
5555
if (allBasketsState.baskets.length === 0) {

src/lib/hooks/use-tip.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
11
import {useCallback} from 'react';
2-
import {useToast} from '@chakra-ui/react';
3-
import useLocalStorage from 'react-use/lib/useLocalStorage';
2+
import {useToast, useBreakpointValue} from '@chakra-ui/react';
3+
import {useLocalStorage} from 'react-use';
44

5-
const useTip = (tip: string) => {
5+
const useTip = (tip: string, tipSpecificToUltrawides?: string) => {
6+
const resolvedTip = useBreakpointValue({base: tip, '4xl': tipSpecificToUltrawides ?? tip}) ?? tip;
67
const isServer = typeof window === 'undefined';
78

89
const toast = useToast();
9-
const [hasShown, setHasShown] = useLocalStorage(isServer ? '' : btoa(tip), false);
10+
const [hasShown, setHasShown] = useLocalStorage(isServer ? '' : btoa(resolvedTip), false);
1011

1112
const onShowTip = useCallback(() => {
1213
if (!hasShown) {
1314
toast({
1415
title: '✨ tip:',
1516
status: 'info',
16-
description: tip,
17+
description: resolvedTip,
1718
isClosable: true,
1819
duration: 10_000,
1920
position: 'bottom-right',
2021
});
2122
setHasShown(true);
2223
}
23-
}, [hasShown, setHasShown, toast, tip]);
24+
}, [hasShown, setHasShown, toast, resolvedTip]);
2425

2526
return onShowTip;
2627
};

0 commit comments

Comments
 (0)