mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2025-09-22 19:46:39 +00:00
Disable language selection for everything other than English GB
This commit is contained in:
parent
dab6bf2e3e
commit
cec85b45a5
@ -104,6 +104,7 @@
|
|||||||
"green": "Green",
|
"green": "Green",
|
||||||
"blue": "Blue",
|
"blue": "Blue",
|
||||||
"custom": "Custom...",
|
"custom": "Custom...",
|
||||||
|
"comingSoon": "Coming soon",
|
||||||
"WorkInProgess": "Work in progress, May not work or be buggy, Please report any problems!",
|
"WorkInProgess": "Work in progress, May not work or be buggy, Please report any problems!",
|
||||||
"poweredBy": "Powered by",
|
"poweredBy": "Powered by",
|
||||||
"yes": "Yes",
|
"yes": "Yes",
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import React, { useState, useEffect } from 'react';
|
import React, { useState, useEffect } from 'react';
|
||||||
import { Menu, Button, ScrollArea, ActionIcon } from '@mantine/core';
|
import { Menu, Button, ScrollArea, ActionIcon, Tooltip } from '@mantine/core';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { supportedLanguages } from '../../i18n';
|
import { supportedLanguages } from '../../i18n';
|
||||||
import LocalIcon from './LocalIcon';
|
import LocalIcon from './LocalIcon';
|
||||||
@ -33,6 +33,7 @@ interface LanguageItemProps {
|
|||||||
rippleEffect?: RippleEffect | null;
|
rippleEffect?: RippleEffect | null;
|
||||||
pendingLanguage: string | null;
|
pendingLanguage: string | null;
|
||||||
compact: boolean;
|
compact: boolean;
|
||||||
|
disabled?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const LanguageItem: React.FC<LanguageItemProps> = ({
|
const LanguageItem: React.FC<LanguageItemProps> = ({
|
||||||
@ -43,8 +44,19 @@ const LanguageItem: React.FC<LanguageItemProps> = ({
|
|||||||
onClick,
|
onClick,
|
||||||
rippleEffect,
|
rippleEffect,
|
||||||
pendingLanguage,
|
pendingLanguage,
|
||||||
compact
|
compact,
|
||||||
|
disabled = false
|
||||||
}) => {
|
}) => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
const label = disabled ? (
|
||||||
|
<Tooltip label={t('comingSoon', 'Coming soon')} position="left" withArrow>
|
||||||
|
<p>{option.label}</p>
|
||||||
|
</Tooltip>
|
||||||
|
) : (
|
||||||
|
<p>{option.label}</p>
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={styles.languageItem}
|
className={styles.languageItem}
|
||||||
@ -58,8 +70,9 @@ const LanguageItem: React.FC<LanguageItemProps> = ({
|
|||||||
variant="subtle"
|
variant="subtle"
|
||||||
size="sm"
|
size="sm"
|
||||||
fullWidth
|
fullWidth
|
||||||
onClick={onClick}
|
onClick={disabled ? undefined : onClick}
|
||||||
data-selected={isSelected}
|
data-selected={isSelected}
|
||||||
|
disabled={disabled}
|
||||||
styles={{
|
styles={{
|
||||||
root: {
|
root: {
|
||||||
borderRadius: '4px',
|
borderRadius: '4px',
|
||||||
@ -71,17 +84,20 @@ const LanguageItem: React.FC<LanguageItemProps> = ({
|
|||||||
backgroundColor: isSelected
|
backgroundColor: isSelected
|
||||||
? 'light-dark(var(--mantine-color-blue-1), var(--mantine-color-blue-8))'
|
? 'light-dark(var(--mantine-color-blue-1), var(--mantine-color-blue-8))'
|
||||||
: 'transparent',
|
: 'transparent',
|
||||||
color: isSelected
|
color: disabled
|
||||||
|
? 'light-dark(var(--mantine-color-gray-5), var(--mantine-color-dark-3))'
|
||||||
|
: isSelected
|
||||||
? 'light-dark(var(--mantine-color-blue-9), var(--mantine-color-white))'
|
? 'light-dark(var(--mantine-color-blue-9), var(--mantine-color-white))'
|
||||||
: 'light-dark(var(--mantine-color-gray-7), var(--mantine-color-white))',
|
: 'light-dark(var(--mantine-color-gray-7), var(--mantine-color-white))',
|
||||||
transition: 'all 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94)',
|
transition: 'all 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94)',
|
||||||
'&:hover': {
|
cursor: disabled ? 'not-allowed' : 'pointer',
|
||||||
|
'&:hover': !disabled ? {
|
||||||
backgroundColor: isSelected
|
backgroundColor: isSelected
|
||||||
? 'light-dark(var(--mantine-color-blue-2), var(--mantine-color-blue-7))'
|
? 'light-dark(var(--mantine-color-blue-2), var(--mantine-color-blue-7))'
|
||||||
: 'light-dark(var(--mantine-color-gray-1), var(--mantine-color-dark-5))',
|
: 'light-dark(var(--mantine-color-gray-1), var(--mantine-color-dark-5))',
|
||||||
transform: 'translateY(-1px)',
|
transform: 'translateY(-1px)',
|
||||||
boxShadow: '0 2px 8px rgba(0, 0, 0, 0.1)',
|
boxShadow: '0 2px 8px rgba(0, 0, 0, 0.1)',
|
||||||
}
|
} : {}
|
||||||
},
|
},
|
||||||
label: {
|
label: {
|
||||||
fontSize: '13px',
|
fontSize: '13px',
|
||||||
@ -95,7 +111,7 @@ const LanguageItem: React.FC<LanguageItemProps> = ({
|
|||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{option.label}
|
{label}
|
||||||
{!compact && rippleEffect && pendingLanguage === option.value && (
|
{!compact && rippleEffect && pendingLanguage === option.value && (
|
||||||
<div
|
<div
|
||||||
key={rippleEffect.key}
|
key={rippleEffect.key}
|
||||||
@ -252,19 +268,25 @@ const LanguageSelector: React.FC<LanguageSelectorProps> = ({ position = 'bottom-
|
|||||||
>
|
>
|
||||||
<ScrollArea h={190} type="scroll">
|
<ScrollArea h={190} type="scroll">
|
||||||
<div className={styles.languageGrid}>
|
<div className={styles.languageGrid}>
|
||||||
{languageOptions.map((option, index) => (
|
{languageOptions.map((option, index) => {
|
||||||
<LanguageItem
|
const isEnglishGB = option.value === 'en-GB'; // Currently only English GB has enough translations to use
|
||||||
key={option.value}
|
const isDisabled = !isEnglishGB;
|
||||||
option={option}
|
|
||||||
index={index}
|
return (
|
||||||
animationTriggered={animationTriggered}
|
<LanguageItem
|
||||||
isSelected={option.value === i18n.language}
|
key={option.value}
|
||||||
onClick={(event) => handleLanguageChange(option.value, event)}
|
option={option}
|
||||||
rippleEffect={rippleEffect}
|
index={index}
|
||||||
pendingLanguage={pendingLanguage}
|
animationTriggered={animationTriggered}
|
||||||
compact={compact}
|
isSelected={option.value === i18n.language}
|
||||||
/>
|
onClick={(event) => handleLanguageChange(option.value, event)}
|
||||||
))}
|
rippleEffect={rippleEffect}
|
||||||
|
pendingLanguage={pendingLanguage}
|
||||||
|
compact={compact}
|
||||||
|
disabled={isDisabled}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
})}
|
||||||
</div>
|
</div>
|
||||||
</ScrollArea>
|
</ScrollArea>
|
||||||
</Menu.Dropdown>
|
</Menu.Dropdown>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user