Skip to content

Commit 4c7dc4e

Browse files
hide icons when too button shrinks
1 parent 0e23f2d commit 4c7dc4e

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

frontends/main/src/page-components/SearchDisplay/ProfessionalToggle.tsx

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,40 @@ const StyledToggleButton = styled(ToggleButton)(({ theme }) => ({
4747
backgroundColor: theme.custom.colors.white,
4848
},
4949
...theme.typography.subtitle3,
50+
51+
// MUI's ToggleButtonGroup have a -1 margin offset that caused problems for our borders.
52+
"&.MuiToggleButtonGroup-middleButton, .MuiToggleButtonGroup-lastButton": {
53+
margin: 0,
54+
},
55+
/**
56+
* The goal here is to ensure the icons:
57+
* - scale at same rate when container shrinks
58+
* - are hidden if container is too small
59+
*
60+
* NOTE: containerType: size enables the container query but requires setting
61+
* a width on the container. We are doing this anyway.
62+
*/
63+
containerType: "size",
64+
boxSizing: "border-box",
65+
"& > span": {
66+
minWidth: "70px",
67+
},
68+
"@container (max-width: 85px)": {
69+
"& > svg": {
70+
display: "none",
71+
},
72+
},
5073
}))
5174

5275
const ViewAllButton = styled(StyledToggleButton)`
53-
border-right: 2px solid;
76+
border-right: 1px solid;
5477
border-color: ${({ theme }) => theme.custom.colors.silverGrayLight};
5578
width: 20%;
5679
border-top-left-radius: 4px;
5780
border-bottom-left-radius: 4px;
5881
`
5982
const AcademicButton = styled(StyledToggleButton)`
60-
border-right: 2px solid;
83+
border-right: 1px solid;
6184
border-color: ${({ theme }) => theme.custom.colors.silverGrayLight};
6285
width: 40%;
6386
`
@@ -93,10 +116,10 @@ const ProfessionalToggle: React.FC<{
93116
>
94117
<ViewAllButton value="">All</ViewAllButton>
95118
<AcademicButton value="false">
96-
<StyledRiBookOpenLine /> Academic
119+
<StyledRiBookOpenLine /> <span>Academic</span>
97120
</AcademicButton>
98121
<ProfesionalButton value="true">
99-
<StyledRiBriefcase3Line /> Professional
122+
<StyledRiBriefcase3Line /> <span>Professional</span>
100123
</ProfesionalButton>
101124
</StyledToggleButtonGroup>
102125
<Collapse in={professionalSetting === ""}>

0 commit comments

Comments
 (0)