-
Notifications
You must be signed in to change notification settings - Fork 250
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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; | ||
} |
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(); | ||
}); | ||
}); |
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [open question]: should there be a component provided by Paragon? For example Paragon FormControl with type="radio" |
||
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, | ||
|
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'; | ||
|
@@ -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(() => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [nit]: After discussions on the PWG, the answer was that this behavior of the buttons is a design decision. So, it seems to me that we should remove this |
||
// 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={() => { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[open question]: should there be a component provided by Paragon? For example Paragon HyperLink