Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOP-5242 🐛 fixes the issue of the tab selector now rendering on mobile view #1332

Merged
merged 10 commits into from
Jan 7, 2025
32 changes: 19 additions & 13 deletions src/components/Heading.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const Heading = ({ sectionDepth, nodeData, className, as, ...rest }) => {
const asHeadingNumber = as ?? sectionDepth;
const asHeading = asHeadingNumber >= 1 && asHeadingNumber <= 6 ? `h${asHeadingNumber}` : 'h6';
const isPageTitle = sectionDepth === 1;
const { isMobile, isTabletOrMobile } = useScreenSize();
const { isTabletOrMobile } = useScreenSize();
seungpark marked this conversation as resolved.
Show resolved Hide resolved
const { selectors } = useContext(TabContext);
const { hasDrawer, isOpen, setIsOpen } = useContext(InstruqtContext);
const hasSelectors = selectors && Object.keys(selectors).length > 0;
Expand All @@ -72,9 +72,9 @@ const Heading = ({ sectionDepth, nodeData, className, as, ...rest }) => {
<ConditionalWrapper
condition={shouldShowMobileHeader}
wrapper={(children) => (
<HeadingContainer stackVertically={isMobile}>
<HeadingContainer>
{children}
<ChildContainer isStacked={isMobile}>{hasSelectors && !tabsMainColumn && <TabSelectors />}</ChildContainer>
<ChildContainer>{hasSelectors && !tabsMainColumn && <TabSelectors rightColumn={true} />}</ChildContainer>
</HeadingContainer>
)}
>
Expand Down Expand Up @@ -117,19 +117,25 @@ const Heading = ({ sectionDepth, nodeData, className, as, ...rest }) => {

const HeadingContainer = styled.div`
display: flex;
flex-direction: ${(props) => (props.stackVertically ? 'column' : 'row')};
flex-direction: row;
justify-content: space-between;
`;

const ChildContainer = styled.div(
({ isStacked }) => css`
${isStacked && 'margin: 4px 0 16px 0;'}
display: flex;
@media ${theme.screenSize.upToLarge} {
flex-direction: column;
justify-content: center;
align-items: ${isStacked ? 'flex-start' : 'center'};
`
);
}
`;

const ChildContainer = styled.div`
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;

@media ${theme.screenSize.upToLarge} {
margin: 4px 0 16px 0;
align-items: flex-start;
}
`;

Heading.propTypes = {
sectionDepth: PropTypes.number.isRequired,
Expand Down
7 changes: 6 additions & 1 deletion src/components/Tabs/TabSelectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ const selectStyle = css`

@media ${theme.screenSize.smallAndUp} {
/* Min width of right panel */
max-width: 180px;
max-width: 140px;
}

@media ${theme.screenSize.upToLarge} {
/* Supports the alignment when on tablet or mobile */
max-width: 300px;
rayangler marked this conversation as resolved.
Show resolved Hide resolved
}
`;

Expand Down
Loading