-
-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #984 from WatWowMap/locales-editing-page
feat: locales editing page
- Loading branch information
Showing
21 changed files
with
462 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -216,3 +216,9 @@ type ValidUserObj { | |
loggedIn: Boolean | ||
admin: Boolean | ||
} | ||
|
||
type Locales { | ||
human: JSON | ||
ai: JSON | ||
missing: JSON | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import * as React from 'react' | ||
import Table from '@mui/material/Table' | ||
import TableBody from '@mui/material/TableBody' | ||
import TableContainer from '@mui/material/TableContainer' | ||
import TableHead from '@mui/material/TableHead' | ||
import TableRow from '@mui/material/TableRow' | ||
import Paper from '@mui/material/Paper' | ||
import { TableVirtuoso } from 'react-virtuoso' | ||
|
||
const COMPONENTS = { | ||
Scroller: React.forwardRef((props, ref) => ( | ||
<TableContainer component={Paper} {...props} ref={ref} /> | ||
)), | ||
Table: (props) => ( | ||
<Table | ||
{...props} | ||
sx={{ borderCollapse: 'separate', tableLayout: 'fixed' }} | ||
/> | ||
), | ||
TableHead, | ||
// eslint-disable-next-line no-unused-vars | ||
TableRow: ({ item: _, ...props }) => <TableRow {...props} />, | ||
TableBody: React.forwardRef((props, ref) => ( | ||
<TableBody {...props} ref={ref} /> | ||
)), | ||
} | ||
|
||
/** @param {import('react-virtuoso').TableVirtuosoProps} props */ | ||
export function VirtualTable(props) { | ||
return <TableVirtuoso components={COMPONENTS} {...props} /> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import * as React from 'react' | ||
import FormControlLabel from '@mui/material/FormControlLabel' | ||
import Switch from '@mui/material/Switch' | ||
import { useTranslation } from 'react-i18next' | ||
|
||
import { useLocalesStore } from '../hooks/store' | ||
|
||
export function AllSwitch() { | ||
const { t } = useTranslation() | ||
const all = useLocalesStore((s) => s.all) | ||
return ( | ||
<FormControlLabel | ||
control={ | ||
<Switch | ||
checked={all} | ||
onChange={(_, checked) => useLocalesStore.setState({ all: checked })} | ||
/> | ||
} | ||
label={t('all')} | ||
/> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// @ts-check | ||
import * as React from 'react' | ||
import TextField from '@mui/material/TextField' | ||
import { useTranslation } from 'react-i18next' | ||
|
||
import { useLocalesStore } from '../hooks/store' | ||
|
||
/** @param {{ name: string } & import('@mui/material').TextFieldProps} props */ | ||
export function EditLocale({ name, type, ...props }) { | ||
const { t } = useTranslation() | ||
const value = useLocalesStore((s) => s.custom[name] || '') | ||
/** @type {import('@mui/material').TextFieldProps['onChange']} */ | ||
const onChange = React.useCallback( | ||
(event) => { | ||
useLocalesStore.setState((prev) => ({ | ||
custom: { | ||
...prev.custom, | ||
[name]: | ||
type === 'number' ? +event.target.value || 0 : event.target.value, | ||
}, | ||
})) | ||
}, | ||
[name], | ||
) | ||
return ( | ||
<TextField | ||
fullWidth | ||
type={type} | ||
value={value} | ||
onChange={onChange} | ||
multiline={type === 'text'} | ||
size="small" | ||
placeholder={t('enter_translation')} | ||
{...props} | ||
/> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// @ts-check | ||
import * as React from 'react' | ||
import Grid from '@mui/material/Unstable_Grid2' | ||
import Button from '@mui/material/Button' | ||
import GitHubIcon from '@mui/icons-material/GitHub' | ||
import { useTranslation } from 'react-i18next' | ||
|
||
import { downloadLocales } from '../hooks/store' | ||
import { AllSwitch } from './AllSwitch' | ||
|
||
const github = <GitHubIcon /> | ||
|
||
export function LocalesFooter() { | ||
const { t } = useTranslation() | ||
return ( | ||
<Grid component="footer" container justifyContent="space-evenly" py={1}> | ||
<Grid xs={4} sm={2} className="flex-center"> | ||
<AllSwitch /> | ||
</Grid> | ||
<Grid xs={4} sm={2} className="flex-center"> | ||
<Button onClick={downloadLocales}>{t('download')}</Button> | ||
</Grid> | ||
<Grid xs={4} sm={2} className="flex-center"> | ||
<Button | ||
startIcon={github} | ||
color="secondary" | ||
href="https://github.com/WatWowMap/ReactMap" | ||
target="_blank" | ||
> | ||
{t('contribute')} | ||
</Button> | ||
</Grid> | ||
</Grid> | ||
) | ||
} |
Oops, something went wrong.