Skip to content

Commit

Permalink
Merge branch 'master' into brandable
Browse files Browse the repository at this point in the history
  • Loading branch information
scottaubrey committed Oct 15, 2024
2 parents e6c6122 + 5395169 commit c8f0fd4
Show file tree
Hide file tree
Showing 34 changed files with 292 additions and 110 deletions.
4 changes: 3 additions & 1 deletion docker-compose.prod.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# overrides that make the app behave like a production build
services:
app:
command: sh -c 'yarn build; yarn start'
build:
context: .
target: prod
healthcheck:
test: ["CMD-SHELL", "sh -c 'apk add curl; curl -X POST http://app:3000/'"]
interval: 5s
Expand Down
16 changes: 9 additions & 7 deletions src/components/atoms/assessment/assessment.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
@use "../../../sass/mixins";

.assessment {
@include mixins.margin(0 -24);
@include mixins.padding(24);
@include mixins.margin(0 -24 36);
@include mixins.padding(36 24);
@include typography.assessment-body();

.highlighted-term {
Expand Down Expand Up @@ -41,14 +41,12 @@
}

@media only all and (min-width: settings.$breakpoint-small) {
@include mixins.margin(0 -48);
@include mixins.padding(36 48);
@include mixins.margin(0 -48 36);
@include mixins.padding(48);
}

@media only all and (min-width: settings.$breakpoint-medium) {
@include mixins.padding(24 36);

margin: 0;
@include mixins.margin(0 0 36);
}

background-color: var(--color-background);
Expand All @@ -61,6 +59,10 @@
.assessment__body {
@include mixins.margin(12, "bottom");

p:first-of-type {
@include mixins.margin(0, "top");
}

p:last-of-type {
@include mixins.margin(0, "bottom");
}
Expand Down
1 change: 1 addition & 0 deletions src/components/atoms/assessment/assessment.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Meta, StoryObj } from '@storybook/react';
import { within, userEvent, expect } from '@storybook/test';
import { Assessment } from './assessment';
import '../../../i18n';

const meta: Meta<typeof Assessment> = {
title: 'Atoms/Assessment',
Expand Down
1 change: 1 addition & 0 deletions src/components/atoms/assessment/assessment.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { fireEvent, render, screen } from '@testing-library/react';
import { significanceTerms, strengthTerms } from '../../../utils/terms';
import { Assessment } from './assessment';
import '../../../i18n';

let mockPathName = '';
jest.mock('next/navigation', () => ({
Expand Down
1 change: 0 additions & 1 deletion src/components/atoms/assessment/assessment.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import './assessment.scss';
import '../../../i18n';
import { useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { TermsList } from '../terms-list/terms-list';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Meta, StoryObj } from '@storybook/react';
import { ReviewContent } from './review-content';
import '../../../i18n';

const meta: Meta<typeof ReviewContent> = {
title: 'Atoms/Review Content',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { render, screen } from '@testing-library/react';
import { ReviewContent } from './review-content';
import '../../../i18n';

describe('ReviewContent', () => {
it('renders with a simple string content', async () => {
Expand Down
1 change: 0 additions & 1 deletion src/components/atoms/review-content/review-content.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import './review-content.scss';
import '../../../i18n';
import { Descriptors } from '../descriptors/descriptors';

type Props = { content: string, id?: string, peerReviewUrl?: string, doi?: string };
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Meta, StoryObj } from '@storybook/react';
import { ReviewProcess } from './review-process';
import '../../../i18n';

const meta: Meta<typeof ReviewProcess> = {
title: 'Atoms/Review Process',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { render, screen } from '@testing-library/react';
import { ReviewProcess } from './review-process';
import '../../../i18n';

describe('Review Process', () => {
it('renders review process', () => {
Expand Down
1 change: 0 additions & 1 deletion src/components/atoms/review-process/review-process.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import './review-process.scss';
import '../../../i18n';
import { useTranslation } from 'react-i18next';
import parse from 'html-react-parser';

Expand Down
1 change: 1 addition & 0 deletions src/components/atoms/socials/socials.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Meta, StoryObj } from '@storybook/react';
import { Socials } from './socials';
import '../../../i18n';

const meta: Meta<typeof Socials> = {
title: 'Atoms/Socials',
Expand Down
1 change: 0 additions & 1 deletion src/components/atoms/socials/socials.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { useTranslation } from 'react-i18next';
import './socials.scss';
import '../../../i18n';

type SocialsProps = {
doi: string,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Meta, StoryObj } from '@storybook/react';
import { citation, metrics } from '../../../utils/mocks';
import { ArticleStatus } from './article-status';
import '../../../i18n';

const meta: Meta<typeof ArticleStatus> = {
title: 'Molecules/ArticleStatus',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { render, screen } from '@testing-library/react';
import { citation } from '../../../utils/mocks';
import { ArticleStatus } from './article-status';
import '../../../i18n';

describe('ArticleStatus', () => {
it('renders the article status and type if passed in', () => {
Expand Down
1 change: 0 additions & 1 deletion src/components/molecules/article-status/article-status.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { Socials } from '../../atoms/socials/socials';
import { Modal } from '../modal/modal';
import './article-status.scss';
import { Citation, CitationData } from '../../atoms/citation/citation';
import '../../../i18n';
import { ContextualData, ContextualDataProps } from '../../atoms/contextual-data/contextual-data';
import { Timeline, TimelineProps } from '../timeline/timeline';

Expand Down
1 change: 1 addition & 0 deletions src/components/molecules/timeline/timeline.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Meta, StoryObj } from '@storybook/react';
import { expect, userEvent, within } from '@storybook/test';
import { Timeline } from './timeline';
import '../../../i18n';

const meta: Meta<typeof Timeline> = {
title: 'Molecules/Timeline',
Expand Down
1 change: 1 addition & 0 deletions src/components/molecules/timeline/timeline.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { fireEvent, render, screen } from '@testing-library/react';
import { Timeline } from './timeline';
import '../../../i18n';

describe('Timeline', () => {
it('renders a single timeline item', () => {
Expand Down
1 change: 0 additions & 1 deletion src/components/molecules/timeline/timeline.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Fragment, useEffect, useState } from 'react';
import '../../../i18n';
import './timeline.scss';
import { formatDate } from '../../../utils/formatters';
import { TimelineEvent } from '../../../types';
Expand Down
13 changes: 11 additions & 2 deletions src/components/pages/article/article-page.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
}

.tabbed-navigation {
@include mixins.margin(0 -24 24);
@include mixins.margin(0 -24);
@include mixins.z-index(1);

background-color: #fff;
Expand All @@ -39,7 +39,7 @@
top: 0;

@media only screen and (min-width: settings.$breakpoint-small) {
@include mixins.margin(0 -48 36);
@include mixins.margin(0 -48);
}

@media only screen and (min-width: settings.$breakpoint-medium) {
Expand Down Expand Up @@ -127,4 +127,13 @@
@media only all and (min-width: settings.$breakpoint-large) {
display: flex;
}

&.tabbed-navigation__content--reviews,
&.tabbed-navigation__content--figures {
@include mixins.margin(36, "top");

@media only all and (min-width: settings.$breakpoint-medium) {
@include mixins.margin(0, "top");
}
}
}
1 change: 1 addition & 0 deletions src/components/pages/article/article-page.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { ArticleFullTextTab, ArticleFiguresTab, ArticleReviewsTab } from './tabs
import { DefaultLayout } from '../../layouts/default';
import { ErrorMessages } from '../../atoms/error-messages/error-messages';
import { contentToHeadings, contentToJsx } from '../../../utils/content';
import '../../../i18n';

const meta: Meta<typeof ArticlePage> = {
title: 'Pages/Article Page',
Expand Down
1 change: 1 addition & 0 deletions src/components/pages/article/article-page.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
} from '../../../utils/mocks';
import { ArticleFiguresTab, ArticleFullTextTab, ArticleReviewsTab } from './tabs';
import { contentToText } from '../../../utils/content';
import '../../../i18n';

jest.mock('next/navigation', () => ({
usePathname: () => '',
Expand Down
6 changes: 2 additions & 4 deletions src/components/pages/article/article-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@ import { useTranslation } from 'react-i18next';
import { ArticleStatus } from '../../molecules/article-status/article-status';
import { ContentHeader } from '../../molecules/content-header/content-header';
import './article-page.scss';
import { MetaData, TimelineEvent } from '../../../types';
import { MetaData, Metrics, TimelineEvent } from '../../../types';
import { ArticleFiguresTab, ArticleFullTextTab, ArticleReviewsTab } from './tabs';
import { contentToText } from '../../../utils/content/content-to-text';
import { contentToText } from '../../../utils/content';
import { CitationData } from '../../atoms/citation/citation';
import '../../../i18n';
import { RelatedContentData, RelatedContent } from '../../atoms/related-content/related-content';
import { Metrics } from '../../../types/enhanced-article';
import { PreviousVersionWarning } from '../../atoms/previous-version-warning/previous-version-warning';

export type ArticleStatusProps = {
Expand Down
2 changes: 1 addition & 1 deletion src/components/pages/article/tabs/figures-tab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ArticleContent } from '../../../atoms/article-content/article-content';
import { JSXContent } from '../../../../utils/content';

export const ArticleFiguresTab = ({ content }: { content: JSXContent }) => (
<div className="tabbed-navigation__content">
<div className="tabbed-navigation__content tabbed-navigation__content--figures">
<div className="menu-spacer"/>
<div className="article-body-container">
<Heading id="figures" headingLevel={2} content="Figures and data" />
Expand Down
7 changes: 2 additions & 5 deletions src/components/pages/article/tabs/fulltext-tab.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { render } from '@testing-library/react';
import { metaData, peerReview, content } from '../../../../utils/mocks';
import { ArticleFullTextTab } from './fulltext-tab';
import { contentToJsx } from '../../../../utils/content';
import '../../../../i18n';

jest.mock('next/navigation', () => ({
usePathname: () => '',
Expand Down Expand Up @@ -98,10 +99,6 @@ describe('FulltextTab', () => {
href: '#abstract',
text: 'Abstract',
},
{
href: '#assessment',
text: 'eLife assessment',
},
{
href: '#s1',
text: 'Introduction',
Expand Down Expand Up @@ -148,7 +145,7 @@ describe('FulltextTab', () => {
it('uses the heading ids for the hrefs in jump-to-menu', () => {
const { container } = render(<ArticleFullTextTab metrics={null} headings={[]} content={''} metaData={metaData} peerReview={peerReview}/>);

const headings = Array.from(container.querySelectorAll('section[id], h1, .heading-1'));
const headings = Array.from(container.querySelectorAll('.article-body-container section[id], h1, .heading-1'));
const ids = headings.map(({ id }) => id);

const links = Array.from(container.querySelectorAll<HTMLAnchorElement>('.jump-menu-list__link'));
Expand Down
28 changes: 12 additions & 16 deletions src/components/pages/article/tabs/fulltext-tab.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import '../article-page.scss';
import { useTranslation } from 'react-i18next';
import { ArticleContent } from '../../../atoms/article-content/article-content';
import { Heading, JumpToMenu } from '../../../atoms/jump-to-menu/jump-to-menu';
import { Abstract } from '../../../atoms/abstract/abstract';
import { ReferenceList } from '../../../atoms/reference-list/reference-list';
import { ArticleAndAuthorInformation } from '../../../molecules/article-and-author-information/article-and-author-information';
import { MetaData, PeerReview } from '../../../../types';
import { JSXContent } from '../../../../utils/content';
import '../../../../i18n';
import { Metrics as MetricsType } from '../../../../types/enhanced-article';
import { Metrics } from '../../../atoms/metrics/metrics';
import { Assessment } from '../../../atoms/assessment/assessment';
Expand All @@ -22,32 +20,30 @@ type Props = {
};

export const ArticleFullTextTab = (props: Props) => {
const { t } = useTranslation();
const headings = [
{ id: 'abstract', text: 'Abstract' },
...props.headings,
{ id: 'references', text: 'References' },
{ id: 'article-and-author-information', text: 'Article and Author Information' },
];

if (props.peerReview !== undefined) {
headings.splice(1, 0, { id: 'assessment', text: t('heading_assessment') });
}
if (props.metrics) {
headings.push({ id: 'metrics', text: 'Metrics' });
}

return (
<div className="tabbed-navigation__content">
<JumpToMenu headings={headings} />
<div className="article-body-container">
<Abstract content={props.metaData.abstract} />
{ props.peerReview && <Assessment content={props.peerReview.evaluationSummary.text} doi={props.peerReview.evaluationSummary.doi}/> }
<ArticleContent content={props.content} />
<ReferenceList references={props.metaData.references} />
<ArticleAndAuthorInformation authors={props.metaData.authors} authorNotes={props.metaData.authorNotes} versions={props.metaData.versionHistory} license={props.metaData.license} publishedYear={props.metaData.publishedYear} />
{ props.metrics && <Metrics metrics={props.metrics} /> }
<>
{ props.peerReview && <Assessment content={props.peerReview.evaluationSummary.text} doi={props.peerReview.evaluationSummary.doi}/> }
<div className="tabbed-navigation__content">
<JumpToMenu headings={headings} />
<div className="article-body-container">
<Abstract content={props.metaData.abstract} />
<ArticleContent content={props.content} />
<ReferenceList references={props.metaData.references} />
<ArticleAndAuthorInformation authors={props.metaData.authors} authorNotes={props.metaData.authorNotes} versions={props.metaData.versionHistory} license={props.metaData.license} publishedYear={props.metaData.publishedYear} />
{ props.metrics && <Metrics metrics={props.metrics} /> }
</div>
</div>
</div>
</>
);
};
2 changes: 1 addition & 1 deletion src/components/pages/article/tabs/reviews-tab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const ArticleReviewsTab = ({ peerReview, currentVersion }: { peerReview:
];

return (
<div className="tabbed-navigation__content">
<div className="tabbed-navigation__content tabbed-navigation__content--reviews">
<JumpToMenu headings={headings} />
<div className="article-body-container">
<ReviewProcess current={currentVersion} {...(peerReview.authorResponse ? { authorResponse: true } : {})} />
Expand Down
10 changes: 7 additions & 3 deletions src/pages/_app.page.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import Head from 'next/head';
import { Noto_Serif, Noto_Sans } from 'next/font/google';
import { ReactNode } from 'react';
import { I18nextProvider } from 'react-i18next';
import { DefaultLayout } from '../components/layouts/default';
import { config } from '../config';
import { BiophysicsColabLayout } from '../components/layouts/biophysics-colab';
import { SimpleSiteHeader } from '../components/molecules/site-header/simple-site-header';
import { brands } from '../brand';
import { i18n } from '../i18n';

const LayoutSelector = ({ siteName, children }: { siteName?: string, children: ReactNode }) => {
switch (siteName) {
Expand Down Expand Up @@ -120,9 +122,11 @@ export default function MyApp({ Component, pageProps }: any) {
}}></script>
}
</Head>
<LayoutSelector siteName={pageProps.siteName}>
<Component {...pageProps} />
</LayoutSelector>
<I18nextProvider i18n={i18n} defaultNS={pageProps.siteName?.replace('-', '_')}>
<LayoutSelector siteName={pageProps.siteName}>
<Component {...pageProps} />
</LayoutSelector>
</I18nextProvider>
</>
);
}
1 change: 0 additions & 1 deletion src/pages/reviewed-preprints/[...path].page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import {
import { generateStatus, generateTimeline, generateVersionHistory } from '../../utils/generators';
import { ErrorMessages } from '../../components/atoms/error-messages/error-messages';
import { formatAuthorName } from '../../utils/formatters';
import '../../i18n';
import { makeNullableOptional } from '../../utils/make-nullable-optional';
import { SerialisedTimelineEvent } from '../../types/article-timeline';
import { Brand, brands } from '../../brand';
Expand Down
1 change: 1 addition & 0 deletions src/types/content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export type FigureContent = DecoratedContent & {

export type ImageObjectContent = {
type: 'ImageObject',
id?: string,
contentUrl?: string,
content?: Content
meta: {
Expand Down
Loading

0 comments on commit c8f0fd4

Please sign in to comment.