-
-
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.
- Loading branch information
1 parent
6a9eec6
commit bfbd15a
Showing
18 changed files
with
417 additions
and
21 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
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
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 VirtuosoTableComponents = { | ||
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={VirtuosoTableComponents} {...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,34 @@ | ||
// @ts-check | ||
import * as React from 'react' | ||
import TextField from '@mui/material/TextField' | ||
import { useLocalesStore } from '../hooks/store' | ||
|
||
/** @param {{ name: string } & import('@mui/material').TextFieldProps} props */ | ||
export function EditLocale({ name, type, ...props }) { | ||
const value = useLocalesStore((s) => s.custom[name] || '') | ||
const isScrolling = useLocalesStore((s) => s.isScrolling) | ||
/** @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' && !isScrolling} | ||
size="small" | ||
{...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> | ||
) | ||
} |
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,51 @@ | ||
// @ts-check | ||
import * as React from 'react' | ||
import Grid from '@mui/material/Unstable_Grid2' | ||
import Typography from '@mui/material/Typography' | ||
import Collapse from '@mui/material/Collapse' | ||
import Button from '@mui/material/Button' | ||
import ExpandMoreIcon from '@mui/icons-material/ExpandMore' | ||
import { useTranslation } from 'react-i18next' | ||
|
||
import { LocaleSelection } from '@components/inputs/LocaleSelection' | ||
|
||
import { useLocalesStore } from '../hooks/store' | ||
|
||
const expandMore = <ExpandMoreIcon /> | ||
|
||
export function LocalesHeader() { | ||
const { t, i18n } = useTranslation() | ||
const instructions = useLocalesStore((s) => s.instructions) | ||
return ( | ||
<Grid component="header" container className="flex-center" p={2}> | ||
<Grid xs={6} sm={4}> | ||
<Typography variant="h4">{t('locales')}</Typography> | ||
</Grid> | ||
<Grid xs={6} sm={4}> | ||
<LocaleSelection /> | ||
</Grid> | ||
<Grid xs={12} sm={4} textAlign="right"> | ||
<Button | ||
color="secondary" | ||
onClick={() => | ||
useLocalesStore.setState((prev) => ({ | ||
instructions: !prev.instructions, | ||
})) | ||
} | ||
endIcon={expandMore} | ||
> | ||
{t('instructions')} | ||
</Button> | ||
</Grid> | ||
<Grid component={Collapse} in={instructions} xs={12} sm={8}> | ||
<ol> | ||
{[1, 2, 3, 4, 5, 6, 7, 8].map((i) => ( | ||
<Typography key={i} component="li"> | ||
{t(`locale_instructions_${i}`, { lng: i18n.language })} | ||
</Typography> | ||
))} | ||
</ol> | ||
</Grid> | ||
</Grid> | ||
) | ||
} |
Oops, something went wrong.