Skip to content

Migrate components in Welcome page to Typescript #2360

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import React from 'react'
import { withTranslation, Trans } from 'react-i18next'
import Box from '../box/Box.js'
import { Trans, useTranslation } from 'react-i18next'
import Box from '../box/Box.tsx'

const AboutIpfs = () => {
const { t } = useTranslation('welcome')

export const AboutIpfs = ({ t }) => {
return (
<Box>
<h2 className='mt0 mb3 montserrat fw2 f3 charcoal'>{t('aboutIpfs.header')}</h2>
Expand All @@ -27,4 +29,4 @@ export const AboutIpfs = ({ t }) => {
)
}

export default withTranslation('welcome')(AboutIpfs)
export default AboutIpfs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React from 'react'
import { withTranslation, Trans } from 'react-i18next'
import Box from '../box/Box.js'
import { Trans, useTranslation } from 'react-i18next'
import Box from '../box/Box.tsx'

export const AboutWebUI = ({ t }) => {
const AboutWebUI = () => {
const { t } = useTranslation('welcome')
return (
<Box>
<h2 className='mt0 mb3 montserrat fw2 f3 charcoal'>{t('welcomeInfo.header')}</h2>
Expand Down Expand Up @@ -30,4 +31,4 @@ export const AboutWebUI = ({ t }) => {
)
}

export default withTranslation('welcome')(AboutWebUI)
export default AboutWebUI
13 changes: 9 additions & 4 deletions src/components/box/Box.js → src/components/box/Box.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import React from 'react'
import React, { CSSProperties, ReactElement } from 'react'
import ErrorBoundary from '../error/ErrorBoundary.js'

type Props = {
className?: string
style?: CSSProperties
children?: ReactElement | ReactElement[] | string
}

export const Box = ({
className = 'pa4',
style,
children,
...props
}) => {
children
}: Props) => {
return (
<section className={className} style={{ background: '#fbfbfb', ...style }}>
<ErrorBoundary>
Expand Down
2 changes: 1 addition & 1 deletion src/components/cli-tutor-mode/CliTutorMode.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Modal, ModalBody, ModalActions } from '../modal/Modal.js'
import StrokeCode from '../../icons/StrokeCode.js'
import Button from '../button/button.tsx'
import Overlay from '../overlay/Overlay.js'
import Shell from '../shell/Shell.js'
import Shell from '../shell/Shell.tsx'
import StrokeDownload from '../../icons/StrokeDownload.js'
import { cliCmdKeys, cliCommandList, cliCmdPrefixes } from '../../bundles/files/consts.js'

Expand Down
2 changes: 1 addition & 1 deletion src/components/experiments/ExperimentsPanel.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react'
import { connect } from 'redux-bundler-react'
import Checkbox from '../checkbox/Checkbox.js'
import Box from '../box/Box.js'
import Box from '../box/Box.tsx'
import Title from '../../settings/Title.js'

const Experiments = ({ doExpToggleAction, experiments, t }) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import React from 'react'
import { withTranslation } from 'react-i18next'
import Box from '../box/Box.js'
import { useTranslation } from 'react-i18next'
import Box from '../box/Box.tsx'
import GlyphTick from '../../icons/GlyphTick.js'

export const IsConnected = ({ t }) => {
const IsConnected = () => {
const { t } = useTranslation('welcome')
return (
<Box className='pv3 ph4'>
<div>
Expand All @@ -17,4 +18,4 @@ export const IsConnected = ({ t }) => {
)
}

export default withTranslation('welcome')(IsConnected)
export default IsConnected
4 changes: 2 additions & 2 deletions src/components/is-not-connected/IsNotConnected.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { connect } from 'redux-bundler-react'
import { withTranslation, Trans } from 'react-i18next'
import classNames from 'classnames'
import ApiAddressForm from '../api-address-form/ApiAddressForm.js'
import Box from '../box/Box.js'
import Shell from '../shell/Shell.js'
import Box from '../box/Box.tsx'
import Shell from '../shell/Shell.tsx'
import GlyphAttention from '../../icons/GlyphAttention.js'

const TABS = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
import React from 'react'
import React, { ReactElement } from 'react'
import classNames from 'classnames'

type Props = {
title?: string
children: ReactElement | ReactElement[]
className?: string
}

const Shell = ({
title = 'Shell',
children,
className
}) => {
}: Props) => {
return (
<div className={classNames('br1 overflow-hidden', className)}>
<div className='f7 mb0 sans-serif ttu tracked charcoal pv1 pl2 bg-black-20'>{ title }</div>
Expand Down
2 changes: 1 addition & 1 deletion src/files/info-boxes/add-files-info/AddFilesInfo.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react'
import { withTranslation, Trans } from 'react-i18next'
import Box from '../../../components/box/Box.js'
import Box from '../../../components/box/Box.tsx'

const AddFilesInfo = ({ t }) => (
<div className='mv4 tc navy f5' >
Expand Down
2 changes: 1 addition & 1 deletion src/files/info-boxes/companion-info/CompanionInfo.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react'
import { withTranslation, Trans } from 'react-i18next'
import Box from '../../../components/box/Box.js'
import Box from '../../../components/box/Box.tsx'

const CompanionInfo = ({ t }) => (
<div className='mv4 tc navy f5' >
Expand Down
2 changes: 1 addition & 1 deletion src/peers/PeersPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { peersTour } from '../lib/tours.js'
import { getJoyrideLocales } from '../helpers/i8n.js'

// Components
import Box from '../components/box/Box.js'
import Box from '../components/box/Box.tsx'
import WorldMap from './WorldMap/WorldMap.js'
import PeersTable from './PeersTable/PeersTable.js'
import AddConnection from './AddConnection/AddConnection.js'
Expand Down
2 changes: 1 addition & 1 deletion src/settings/AnalyticsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react'
import { Helmet } from 'react-helmet'
import { withTranslation } from 'react-i18next'
import Title from './Title.js'
import Box from '../components/box/Box.js'
import Box from '../components/box/Box.tsx'
import AnalyticsToggle from '../components/analytics-toggle/AnalyticsToggle.js'

export const AnalyticsPage = ({ t }) => (
Expand Down
2 changes: 1 addition & 1 deletion src/settings/SettingsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import withTour from '../components/tour/withTour.js'
import { getJoyrideLocales } from '../helpers/i8n.js'
// Components
import Tick from '../icons/GlyphSmallTick.js'
import Box from '../components/box/Box.js'
import Box from '../components/box/Box.tsx'
import Button from '../components/button/button.tsx'
import LanguageSelector from '../components/language-selector/LanguageSelector.js'
import PinningManager from '../components/pinning-manager/PinningManager.js'
Expand Down
4 changes: 2 additions & 2 deletions src/status/BandwidthStatsDisabled.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react'
import { withTranslation, Trans } from 'react-i18next'
import Shell from '../components/shell/Shell.js'
import Box from '../components/box/Box.js'
import Shell from '../components/shell/Shell.tsx'
import Box from '../components/box/Box.tsx'

const StatusNotConnected = ({ t }) => {
return (
Expand Down
2 changes: 1 addition & 1 deletion src/status/PeerBandwidthTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { withTranslation } from 'react-i18next'
import PropTypes from 'prop-types'
import { humanSize } from '../lib/files.js'
import CountryFlag from 'react-country-flag'
import Box from '../components/box/Box.js'
import Box from '../components/box/Box.tsx'
import { Title } from './Commons.js'
import ComponentLoader from '../loader/ComponentLoader.js'

Expand Down
2 changes: 1 addition & 1 deletion src/status/StatusPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import NodeInfo from './NodeInfo.js'
import NodeInfoAdvanced from './NodeInfoAdvanced.js'
import NodeBandwidthChart from './NodeBandwidthChart.js'
import NetworkTraffic from './NetworkTraffic.js'
import Box from '../components/box/Box.js'
import Box from '../components/box/Box.tsx'
import AnalyticsBanner from '../components/analytics-banner/AnalyticsBanner.js'
import { statusTour } from '../lib/tours.js'
import { getJoyrideLocales } from '../helpers/i8n.js'
Expand Down
14 changes: 6 additions & 8 deletions src/welcome/WelcomePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,24 @@ import { welcomeTour } from '../lib/tours.js'
import { getJoyrideLocales } from '../helpers/i8n.js'

// Components
import IsConnected from '../components/is-connected/IsConnected.js'
import IsConnected from '../components/is-connected/IsConnected.tsx'
import IsNotConnected from '../components/is-not-connected/IsNotConnected.js'
import AboutIpfs from '../components/about-ipfs/AboutIpfs.js'
import AboutWebUI from '../components/about-webui/AboutWebUI.js'
import AboutIpfs from '../components/about-ipfs/AboutIpfs.tsx'
import AboutWebUI from '../components/about-webui/AboutWebUI.tsx'
import ComponentLoader from '../loader/ComponentLoader.js'

const WelcomePage = ({ t, apiUrl, ipfsInitFailed, ipfsConnected, ipfsReady, toursEnabled, handleJoyrideCallback }) => {
const WelcomePage = ({ t, ipfsInitFailed, ipfsConnected, ipfsReady, toursEnabled, handleJoyrideCallback }) => {
if (!ipfsInitFailed && !ipfsReady) {
return <ComponentLoader />
}

const isSameOrigin = window.location.origin === apiUrl

return (
<div>
<Helmet>
<title>{t('title')}</title>
</Helmet>
<div className='lh-copy charcoal'>
<ConnectionStatus connected={ipfsConnected} sameOrigin={isSameOrigin} t={t} />
<ConnectionStatus connected={ipfsConnected} />
</div>
<ReactJoyride
run={toursEnabled}
Expand All @@ -40,7 +38,7 @@ const WelcomePage = ({ t, apiUrl, ipfsInitFailed, ipfsConnected, ipfsReady, tour
)
}

const ConnectionStatus = ({ t, connected, sameOrigin }) => {
const ConnectionStatus = ({ connected }) => {
if (connected) {
return (
<div>
Expand Down