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

lib-user: Setup react-i18next for HeaderDropdown, ProfileHeader, and TopProjects #6559

Open
wants to merge 1 commit into
base: translations-group-form
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
Expand Up @@ -4,6 +4,7 @@ import styled, { css } from 'styled-components'
import { Box, DropButton } from 'grommet'
import { FormDown } from 'grommet-icons'
import { SpacedText } from '@zooniverse/react-components'
import { useTranslation } from '../../../../translations/i18n.js'

const StyledDropButton = styled(DropButton)`
position: relative;
Expand Down Expand Up @@ -57,6 +58,7 @@ const StyledLi = styled.li`
`

function HeaderDropdown({ secondaryHeaderItems = [] }) {
const { t } = useTranslation()
const [isOpen, setIsOpen] = useState(false)

const handleOpen = () => {
Expand Down Expand Up @@ -98,7 +100,7 @@ function HeaderDropdown({ secondaryHeaderItems = [] }) {
pad={{ horizontal: 'medium', vertical: 'xsmall' }}
>
<SpacedText size='.78rem' weight={700}>
Group Options
{t('HeaderDropdown.label')}
</SpacedText>
<FormDown color='white' />
</Box>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { SpacedText, ZooniverseLogo } from '@zooniverse/react-components'
import { Box, ResponsiveContext } from 'grommet'
import { number, string } from 'prop-types'
import { useContext } from 'react'
import { useTranslation } from '../../../translations/i18n.js'

import {
Avatar,
Expand All @@ -17,6 +18,7 @@ function ProfileHeader({
login = '',
projects = undefined
}) {
const { t } = useTranslation()
const size = useContext(ResponsiveContext)

return (
Expand Down Expand Up @@ -65,25 +67,25 @@ function ProfileHeader({
>
{classifications !== undefined ?
<TitledStat
title='Classifications'
title={t('common.classifications')}
value={classifications}
/>
: null}
{hours !== undefined ?
<TitledStat
title='Hours'
title={t('common.hours')}
value={hours}
/>
: null}
{contributors !== undefined ?
<TitledStat
title='Contributors'
title={t('common.contributors')}
value={contributors}
/>
: null}
{projects !== undefined ?
<TitledStat
title='Projects'
title={t('common.projects')}
value={projects}
/>
: null}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { arrayOf, bool, node, number, string, shape } from 'prop-types'
import { useContext } from 'react'
import styled from 'styled-components'
import { Loader, ProjectCard } from '@zooniverse/react-components'
import { useTranslation } from '../../../translations/i18n.js'

import { ContentBox } from '@components/shared'

Expand All @@ -23,9 +24,10 @@ const StyledRowList = styled(Box)`
`

function CardsGrid({ children }) {
const { t } = useTranslation()
return (
<StyledGridList
a11yTitle='Top Projects'
a11yTitle={t('TopProjects.title')}
columns={['1fr', '1fr', '1fr']}
forwardedAs='ul'
gap='xsmall'
Expand All @@ -43,9 +45,10 @@ CardsGrid.propTypes = {
}

function CardsRow({ children }) {
const { t } = useTranslation()
return (
<StyledRowList
a11yTitle='Top Projects'
a11yTitle={t('TopProjects.title')}
direction='row'
forwardedAs='ul'
gap='small'
Expand All @@ -71,6 +74,7 @@ function TopProjects({
loading = false,
projects = []
}) {
const { t } = useTranslation()
const size = useContext(ResponsiveContext)
const cardSize = grid ? 'small' : size

Expand All @@ -96,7 +100,7 @@ function TopProjects({

return (
<ContentBox
title='Top Projects'
title={t('TopProjects.title')}
>
{loading ? (
<Box
Expand Down
6 changes: 6 additions & 0 deletions packages/lib-user/src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@
"title": "Top Contributors"
}
},
"HeaderDropdown": {
"label": "Group Options"
},
"MyGroups": {
"createNew": "Create new group",
"error": "There was an error fetching your groups",
Expand All @@ -110,6 +113,9 @@
"seeAll": "See all"
}
},
"TopProjects": {
"title": "Top Projects"
},
"UserHome": {
"Dashboard": {
"allTime": "All Time",
Expand Down
Loading