-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
5 changed files
with
156 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
export const CONSONANTS = [ | ||
'p', | ||
'b', | ||
't', | ||
'd', | ||
'k', | ||
'g', | ||
'f', | ||
'v', | ||
'θ', | ||
'ð', | ||
's', | ||
'z', | ||
'ʃ', | ||
'ʒ', | ||
'h', | ||
'ʧ', | ||
'ʤ', | ||
'm', | ||
'n', | ||
'ŋ', | ||
'w', | ||
'r', | ||
'l', | ||
'j', | ||
]; | ||
|
||
export const VOWELS = [ | ||
'ɪ', | ||
'e', | ||
'æ', | ||
'ɒ', | ||
'ʊ', | ||
'ʌ', | ||
'iː', | ||
'ɑː', | ||
'ɔː', | ||
'uː', | ||
'ɜː', | ||
'eɪ', | ||
'aɪ', | ||
'ɔɪ', | ||
'əʊ', | ||
'aʊ', | ||
'ɪə', | ||
'eə', | ||
'ʊə', | ||
'ə', | ||
'i', | ||
'u', | ||
]; |
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 @@ | ||
import { Chip, Stack, Grid2 as Grid, Accordion, AccordionSummary, AccordionDetails, Typography } from '@mui/material'; | ||
import { CONSONANTS, VOWELS } from './constants'; | ||
import ExpandMoreIcon from '@mui/icons-material/ExpandMore'; | ||
import KeyboardRoundedIcon from '@mui/icons-material/KeyboardRounded'; | ||
|
||
const TRANSCRIPTION_LIST = [...CONSONANTS, ...VOWELS]; | ||
|
||
interface Props { | ||
onClick: (value: string) => void; | ||
} | ||
|
||
export const TranscriptionKeyboard = ({ onClick }: Props) => { | ||
return ( | ||
<Accordion> | ||
<AccordionSummary expandIcon={<ExpandMoreIcon />}> | ||
<Stack direction="row" spacing={1}> | ||
<KeyboardRoundedIcon /> | ||
<div>Клавиатура транскрипции</div> | ||
</Stack> | ||
</AccordionSummary> | ||
<AccordionDetails> | ||
<Grid container spacing={0.5}> | ||
{TRANSCRIPTION_LIST.map((value, i) => ( | ||
<Grid key={i}> | ||
<Chip | ||
variant="outlined" | ||
color={VOWELS.includes(value) ? 'error' : 'info'} | ||
label={<Typography variant="h6">{value}</Typography>} | ||
onClick={() => onClick(value)} | ||
/> | ||
</Grid> | ||
))} | ||
</Grid> | ||
</AccordionDetails> | ||
</Accordion> | ||
); | ||
}; |
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,24 @@ | ||
import { useEffect, useState } from 'react'; | ||
|
||
export const useInputCursorPosition = () => { | ||
const [position, setPosition] = useState(0); | ||
const [inputRef, setInputRef] = useState<HTMLInputElement | null>(null); | ||
|
||
useEffect(() => { | ||
if (!inputRef) { | ||
return; | ||
} | ||
|
||
const handle = () => { | ||
setPosition(inputRef.selectionStart ?? 0); | ||
}; | ||
|
||
inputRef.addEventListener('focusout', handle); | ||
|
||
return () => { | ||
inputRef.removeEventListener('focusout', handle); | ||
}; | ||
}, [inputRef]); | ||
|
||
return { position, setInputRef }; | ||
}; |