|
| 1 | +import { useMediaQuery } from '@react-hookz/web'; |
1 | 2 | import { m as motion } from 'motion/react'; |
2 | 3 | import type { ReactElement } from 'react'; |
3 | 4 | import styled, { RuleSet } from 'styled-components'; |
4 | 5 |
|
5 | 6 | import Badge from 'src/domains/misc/components/Badge'; |
| 7 | +import { BOTTOM_MENU_BREAKPOINT } from 'src/domains/misc/consts/consts.ts'; |
6 | 8 | import composeFluidSize from 'src/domains/styling/utils/composeFluidSize'; |
7 | 9 | import { transitionTime, typography } from 'src/domains/styling/utils/tokens'; |
8 | 10 | import vars from 'src/domains/styling/utils/vars'; |
@@ -36,36 +38,42 @@ const positionStyles = { |
36 | 38 | }, |
37 | 39 | }; |
38 | 40 |
|
39 | | -const Tab = ({ label, selected, onClick, layoutId, size = 'medium', position = 'floor', icon, comingSoon }: Props) => ( |
40 | | - <Wrapper |
41 | | - initial={{ opacity: 0 }} |
42 | | - animate={{ opacity: 1, transition: { delay: 0.1 }}} |
43 | | - exit={{ opacity: 0 }} |
44 | | - > |
45 | | - <Container |
46 | | - selected={selected} |
47 | | - onClick={onClick} |
48 | | - disabled={comingSoon} |
49 | | - title={label} |
50 | | - $size={size} |
51 | | - layout |
| 41 | +const Tab = ({ label, selected, onClick, layoutId, size = 'medium', position = 'floor', icon, comingSoon }: Props) => { |
| 42 | + const isSmallScreen = useMediaQuery(`(max-width: ${BOTTOM_MENU_BREAKPOINT})`); |
| 43 | + |
| 44 | + return ( |
| 45 | + <Wrapper |
| 46 | + initial={{ opacity: 0 }} |
| 47 | + animate={{ opacity: 1, transition: { delay: 0.1 }}} |
| 48 | + exit={{ opacity: 0 }} |
52 | 49 | > |
53 | | - <LabelContainer> |
54 | | - {icon} |
55 | | - {label} |
56 | | - </LabelContainer> |
57 | | - <HoverBar style={positionStyles[position]} /> |
58 | | - {selected && ( |
59 | | - <SelectionBar |
60 | | - // set as an inline style for scale correction during transition (https://www.framer.com/motion/layout-animations/##scale-correction) |
61 | | - style={positionStyles[position]} |
62 | | - layoutId={layoutId} |
63 | | - /> |
| 50 | + <Container |
| 51 | + selected={selected} |
| 52 | + onClick={onClick} |
| 53 | + disabled={comingSoon} |
| 54 | + title={label} |
| 55 | + $size={size} |
| 56 | + layout |
| 57 | + > |
| 58 | + <LabelContainer> |
| 59 | + {icon} |
| 60 | + {label} |
| 61 | + </LabelContainer> |
| 62 | + <HoverBar style={positionStyles[position]} /> |
| 63 | + {selected && ( |
| 64 | + <SelectionBar |
| 65 | + // set as an inline style for scale correction during transition (https://www.framer.com/motion/layout-animations/##scale-correction) |
| 66 | + style={positionStyles[position]} |
| 67 | + layoutId={layoutId} |
| 68 | + /> |
| 69 | + )} |
| 70 | + </Container> |
| 71 | + {comingSoon && ( |
| 72 | + <Badge size="medium" variant="subtle" design="tint" text={isSmallScreen ? 'Soon' : 'Coming soon'} circular /> |
64 | 73 | )} |
65 | | - </Container> |
66 | | - {comingSoon && <Badge size="medium" variant="subtle" design="tint" text="Coming soon" circular />} |
67 | | - </Wrapper> |
68 | | -); |
| 74 | + </Wrapper> |
| 75 | + ); |
| 76 | +}; |
69 | 77 |
|
70 | 78 | export default Tab; |
71 | 79 |
|
@@ -102,6 +110,7 @@ const LabelContainer = styled.div` |
102 | 110 | display: flex; |
103 | 111 | gap: ${vars('--spacing-xxs')}; |
104 | 112 | align-items: center; |
| 113 | + white-space: nowrap; |
105 | 114 |
|
106 | 115 | svg { |
107 | 116 | fill: ${vars('--color-brand-foreground-compound-rest')}; |
|
0 commit comments