Skip to content

Commit f438360

Browse files
feat: Ora mobile responsive (#336)
Co-authored-by: ihor-romaniuk <ihor.romaniuk@raccoongang.com>
1 parent 4ce7209 commit f438360

File tree

8 files changed

+68
-14
lines changed

8 files changed

+68
-14
lines changed

.eslintrc.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,28 @@ const config = createConfig('eslint', {
77
'import/no-named-as-default-member': 'off',
88
'import/no-import-module-exports': 'off',
99
'import/no-self-import': 'off',
10-
'spaced-comment': ['error', 'always', { 'block': { 'exceptions': ['*'] } }],
10+
'spaced-comment': ['error', 'always', { block: { exceptions: ['*'] } }],
1111
'react-hooks/rules-of-hooks': 'off',
12-
"react/forbid-prop-types": ["error", { "forbid": ["any", "array"] }], // arguable object proptype is use when I do not care about the shape of the object
12+
'react/forbid-prop-types': ['error', { forbid: ['any', 'array'] }], // arguable object proptype is use when I do not care about the shape of the object
1313
'no-import-assign': 'off',
1414
'no-promise-executor-return': 'off',
1515
'import/no-cycle': 'off',
1616
},
17+
overrides: [
18+
{
19+
files: ['**/*.test.{js,jsx,ts,tsx}'],
20+
rules: {
21+
'react/prop-types': 'off',
22+
},
23+
},
24+
],
1725
});
1826

1927
config.settings = {
20-
"import/resolver": {
28+
'import/resolver': {
2129
node: {
22-
paths: ["src", "node_modules"],
23-
extensions: [".js", ".jsx"],
30+
paths: ['src', 'node_modules'],
31+
extensions: ['.js', '.jsx'],
2432
},
2533
},
2634
};

src/App.test.jsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { screen } from '@testing-library/react';
22
import { selectors } from 'data/redux';
3+
34
import { renderWithIntl } from './testUtils';
45
import { App, mapStateToProps } from './App';
56

@@ -22,6 +23,14 @@ jest.mock('containers/DemoWarning', () => function DemoWarning() {
2223
return <div role="alert" data-testid="demo-warning">Demo Warning</div>;
2324
});
2425

26+
jest.mock('@edx/frontend-component-header', () => ({
27+
LearningHeader: ({ courseTitle, courseNumber, courseOrg }) => (
28+
<div data-testid="header">
29+
Header - {courseTitle} {courseNumber} {courseOrg}
30+
</div>
31+
),
32+
}));
33+
2534
jest.mock('data/redux', () => ({
2635
selectors: {
2736
app: {
@@ -53,7 +62,7 @@ describe('App component', () => {
5362
renderWithIntl(<App {...defaultProps} />);
5463
const org = screen.getByText((text) => text.includes('test-org'));
5564
expect(org).toBeInTheDocument();
56-
const title = screen.getByText('Test Course');
65+
const title = screen.getByText((content) => content.includes('Test Course'));
5766
expect(title).toBeInTheDocument();
5867
});
5968

src/components/ConfirmModal.test.jsx

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { render, screen } from '@testing-library/react';
22
import userEvent from '@testing-library/user-event';
3+
import { IntlProvider } from '@edx/frontend-platform/i18n';
34
import { ConfirmModal } from './ConfirmModal';
45

56
describe('ConfirmModal', () => {
@@ -18,24 +19,40 @@ describe('ConfirmModal', () => {
1819
});
1920

2021
it('should not render content when modal is closed', () => {
21-
render(<ConfirmModal {...props} />);
22+
render(
23+
<IntlProvider locale="en">
24+
<ConfirmModal {...props} />
25+
</IntlProvider>,
26+
);
2227
expect(screen.queryByText(props.content)).toBeNull();
2328
});
2429

2530
it('should display content when modal is open', () => {
26-
render(<ConfirmModal {...props} isOpen />);
31+
render(
32+
<IntlProvider locale="en">
33+
<ConfirmModal {...props} isOpen />
34+
</IntlProvider>,
35+
);
2736
expect(screen.getByText(props.content)).toBeInTheDocument();
2837
});
2938

3039
it('should call onCancel when cancel button is clicked', async () => {
31-
render(<ConfirmModal {...props} isOpen />);
40+
render(
41+
<IntlProvider locale="en">
42+
<ConfirmModal {...props} isOpen />
43+
</IntlProvider>,
44+
);
3245
const user = userEvent.setup();
3346
await user.click(screen.getByText(props.cancelText));
3447
expect(props.onCancel).toHaveBeenCalledTimes(1);
3548
});
3649

3750
it('should call onConfirm when confirm button is clicked', async () => {
38-
render(<ConfirmModal {...props} isOpen />);
51+
render(
52+
<IntlProvider locale="en">
53+
<ConfirmModal {...props} isOpen />
54+
</IntlProvider>,
55+
);
3956
const user = userEvent.setup();
4057
await user.click(screen.getByText(props.confirmText));
4158
expect(props.onConfirm).toHaveBeenCalledTimes(1);

src/components/InfoPopover/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export const InfoPopover = (
2727
return (
2828
<OverlayTrigger
2929
trigger="focus"
30-
placement="right-end"
30+
placement="left-end"
3131
flip
3232
overlay={(
3333
<Popover id="info-popover" className="overlay-help-popover">

src/containers/ListView/ListView.scss

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,14 @@ span.pgn__icon.breadcrumb-arrow {
2323
margin-bottom: 0;
2424
}
2525
}
26+
27+
@media (--pgn-size-breakpoint-max-width-xs) {
28+
.badge {
29+
white-space: normal;
30+
}
31+
32+
.pgn__table-actions > div:first-of-type {
33+
z-index: var(--pgn-elevation-modal-zindex) !important;
34+
}
35+
}
2636
}

src/containers/ReviewActions/ReviewActions.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,10 @@
3333
padding-bottom:var(--pgn-spacing-spacer-3);
3434
}
3535
}
36+
37+
38+
@media (--pgn-size-breakpoint-max-width-xs) {
39+
.overlay-help-popover {
40+
max-width: calc(100% - 60px) !important;
41+
}
42+
}

src/containers/ReviewActions/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export const ReviewActions = ({
3030
{ gradingStatus && (
3131
<StatusBadge className="review-actions-status mr-3" status={gradingStatus} />
3232
)}
33-
<span className="small">
33+
<span className="small text-nowrap">
3434
{pointsPossible && (
3535
<FormattedMessage
3636
{...messages.pointsDisplay}

src/containers/ReviewModal/index.jsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22
import { useDispatch } from 'react-redux';
33

4-
import { FullscreenModal } from '@openedx/paragon';
4+
import { FullscreenModal, Truncate, useMediaQuery } from '@openedx/paragon';
55
import { useIntl } from '@edx/frontend-platform/i18n';
66

77
import LoadingMessage from 'components/LoadingMessage';
@@ -28,9 +28,12 @@ export const ReviewModal = () => {
2828
isOpen,
2929
closeConfirmModalProps,
3030
} = hooks.rendererHooks({ dispatch, intl });
31+
32+
const isMobile = useMediaQuery({ query: '(max-width: 768px)' });
33+
3134
return (
3235
<FullscreenModal
33-
title={title}
36+
title={isMobile ? <Truncate lines={3}>{title}</Truncate> : title}
3437
isOpen={isOpen}
3538
beforeBodyNode={(
3639
<>

0 commit comments

Comments
 (0)