Skip to content

feat: increased Course home font size #1600

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/alerts/course-start-alert/CourseStartAlert.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const CourseStartAlert = ({ payload }) => {
);
if (delta < DAY_MS) {
return (
<Alert variant="info" icon={Info}>
<Alert className="course-start-info-alert" variant="info" icon={Info}>
<FormattedMessage
id="learning.outline.alert.start.short"
defaultMessage="Course starts {timeRemaining} at {courseStartTime}."
Expand All @@ -65,7 +65,7 @@ const CourseStartAlert = ({ payload }) => {
}

return (
<Alert variant="info" icon={Info}>
<Alert className="course-start-info-alert" variant="info" icon={Info}>
<strong>
<FormattedMessage
id="learning.outline.alert.start.long"
Expand Down
3 changes: 3 additions & 0 deletions src/alerts/course-start-alert/CourseStartAlert.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.course-start-info-alert.alert-content {
font-size: $font-size-base;
}
77 changes: 77 additions & 0 deletions src/course-home/live-tab/LiveTab.test.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import React from 'react';
import { render } from '@testing-library/react';
import { useSelector } from 'react-redux';
import LiveTab from './LiveTab';

jest.mock('react-redux', () => ({
useSelector: jest.fn(),
}));

describe('LiveTab', () => {
afterEach(() => {
jest.clearAllMocks();
document.body.innerHTML = '';
});

it('renders iframe from liveModel using dangerouslySetInnerHTML', () => {
useSelector.mockImplementation((selector) => selector({
courseHome: { courseId: 'course-v1:test+id+2024' },
models: {
live: {
'course-v1:test+id+2024': {
iframe: '<iframe id="lti-tab-embed" src="about:blank"></iframe>',
},
},
},
}));

render(<LiveTab />);

const iframe = document.getElementById('lti-tab-embed');
expect(iframe).toBeInTheDocument();
expect(iframe.src).toBe('about:blank');
});

it('adds classes to iframe after mount', () => {
document.body.innerHTML = `
<div id="live_tab">
<iframe id="lti-tab-embed" class=""></iframe>
</div>
`;

useSelector.mockImplementation((selector) => selector({
courseHome: { courseId: 'course-v1:test+id+2024' },
models: {
live: {
'course-v1:test+id+2024': {
iframe: '<iframe id="lti-tab-embed"></iframe>',
},
},
},
}));

render(<LiveTab />);

const iframe = document.getElementById('lti-tab-embed');
expect(iframe.className).toContain('vh-100');
expect(iframe.className).toContain('w-100');
expect(iframe.className).toContain('border-0');
});

it('does not throw if iframe is not found in DOM', () => {
useSelector.mockImplementation((selector) => selector({
courseHome: { courseId: 'course-v1:test+id+2024' },
models: {
live: {
'course-v1:test+id+2024': {
iframe: '<div>No iframe here</div>',
},
},
},
}));

expect(() => render(<LiveTab />)).not.toThrow();
const iframe = document.getElementById('lti-tab-embed');
expect(iframe).toBeNull();
});
});
5 changes: 4 additions & 1 deletion src/course-home/outline-tab/DateSummary.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { FormattedDate } from '@edx/frontend-platform/i18n';
import React from 'react';
import { useSelector } from 'react-redux';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import { useWindowSize, breakpoints } from '@openedx/paragon';
import { useModel } from '../../generic/model-store';
import { isLearnerAssignment } from '../dates-tab/utils';
import './DateSummary.scss';
Expand All @@ -19,6 +21,7 @@ const DateSummary = ({
const {
org,
} = useModel('courseHomeMeta', courseId);
const wideScreen = useWindowSize().width >= breakpoints.medium.minWidth;

const linkedTitle = dateBlock.link && isLearnerAssignment(dateBlock);
const timezoneFormatArgs = userTimezone ? { timeZone: userTimezone } : {};
Expand All @@ -35,7 +38,7 @@ const DateSummary = ({
};

return (
<li className="p-0 mb-3 small text-dark-500">
<li className={classNames('p-0 mb-3 text-dark-500', { small: !wideScreen })}>
<div className="row">
<FontAwesomeIcon icon={faCalendarAlt} className="ml-3 mt-1 mr-1" fixedWidth />
<div className="ml-1 font-weight-bold">
Expand Down
8 changes: 7 additions & 1 deletion src/course-home/outline-tab/widgets/CourseDates.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import React from 'react';
import { useSelector } from 'react-redux';
import classNames from 'classnames';
import { useWindowSize, breakpoints } from '@openedx/paragon';

import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';

Expand All @@ -22,6 +24,7 @@ const CourseDates = ({
datesTabLink,
},
} = useModel('outline', courseId);
const wideScreen = useWindowSize().width >= breakpoints.medium.minWidth;

if (courseDateBlocks.length === 0) {
return null;
Expand All @@ -40,7 +43,10 @@ const CourseDates = ({
/>
))}
</ol>
<a className="font-weight-bold ml-4 pl-1 small" href={datesTabLink}>
<a
className={classNames('font-weight-bold ml-4 pl-1', { small: !wideScreen })}
href={datesTabLink}
>
{intl.formatMessage(messages.allDates)}
</a>
</div>
Expand Down
5 changes: 4 additions & 1 deletion src/course-home/outline-tab/widgets/CourseHandouts.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import React from 'react';
import { useSelector } from 'react-redux';
import { useWindowSize, breakpoints } from '@openedx/paragon';
import classNames from 'classnames';

import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';

Expand All @@ -14,6 +16,7 @@ const CourseHandouts = ({ intl }) => {
const {
handoutsHtml,
} = useModel('outline', courseId);
const wideScreen = useWindowSize().width >= breakpoints.medium.minWidth;

if (!handoutsHtml) {
return null;
Expand All @@ -23,7 +26,7 @@ const CourseHandouts = ({ intl }) => {
<section className="mb-4">
<h2 className="h4">{intl.formatMessage(messages.handouts)}</h2>
<LmsHtmlFragment
className="small"
className={classNames({ small: !wideScreen })}
html={handoutsHtml}
title={intl.formatMessage(messages.handouts)}
/>
Expand Down
7 changes: 5 additions & 2 deletions src/course-home/outline-tab/widgets/CourseTools.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import {
faBookmark, faCertificate, faInfo, faCalendar, faStar,
} from '@fortawesome/free-solid-svg-icons';
import { faNewspaper } from '@fortawesome/free-regular-svg-icons';
import { useWindowSize, breakpoints } from '@openedx/paragon';
import classNames from 'classnames';

import messages from '../messages';
import { useModel } from '../../../generic/model-store';
Expand All @@ -22,6 +24,7 @@ const CourseTools = ({ intl }) => {
const {
courseTools,
} = useModel('outline', courseId);
const wideScreen = useWindowSize().width >= breakpoints.medium.minWidth;

if (courseTools.length === 0) {
return null;
Expand Down Expand Up @@ -66,14 +69,14 @@ const CourseTools = ({ intl }) => {
<h2 className="h4">{intl.formatMessage(messages.tools)}</h2>
<ul className="list-unstyled">
{courseTools.map((courseTool) => (
<li key={courseTool.analyticsId} className="small">
<li key={courseTool.analyticsId} className={classNames({ small: !wideScreen })}>
<a href={courseTool.url} onClick={() => logClick(courseTool.analyticsId)}>
<FontAwesomeIcon icon={renderIcon(courseTool.analyticsId)} className="mr-2" fixedWidth />
{courseTool.title}
</a>
</li>
))}
<li className="small" id="courseHome-launchTourLink">
<li id="courseHome-launchTourLink" className={classNames({ small: !wideScreen })}>
<LaunchCourseHomeTourButton />
</li>
</ul>
Expand Down
61 changes: 38 additions & 23 deletions src/course-home/outline-tab/widgets/FlagButton.jsx
Original file line number Diff line number Diff line change
@@ -1,36 +1,51 @@
import React from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
import { useWindowSize, breakpoints } from '@openedx/paragon';

const FlagButton = ({
buttonIcon,
title,
text,
handleSelect,
isSelected,
}) => (
<button
type="button"
className={classnames(
'flag-button row w-100 align-content-between m-1.5 py-3.5',
isSelected ? 'flag-button-selected' : '',
)}
aria-checked={isSelected}
role="radio"
onClick={() => handleSelect()}
data-testid={`weekly-learning-goal-input-${title}`}
>
<div className="row w-100 m-0 justify-content-center pb-1">
{buttonIcon}
</div>
<div className={classnames('row w-100 m-0 justify-content-center small text-gray-700 pb-1', isSelected ? 'font-weight-bold' : '')}>
{title}
</div>
<div className={classnames('row w-100 m-0 justify-content-center micro text-gray-500', isSelected ? 'font-weight-bold' : '')}>
{text}
</div>
</button>
);
}) => {
const wideScreen = useWindowSize().width >= breakpoints.medium.minWidth;

return (
<button
type="button"
className={classnames(
'flag-button row w-100 align-content-between m-1.5 py-3.5',
isSelected ? 'flag-button-selected' : '',
)}
aria-checked={isSelected}
role="radio"
onClick={() => handleSelect()}
data-testid={`weekly-learning-goal-input-${title}`}
>
<div className="row w-100 m-0 justify-content-center pb-1">
{buttonIcon}
</div>
<div className={classnames(
'row w-100 m-0 justify-content-center text-gray-700 pb-1',
isSelected ? 'font-weight-bold' : '',
{ small: !wideScreen },
)}
>
{title}
</div>
<div className={classnames(
'row w-100 m-0 justify-content-center small text-gray-500',
isSelected ? 'font-weight-bold' : '',
{ small: !wideScreen },
)}
>
{text}
</div>
</button>
);
};

FlagButton.propTypes = {
buttonIcon: PropTypes.element.isRequired,
Expand Down
17 changes: 12 additions & 5 deletions src/course-home/outline-tab/widgets/WeeklyLearningGoalCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ import React, { useEffect, useState } from 'react';
import { useLocation } from 'react-router-dom';
import PropTypes from 'prop-types';

import { Form, Card, Icon } from '@openedx/paragon';
import {
Form, Card, Icon, useWindowSize, breakpoints,
} from '@openedx/paragon';
import classNames from 'classnames';
import { history } from '@edx/frontend-platform';
import { sendTrackEvent } from '@edx/frontend-platform/analytics';
import { getAuthenticatedUser } from '@edx/frontend-platform/auth';
Expand All @@ -23,6 +26,7 @@ const WeeklyLearningGoalCard = ({
const {
courseId,
} = useSelector(state => state.courseHome);
const wideScreen = useWindowSize().width >= breakpoints.medium.minWidth;

const {
isMasquerading,
Expand Down Expand Up @@ -94,11 +98,11 @@ const WeeklyLearningGoalCard = ({
data-testid="weekly-learning-goal-card"
>
<Card.Header
size="sm"
size={!wideScreen ? 'sm' : 'md'}
title={(<div id="set-weekly-goal-header">{intl.formatMessage(messages.setWeeklyGoal)}</div>)}
subtitle={intl.formatMessage(messages.setWeeklyGoalDetail)}
/>
<Card.Section className="text-gray-700 small">
<Card.Section className={classNames('text-gray-700', { small: !wideScreen })}>
<div
role="radiogroup"
aria-labelledby="set-weekly-goal-header"
Expand All @@ -125,14 +129,17 @@ const WeeklyLearningGoalCard = ({
checked={isGetReminderSelected}
onChange={(event) => handleSubscribeToReminders(event)}
disabled={!daysPerWeekGoal}
className={classNames({ small: !wideScreen })}
>
<small>{intl.formatMessage(messages.setGoalReminder)}</small>
{wideScreen
? intl.formatMessage(messages.setGoalReminder)
: <small>{intl.formatMessage(messages.setGoalReminder)}</small>}
</Form.Switch>
</div>
</Card.Section>
{isGetReminderSelected && (
<Card.Section muted>
<div className="row w-100 m-0 small align-center">
<div className="row w-100 m-0 align-center">
<div className="d-flex align-items-center pr-1">
<Icon
className="text-primary-500"
Expand Down
18 changes: 16 additions & 2 deletions src/course-home/outline-tab/widgets/WelcomeMessage.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { useState, useMemo, useRef } from 'react';
import React, {
useState, useRef, useEffect, useMemo,
} from 'react';
import PropTypes from 'prop-types';

import { useIntl } from '@edx/frontend-platform/i18n';
import { Alert, Button, TransitionReplace } from '@openedx/paragon';
import truncate from 'truncate-html';

import { useDispatch } from 'react-redux';
import { useIntl } from '@edx/frontend-platform/i18n';
import LmsHtmlFragment from '../LmsHtmlFragment';
import messages from '../messages';
import { useModel } from '../../../generic/model-store';
Expand Down Expand Up @@ -38,16 +40,28 @@ const WelcomeMessage = ({ courseId, nextElementRef }) => {

const [showShortMessage, setShowShortMessage] = useState(messageCanBeShortened);
const dispatch = useDispatch();
const alertRef = useRef(null);

if (!welcomeMessageHtml) {
return null;
}

useEffect(() => {
// TODO: Temporary solution due to a bug in the Paragon Alert component
// that prevents changing the button sizes. Delete after correction.
// Issue: https://github.com/openedx/paragon/issues/3205
if (alertRef.current) {
const buttons = alertRef.current.querySelectorAll('button.btn-sm');
buttons.forEach(btn => btn.classList.remove('btn-sm'));
}
}, [showShortMessage]);

return (
<Alert
data-testid="alert-container-welcome"
variant="light"
stacked
ref={alertRef}
dismissible
show={display}
onClose={() => {
Expand Down
Empty file.
Loading