Skip to content

Commit

Permalink
fix: fixed units overflow issue (#1343)
Browse files Browse the repository at this point in the history
* fix: fixed units overflow issue

* refactor: refactor code for desktop and xl screen

* refactor: fixed refactor issue
  • Loading branch information
sundasnoreen12 authored Apr 4, 2024
1 parent 85b95ad commit 9423a88
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';

import UnitButton from './UnitButton';
import SequenceNavigationDropdown from './SequenceNavigationDropdown';
import useIndexOfLastVisibleChild from '../../../../generic/tabs/useIndexOfLastVisibleChild';
import { useIsOnXLDesktop } from './hooks';

const SequenceNavigationTabs = ({
unitIds, unitId, showCompletion, onNavigate,
Expand All @@ -13,11 +15,17 @@ const SequenceNavigationTabs = ({
containerRef,
invisibleStyle,
] = useIndexOfLastVisibleChild();
const isOnXLDesktop = useIsOnXLDesktop();
const shouldDisplayDropdown = indexOfLastVisibleChild === -1;

return (
<div style={{ flexBasis: '100%', minWidth: 0 }}>
<div className="sequence-navigation-tabs-container" ref={containerRef}>
<div
ref={containerRef}
className={classNames('sequence-navigation-tabs-container', {
'navigation-tab-width': isOnXLDesktop && shouldDisplayDropdown,
})}
>
<div
className="sequence-navigation-tabs d-flex flex-grow-1"
style={shouldDisplayDropdown ? invisibleStyle : null}
Expand Down
6 changes: 6 additions & 0 deletions src/courseware/course/sequence/sequence-navigation/hooks.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint-disable import/prefer-default-export */

import { useSelector } from 'react-redux';
import { breakpoints, useWindowSize } from '@openedx/paragon';
import { useModel } from '../../../../generic/model-store';
import { sequenceIdsSelector } from '../../../data';

Expand Down Expand Up @@ -68,3 +69,8 @@ export function useSequenceNavigationMetadata(currentSequenceId, currentUnitId)
navigationDisabledPrevSequence,
};
}

export function useIsOnXLDesktop() {
const windowSize = useWindowSize();
return windowSize.width >= breakpoints.extraLarge.minWidth;
}
4 changes: 4 additions & 0 deletions src/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,10 @@
}
}

.navigation-tab-width {
max-width: 30rem;
}

.sequence-navigation-dropdown {
.dropdown-menu .btn {
flex-basis: 100%;
Expand Down

0 comments on commit 9423a88

Please sign in to comment.