Skip to content

Commit

Permalink
fix(rtl): mirror position of grade rectangles in grade bar (#980)
Browse files Browse the repository at this point in the history
Translates the rectangles for current and passing
grades when to appear on the right when in RTL.
  • Loading branch information
ARMBouhali authored Oct 14, 2022
1 parent e5e73e4 commit 7c4200e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/course-home/progress-tab/grades/course-grade/GradeBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import React from 'react';
import { useSelector } from 'react-redux';
import PropTypes from 'prop-types';

import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
import {
getLocale, injectIntl, intlShape, isRtl,
} from '@edx/frontend-platform/i18n';
import { useModel } from '../../../../generic/model-store';
import CurrentGradeTooltip from './CurrentGradeTooltip';
import PassingGradeTooltip from './PassingGradeTooltip';
Expand All @@ -26,14 +28,16 @@ function GradeBar({ intl, passingGrade }) {

const lockedTooltipClassName = gradesFeatureIsFullyLocked ? 'locked-overlay' : '';

const adjustedRtlStyle = (percentOffest) => (isRtl(getLocale()) ? { transform: `translateX(${100 - percentOffest}%)` } : {});

return (
<div className="col-12 col-sm-6 align-self-center p-0">
<div className="sr-only">{intl.formatMessage(messages.courseGradeBarAltText, { currentGrade, passingGrade })}</div>
<svg width="100%" height="100px" className="grade-bar" aria-hidden="true">
<g style={{ transform: 'translateY(2.61em)' }}>
<rect className="grade-bar__base" width="100%" />
<rect className="grade-bar--passing" width={`${passingGrade}%`} />
<rect className={`grade-bar--current-${isPassing ? 'passing' : 'non-passing'}`} width={`${currentGrade}%`} />
<rect className="grade-bar--passing" width={`${passingGrade}%`} style={adjustedRtlStyle(passingGrade)} />
<rect className={`grade-bar--current-${isPassing ? 'passing' : 'non-passing'}`} width={`${currentGrade}%`} style={adjustedRtlStyle(currentGrade)} />

{/* Start divider */}
<rect className="grade-bar__divider" />
Expand Down

0 comments on commit 7c4200e

Please sign in to comment.