Skip to content
This repository has been archived by the owner on Mar 11, 2024. It is now read-only.

Commit

Permalink
Show disclaimer in lang other than English
Browse files Browse the repository at this point in the history
Closes #545
  • Loading branch information
nop33 committed Jun 28, 2023
1 parent 3d95be3 commit 545545a
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 33 deletions.
4 changes: 3 additions & 1 deletion locales/en-US/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -434,5 +434,7 @@
"Your Wallet": "Your Wallet",
"{{ amount }} words entered": "{{ amount }} words entered",
"{{ number }} selected": "{{ number }} selected",
"No NFTs found.": "No NFTs found."
"No NFTs found.": "No NFTs found.",
"Disclaimer": "Disclaimer",
"The wallet is developed in English.<br />Translations in other languages are provided by the Alephium community.<br />In case of doubt, always refer to the English version.": "The wallet is developed in English.<br />Translations in other languages are provided by the Alephium community.<br />In case of doubt, always refer to the English version."
}
41 changes: 12 additions & 29 deletions src/components/Inputs/InlineLabelValueInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,46 +16,33 @@ You should have received a copy of the GNU Lesser General Public License
along with the library. If not, see <http://www.gnu.org/licenses/>.
*/

import { Info } from 'lucide-react'
import { ReactNode } from 'react'
import { useTranslation } from 'react-i18next'
import styled from 'styled-components'

import ActionLink from '@/components/ActionLink'
import { openInWebBrowser } from '@/utils/misc'

interface InlineLabelValueInputProps {
label: ReactNode
InputComponent: ReactNode
description?: string
moreInfoLink?: string
children?: ReactNode
className?: string
}

const InlineLabelValueInput = ({
label,
InputComponent,
description,
moreInfoLink,
children,
className
}: InlineLabelValueInputProps) => {
const { t } = useTranslation()

return (
<KeyValueInputContainer className={className}>
<KeyContainer>
<Label>{label}</Label>
{description && <DescriptionContainer>{description}</DescriptionContainer>}
{moreInfoLink && (
<ActionLinkStyled onClick={() => openInWebBrowser(moreInfoLink)}>
<Info size={12} /> {t('More info')}
</ActionLinkStyled>
)}
</KeyContainer>
<InputContainer>{InputComponent}</InputContainer>
</KeyValueInputContainer>
)
}
}: InlineLabelValueInputProps) => (
<KeyValueInputContainer className={className}>
<KeyContainer>
<Label>{label}</Label>
{description && <DescriptionContainer>{description}</DescriptionContainer>}
{children}
</KeyContainer>
<InputContainer>{InputComponent}</InputContainer>
</KeyValueInputContainer>
)

export default InlineLabelValueInput

Expand Down Expand Up @@ -88,7 +75,3 @@ const InputContainer = styled.div`
justify-content: flex-end;
flex: 1;
`

const ActionLinkStyled = styled(ActionLink)`
gap: 0.3em;
`
35 changes: 32 additions & 3 deletions src/modals/SettingsModal/GeneralSettingsSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@ You should have received a copy of the GNU Lesser General Public License
along with the library. If not, see <http://www.gnu.org/licenses/>.
*/

import { AlertTriangle, Info } from 'lucide-react'
import { usePostHog } from 'posthog-js/react'
import { useCallback, useState } from 'react'
import { useTranslation } from 'react-i18next'
import styled from 'styled-components'

import ActionLink from '@/components/ActionLink'
import Box from '@/components/Box'
import HorizontalDivider from '@/components/Dividers/HorizontalDivider'
import KeyValueInput from '@/components/Inputs/InlineLabelValueInput'
Expand All @@ -41,6 +44,7 @@ import {
import { switchTheme } from '@/storage/settings/settingsStorageUtils'
import { Currency, Language, ThemeSettings } from '@/types/settings'
import { links } from '@/utils/links'
import { openInWebBrowser } from '@/utils/misc'
import { fiatCurrencyOptions, languageOptions, locktimeInMinutes } from '@/utils/settings'

interface GeneralSettingsSectionProps {
Expand Down Expand Up @@ -201,7 +205,18 @@ const GeneralSettingsSection = ({ className }: GeneralSettingsSectionProps) => {
heightSize="small"
/>
}
/>
>
{language !== 'en-US' && (
<Disclaimer
data-tooltip-html={t(
'The wallet is developed in English.<br />Translations in other languages are provided by the Alephium community.<br />In case of doubt, always refer to the English version.'
)}
data-tooltip-id="default"
>
<AlertTriangle size={12} /> <span>{t('Disclaimer')}</span>
</Disclaimer>
)}
</KeyValueInput>
<HorizontalDivider />
<KeyValueInput
label={t('Currency')}
Expand All @@ -222,9 +237,12 @@ const GeneralSettingsSection = ({ className }: GeneralSettingsSectionProps) => {
<KeyValueInput
label={t('Analytics')}
description={t('Help us improve your experience!')}
moreInfoLink={links.analytics}
InputComponent={<Toggle toggled={analytics} onToggle={handleAnalyticsToggle} />}
/>
>
<ActionLinkStyled onClick={() => openInWebBrowser(links.analytics)}>
<Info size={12} /> {t('More info')}
</ActionLinkStyled>
</KeyValueInput>
<ModalPortal>
{isPasswordModelOpen && (
<CenteredModal title={t('Password')} onClose={() => setIsPasswordModalOpen(false)} focusMode skipFocusOnMount>
Expand All @@ -241,3 +259,14 @@ const GeneralSettingsSection = ({ className }: GeneralSettingsSectionProps) => {
}

export default GeneralSettingsSection

const ActionLinkStyled = styled(ActionLink)`
gap: 0.3em;
`

const Disclaimer = styled.div`
display: flex;
align-items: center;
gap: 0.3em;
color: ${({ theme }) => theme.global.highlight};
`

0 comments on commit 545545a

Please sign in to comment.