Skip to content

Commit

Permalink
💄(edulib) update theme to richie 1.12
Browse files Browse the repository at this point in the history
update theme to richie 1.12 but maintain font icons
  • Loading branch information
2018D committed Jan 14, 2020
1 parent 5664e4f commit be8a265
Show file tree
Hide file tree
Showing 45 changed files with 599 additions and 313 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import fetchMock from 'fetch-mock';

import { handle } from '../../utils/errors/handle';
import { handle } from 'utils/errors/handle';
import { getSuggestionsSection } from './getSuggestionsSection';

const mockHandle: jest.Mock<typeof handle> = handle as any;
jest.mock('../../utils/errors/handle');
jest.mock('utils/errors/handle');

describe('common/searchFields/getSuggestionsSection', () => {
afterEach(() => {
Expand Down
4 changes: 2 additions & 2 deletions src/frontend/js/common/searchFields/getSuggestionsSection.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import take from 'lodash-es/take';
import { stringify } from 'query-string';

import { Suggestion } from '../../types/Suggestion';
import { handle } from '../../utils/errors/handle';
import { Suggestion } from 'types/Suggestion';
import { handle } from 'utils/errors/handle';

/**
* Build a suggestion section from a model name and a title, requesting the relevant
Expand Down
6 changes: 3 additions & 3 deletions src/frontend/js/common/searchFields/index.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from 'react';

import { APICourseSearchResponse } from '../../types/api';
import { APICourseSearchResponse } from 'types/api';
import {
SearchAutosuggestProps,
SearchSuggestion,
SearchSuggestionSection,
} from '../../types/Suggestion';
import { handle } from '../../utils/errors/handle';
} from 'types/Suggestion';
import { handle } from 'utils/errors/handle';
import { getSuggestionsSection } from './getSuggestionsSection';

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import '../../testSetup';
import 'testSetup';

import { render } from '@testing-library/react';
import React from 'react';
import { IntlProvider } from 'react-intl';

import { CourseGlimpse } from './CourseGlimpse';
import { CourseGlimpse } from '.';

describe('components/CourseGlimpse', () => {
const course = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { defineMessages, FormattedDate, FormattedMessage } from 'react-intl';

import { Course } from '../../types/Course';
import { Course } from 'types/Course';

export interface CourseGlimpseProps {
course: Course;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import '../../testSetup';
import 'testSetup';

import { render } from '@testing-library/react';
import React from 'react';
import { IntlProvider } from 'react-intl';

import { Course } from '../../types/Course';
import { CourseGlimpseList } from './CourseGlimpseList';
import { Course } from 'types/Course';
import { CourseGlimpseList } from '.';

describe('components/CourseGlimpseList', () => {
it('renders a list of Courses into a list of CourseGlimpses', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from 'react';
import { defineMessages, FormattedMessage } from 'react-intl';

import { APIResponseListMeta } from '../../types/api';
import { Course } from '../../types/Course';
import { CourseGlimpse } from '../CourseGlimpse/CourseGlimpse';
import { CourseGlimpse } from 'components/CourseGlimpse';
import { APIResponseListMeta } from 'types/api';
import { Course } from 'types/Course';

const messages = defineMessages({
courseCount: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import '../../testSetup';
import 'testSetup';

import { cleanup, fireEvent, render } from '@testing-library/react';
import { fireEvent, render } from '@testing-library/react';
import React from 'react';
import { IntlProvider } from 'react-intl';

import { CourseSearchParamsContext } from 'data/useCourseSearchParams';
import { PaginateCourseSearch } from '.';
import { CourseSearchParamsContext } from '../../data/useCourseSearchParams/useCourseSearchParams';

describe('<PaginateCourseSearch />', () => {
beforeEach(jest.resetAllMocks);
Expand Down
183 changes: 95 additions & 88 deletions src/frontend/js/components/PaginateCourseSearch/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useContext, useState } from 'react';
import { defineMessages, FormattedMessage } from 'react-intl';

import { CourseSearchParamsContext } from '../../data/useCourseSearchParams/useCourseSearchParams';
import { CourseSearchParamsContext } from 'data/useCourseSearchParams';

const messages = defineMessages({
currentlyReadingLastPageN: {
Expand Down Expand Up @@ -95,95 +95,102 @@ export const PaginateCourseSearch = ({
<div id={`pagination-label-${componentId}`} className="offscreen">
<FormattedMessage {...messages.pagination} />
</div>
<ul
role="navigation"
aria-labelledby={`pagination-label-${componentId}`}
className="pagination__list"
>
{pageList.map((page, index) => (
<React.Fragment key={page}>
{/* Prepend a cell with "..." when the page number we're rendering does not follow the previous one */}
{page > (pageList[index - 1] || 0) + 1 && (
<li className="pagination__list__item pagination__list__item--placeholder">
...
</li>
)}
<nav aria-labelledby={`pagination-label-${componentId}`}>
<ul className="pagination__list">
{pageList.map((page, index) => (
<React.Fragment key={page}>
{/* Prepend a cell with "..." when the page number we're rendering does not follow the previous one */}
{page > (pageList[index - 1] || 0) + 1 && (
<li className="pagination__list__item pagination__list__item--placeholder">
...
</li>
)}

{page === currentPage ? (
/* The current page needs different markup as it does not include a link */
<li className="pagination__list__item pagination__list__item--current">
<span className="pagination__list__item__page-number">
{/* Help assistive technology users with some context */}
<span className="offscreen">
{page === maxPage ? (
<FormattedMessage
{...messages.currentlyReadingLastPageN}
values={{ page }}
/>
) : (
<FormattedMessage
{...messages.currentlyReadingPageN}
values={{ page }}
/>
)}
{page === currentPage ? (
/* The current page needs different markup as it does not include a link */
<li className="pagination__list__item pagination__list__item--current">
<span className="pagination__list__item__page-number">
{/* Help assistive technology users with some context */}
<span className="offscreen">
{page === maxPage ? (
<FormattedMessage
{...messages.currentlyReadingLastPageN}
values={{ page }}
/>
) : (
<FormattedMessage
{...messages.currentlyReadingPageN}
values={{ page }}
/>
)}
</span>
<span aria-hidden={true}>
{/* Show context "Page 1" on the first item to make it obvious this is pagination */}
{page === 1 ? (
<FormattedMessage
{...messages.pageN}
values={{ page }}
/>
) : (
page
)}
</span>
</span>
<span aria-hidden={true}>
{/* Show context "Page 1" on the first item to make it obvious this is pagination */}
{page === 1 ? (
<FormattedMessage {...messages.pageN} values={{ page }} />
) : (
page
)}
</span>
</span>
</li>
) : (
<li className="pagination__list__item">
<a
className="pagination__list__item__page-number"
onClick={() =>
dispatchCourseSearchParamsUpdate({
// Pages are 1-indexed, we need to 0-index them to calculate the correct offset
offset: String((page - 1) * limit),
type: 'PAGE_CHANGE',
})
}
>
{/* Help assistive technology users with some context */}
<span className="offscreen">
{page === maxPage ? (
<FormattedMessage
{...messages.lastPageN}
values={{ page }}
/>
) : page === currentPage - 1 ? (
<FormattedMessage
{...messages.previousPageN}
values={{ page }}
/>
) : page === currentPage + 1 ? (
<FormattedMessage
{...messages.nextPageN}
values={{ page }}
/>
) : (
<FormattedMessage {...messages.pageN} values={{ page }} />
)}
</span>
<span aria-hidden={true}>
{/* Show context "Page 1" on the first item to make it obvious this is pagination */}
{page === 1 ? (
<FormattedMessage {...messages.pageN} values={{ page }} />
) : (
page
)}
</span>
</a>
</li>
)}
</React.Fragment>
))}
</ul>
</li>
) : (
<li className="pagination__list__item">
<a
className="pagination__list__item__page-number"
onClick={() =>
dispatchCourseSearchParamsUpdate({
// Pages are 1-indexed, we need to 0-index them to calculate the correct offset
offset: String((page - 1) * limit),
type: 'PAGE_CHANGE',
})
}
>
{/* Help assistive technology users with some context */}
<span className="offscreen">
{page === maxPage ? (
<FormattedMessage
{...messages.lastPageN}
values={{ page }}
/>
) : page === currentPage - 1 ? (
<FormattedMessage
{...messages.previousPageN}
values={{ page }}
/>
) : page === currentPage + 1 ? (
<FormattedMessage
{...messages.nextPageN}
values={{ page }}
/>
) : (
<FormattedMessage
{...messages.pageN}
values={{ page }}
/>
)}
</span>
<span aria-hidden={true}>
{/* Show context "Page 1" on the first item to make it obvious this is pagination */}
{page === 1 ? (
<FormattedMessage
{...messages.pageN}
values={{ page }}
/>
) : (
page
)}
</span>
</a>
</li>
)}
</React.Fragment>
))}
</ul>
</nav>
</div>
);
};
Loading

0 comments on commit be8a265

Please sign in to comment.