Skip to content
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

perf(web): performance tweaks #972

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
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
18 changes: 9 additions & 9 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
{
"login": "emmahodcroft",
"name": "Emma Hodcroft",
"avatar_url": "https://avatars1.githubusercontent.com/u/14290674?v=4",
"avatar_url": "https://avatars1.githubusercontent.com/u/14290674?v=4&s=48",
"profile": "https://github.com/emmahodcroft",
"contributions": [
"ideas",
Expand All @@ -23,7 +23,7 @@
{
"login": "tsibley",
"name": "Thomas Sibley",
"avatar_url": "https://avatars2.githubusercontent.com/u/79913?v=4",
"avatar_url": "https://avatars2.githubusercontent.com/u/79913?v=4&s=48",
"profile": "https://tsibley.net/",
"contributions": [
"infra",
Expand All @@ -33,7 +33,7 @@
{
"login": "victorlin",
"name": "Victor Lin",
"avatar_url": "https://avatars2.githubusercontent.com/u/13424970?v=4",
"avatar_url": "https://avatars2.githubusercontent.com/u/13424970?v=4&s=48",
"profile": "https://github.com/victorlin",
"contributions": [
"code",
Expand All @@ -43,7 +43,7 @@
{
"login": "theosanderson",
"name": "Theo Sanderson",
"avatar_url": "https://avatars.githubusercontent.com/u/19732295?v=4",
"avatar_url": "https://avatars.githubusercontent.com/u/19732295?v=4&s=48",
"profile": "http://theo.io/",
"contributions": [
"code"
Expand All @@ -52,7 +52,7 @@
{
"login": "stroudn1",
"name": "Natalie Stroud",
"avatar_url": "https://avatars3.githubusercontent.com/u/17433156?v=4",
"avatar_url": "https://avatars3.githubusercontent.com/u/17433156?v=4&s=48",
"profile": "http://www.natalieastroud.com/",
"contributions": [
"content",
Expand All @@ -62,7 +62,7 @@
{
"login": "iskandr",
"name": "Alex Rubinsteyn",
"avatar_url": "https://avatars.githubusercontent.com/u/48441?v=4",
"avatar_url": "https://avatars.githubusercontent.com/u/48441?v=4&s=48",
"profile": "http://www.rubinsteyn.com/",
"contributions": [
"doc"
Expand All @@ -71,7 +71,7 @@
{
"login": "molecules",
"name": "Christopher Bottoms",
"avatar_url": "https://avatars.githubusercontent.com/u/345060?v=4",
"avatar_url": "https://avatars.githubusercontent.com/u/345060?v=4&s=48",
"profile": "https://github.com/molecules",
"contributions": [
"doc"
Expand All @@ -80,7 +80,7 @@
{
"login": "fmaguire",
"name": "Finlay Maguire",
"avatar_url": "https://avatars.githubusercontent.com/u/1698629?v=4",
"avatar_url": "https://avatars.githubusercontent.com/u/1698629?v=4&s=48",
"profile": "http://finlaymagui.re/",
"contributions": [
"doc"
Expand All @@ -89,7 +89,7 @@
{
"login": "dnanto",
"name": "dnanto",
"avatar_url": "https://avatars.githubusercontent.com/u/49757922?v=4",
"avatar_url": "https://avatars.githubusercontent.com/u/49757922?v=4&s=48",
"profile": "https://github.com/dnanto",
"contributions": [
"code",
Expand Down
3 changes: 2 additions & 1 deletion packages_rs/nextclade-web/config/next/withSvg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ export default function withSvg(nextConfig: NextConfig) {
loader: '@svgr/webpack',
options: {
removeViewbox: false,
typescript: false,
typescript: true,
},
},
'url-loader',
],
}))
}
16 changes: 10 additions & 6 deletions packages_rs/nextclade-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@
"pretty-bytes": "5.6.0",
"prop-types": "15.8.1",
"re-reselect": "4.0.0",
"react": "18.1.0",
"react": "18.2.0",
"react-awesome-popover": "6.1.1",
"react-dom": "18.1.0",
"react-dom": "18.2.0",
"react-error-boundary": "3.1.4",
"react-file-icon": "1.1.0",
"react-helmet": "6.1.0",
Expand All @@ -137,8 +137,8 @@
"react-window": "1.8.7",
"reactstrap": "8.10.1",
"recharts": "2.1.9",
"recoil": "0.7.2",
"recoil-persist": "4.1.0",
"recoil": "0.7.5",
"recoil-persist": "4.2.0",
"redux": "4.2.0",
"redux-saga": "1.1.3",
"redux-thunk": "2.4.1",
Expand Down Expand Up @@ -175,6 +175,7 @@
"@testing-library/user-event": "14.1.1",
"@types/classnames": "2.3.0",
"@types/compare-versions": "3.3.0",
"@types/compression": "1.7.2",
"@types/compression-webpack-plugin": "9.0.0",
"@types/connect-history-api-fallback": "1.3.5",
"@types/copy-webpack-plugin": "6.4.3",
Expand Down Expand Up @@ -225,6 +226,7 @@
"allow-methods": "3.1.0",
"babel-plugin-parameter-decorator": "1.0.16",
"babel-plugin-transform-typescript-metadata": "0.3.2",
"compression": "1.7.4",
"compression-webpack-plugin": "9.2.0",
"connect-history-api-fallback": "1.6.0",
"conventional-changelog-cli": "2.2.2",
Expand Down Expand Up @@ -405,11 +407,13 @@
"papaparse": "5.2.0",
"postcss-loader": "6.2.1",
"pretty-bytes": "5.6.0",
"react": "18.1.0",
"react-dom": "18.1.0",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-error-boundary": "2.2.3",
"react-i18next": "11.16.7",
"react-redux": "7.2.8",
"recoil": "0.7.5",
"recoil-persist": "4.2.0",
"redux": "4.2.0",
"reflect-metadata": "0.1.13",
"serialize-javascript": "6.0.0",
Expand Down
116 changes: 15 additions & 101 deletions packages_rs/nextclade-web/src/components/Citation/CitationButton.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,13 @@
import React, { useCallback, useState } from 'react'

import { useTranslation } from 'react-i18next'
import {
Button,
ButtonProps,
Col,
Container,
Modal as ReactstrapModal,
ModalBody as ReactstrapModalBody,
ModalFooter as ReactstrapModalFooter,
ModalHeader as ReactstrapModalHeader,
Row,
} from 'reactstrap'
import React, { useCallback, useMemo, useState } from 'react'
import dynamic from 'next/dynamic'
import styled from 'styled-components'
import { useTranslation } from 'react-i18next'
import { HiOutlineAcademicCap } from 'react-icons/hi'
import { ButtonProps } from 'reactstrap'

import { ButtonTransparent } from 'src/components/Common/ButtonTransparent'
import { Citation } from 'src/components/Citation/Citation'

const CitationDialog = dynamic(() => import('src/components/Citation/CitationDialog'), { ssr: false })

export const ButtonCitationBase = styled(ButtonTransparent)<ButtonProps>`
margin: 2px 2px;
Expand All @@ -29,103 +20,26 @@ export const ButtonCitationBase = styled(ButtonTransparent)<ButtonProps>`
}
`

export const ButtonOk = styled(Button)<ButtonProps>`
width: 100px;
`

export const ModalHeader = styled(ReactstrapModalHeader)`
.modal-title {
width: 100%;
}

@media (max-width: 992px) {
padding: 0.25rem;
margin: 0.5rem;
margin-bottom: 0;
}
`

export const Modal = styled(ReactstrapModal)`
height: 100%;

// fullscreen on mobile
@media (max-width: 992px) {
max-width: unset;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
margin: 0;
padding: 0;

.modal-content {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
margin: 0;
}
}
`

export const ModalBody = styled(ReactstrapModalBody)`
@media (min-width: 991.98px) {
max-height: 66vh;
margin: auto;
}

@media (max-width: 992px) {
margin: 1rem 0;
padding: 0;
}

overflow-y: auto;
`

export const ModalFooter = styled(ReactstrapModalFooter)`
margin: 0;
padding: 0;
`

export function CitationButton() {
const { t } = useTranslation()
const [showCitation, setShowCitation] = useState(false)
const toggleOpen = useCallback(() => setShowCitation((showCitation) => !showCitation), [])
const open = useCallback(() => setShowCitation(true), [])
const close = useCallback(() => setShowCitation(false), [])
const totggle = useCallback(() => setShowCitation((showCitation) => !showCitation), [])
const text = t('Citation')
const closeText = t('Close this window')
const dialog = useMemo(() => {
if (!showCitation) {
return null
}
return <CitationDialog isOpen={showCitation} toggle={totggle} />
}, [showCitation, totggle])
Copy link
Member

@corneliusroemer corneliusroemer Aug 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

totggle is a typo of toggle I think :)


return (
<>
<ButtonCitationBase type="button" onClick={open} title={text}>
<ButtonCitationBase type="button" onClick={totggle} title={text}>
<HiOutlineAcademicCap className="mr-xl-2" />
<span className="d-none d-xl-inline">{text}</span>
</ButtonCitationBase>

<Modal centered isOpen={showCitation} toggle={toggleOpen} fade={false} size="lg">
<ModalHeader toggle={close} tag="div">
<h2 className="text-center">{text}</h2>
</ModalHeader>

<ModalBody>
<Citation />
</ModalBody>

<ModalFooter>
<Container fluid>
<Row noGutters className="my-2">
<Col className="d-flex w-100">
<ButtonOk className="ml-auto" type="button" color="success" onClick={close} title={closeText}>
{t('OK')}
</ButtonOk>
</Col>
</Row>
</Container>
</ModalFooter>
</Modal>
{dialog}
</>
)
}
106 changes: 106 additions & 0 deletions packages_rs/nextclade-web/src/components/Citation/CitationDialog.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
import React from 'react'
import {
Button,
ButtonProps,
Col,
Container,
Modal as ReactstrapModal,
ModalBody as ReactstrapModalBody,
ModalFooter as ReactstrapModalFooter,
ModalHeader as ReactstrapModalHeader,
Row,
} from 'reactstrap'
import { Citation } from 'src/components/Citation/Citation'
import { useTranslationSafe } from 'src/helpers/useTranslationSafe'
import styled from 'styled-components'

export const ButtonOk = styled(Button)<ButtonProps>`
width: 100px;
`
export const ModalHeader = styled(ReactstrapModalHeader)`
.modal-title {
width: 100%;
}

@media (max-width: 992px) {
padding: 0.25rem;
margin: 0.5rem;
margin-bottom: 0;
}
`
export const Modal = styled(ReactstrapModal)`
height: 100%;

// fullscreen on mobile
@media (max-width: 992px) {
max-width: unset;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
margin: 0;
padding: 0;

.modal-content {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
margin: 0;
}
}
`
export const ModalBody = styled(ReactstrapModalBody)`
@media (min-width: 991.98px) {
max-height: 66vh;
margin: auto;
}

@media (max-width: 992px) {
margin: 1rem 0;
padding: 0;
}

overflow-y: auto;
`
export const ModalFooter = styled(ReactstrapModalFooter)`
margin: 0;
padding: 0;
`

export interface CitationDialogProps {
isOpen: boolean
toggle: () => void
}

export default function CitationDialog({ isOpen, toggle }: CitationDialogProps) {
const { t } = useTranslationSafe()
const text = t('Citation')
const closeText = t('Close this window')

return (
<Modal centered isOpen={isOpen} toggle={toggle} fade={false} size="lg">
<ModalHeader toggle={toggle} tag="div">
<h2 className="text-center">{text}</h2>
</ModalHeader>

<ModalBody>
<Citation />
</ModalBody>

<ModalFooter>
<Container fluid>
<Row noGutters className="my-2">
<Col className="d-flex w-100">
<ButtonOk className="ml-auto" type="button" color="success" onClick={toggle} title={closeText}>
{t('Ok')}
</ButtonOk>
</Col>
</Row>
</Container>
</ModalFooter>
</Modal>
)
}
Loading