diff --git a/.env b/.env new file mode 100644 index 0000000..0ad5a0d --- /dev/null +++ b/.env @@ -0,0 +1 @@ +VITE_REACT_APP_VERSION=$npm_package_version \ No newline at end of file diff --git a/package.json b/package.json index e3deed3..100fa0c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,8 @@ { - "name": "vite-1", + "name": "pinyindictation", + "author": {"email": "rurik19@yandex.ru", "name": "Yuriy Evdokimov"}, "private": true, - "version": "0.0.0", + "version": "1.0.2", "type": "module", "scripts": { "dev": "vite", diff --git a/src/App.css b/src/App.css index bdf1524..b0fc193 100644 --- a/src/App.css +++ b/src/App.css @@ -59,4 +59,6 @@ .tone2 { color: rgb(255, 170, 0) } .tone3 { color: rgb(85, 170, 0) } .tone4 { color: rgb(0, 0, 255) } -.tone5 { color: rgb(50, 50, 50) } \ No newline at end of file +.tone5 { color: rgb(50, 50, 50) } + +.cpr { color: gray} \ No newline at end of file diff --git a/src/App.tsx b/src/App.tsx index df75f21..789f056 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,14 +1,17 @@ import { useEffect, useState } from 'react' import './App.css' import { Button, ListGroup } from 'react-bootstrap'; -import { initials, finales } from './data'; +import { initials, finales } from './pinyin'; import { BtnColor, Status, Tone } from './types'; import { strings } from './strings'; import { useStateContext } from './store'; import { Params } from './params'; import { ActionType, ToggleType } from './reducer'; import { ButtonSet } from './buttons'; -import { getAudio } from './utils'; +import { RenderTones } from './rendertones'; +import { getAudio } from './audio'; +import { Copyright } from './copyright'; +import { SelectTones } from './selecttones'; function App() { @@ -65,23 +68,7 @@ const playPlayList = () => { playlist[0].play() } -const playTone = (index: string) => { - getAudio(index).play() -} - -const renderPlayList = () => { - - return state.randomTones!.map( - (ton, i) => { return playTone(ton.tone)} - > - {i+1}{'. '}{ton.caption}{' '} - } - ) -} - - return ( +return ( <>

{strings.mainHeader}

@@ -96,6 +83,11 @@ const renderPlayList = () => { + +

{strings.selectTones}

+ +
+

{strings.params}

@@ -129,16 +121,16 @@ const renderPlayList = () => { { status == Status.showlist && <> -
{renderPlayList()}
+
}
+
) } -export default App - +export default App \ No newline at end of file diff --git a/src/Strings.ts b/src/Strings.ts index 70085bb..c7972f1 100644 --- a/src/Strings.ts +++ b/src/Strings.ts @@ -10,5 +10,8 @@ export const strings = { selectInitAndFin: "Выберите инициали и финали", showSyllables: "Показать слоги", playAgain: "Повторить", - toBegin: "В начало" + toBegin: "В начало", + version: "Версия", + cpr: "©", + selectTones: "Выберите тоны" } \ No newline at end of file diff --git a/src/Utils.ts b/src/Utils.ts index 115fe68..17cda21 100644 --- a/src/Utils.ts +++ b/src/Utils.ts @@ -1,4 +1,4 @@ -import { syllables } from "./data" +import { syllables } from "./pinyin" import { BtnColor, SylPart, Syllable } from "./types" export const isEnabled = (arr: SylPart[], find: string): boolean => arr.some((str) => str.index==find) @@ -36,6 +36,3 @@ export const GetSyllablesByInitAndFin = (initiales:SylPart[], finales: SylPart[] } export const Outlined = (color: BtnColor):string => `outline-${color}` -export const getAudioPath = (index: string):string => `/audio/${index}.mp3` - -export const getAudio = (index: string):HTMLAudioElement => new Audio(getAudioPath(index)) \ No newline at end of file diff --git a/src/audio.ts b/src/audio.ts index b1bb227..8ae4365 100644 --- a/src/audio.ts +++ b/src/audio.ts @@ -3,7 +3,14 @@ export const playFile = (filename: string) => { audio.play() } -export const playTone = async (toneName: string) => { - const audio = new Audio(`/src/assets/audio/${toneName}.mp3`) - await audio.play() -} \ No newline at end of file +// export const playTone = async (toneName: string) => { +// const audio = new Audio(`/src/assets/audio/${toneName}.mp3`) +// await audio.play() +// } + +export const playTone = (index: string) => { + getAudio(index).play() + } + +export const getAudioPath = (index: string):string => `/audio/${index}.mp3` +export const getAudio = (index: string):HTMLAudioElement => new Audio(getAudioPath(index)) \ No newline at end of file diff --git a/src/buttons.tsx b/src/buttons.tsx index 187f8ee..7822eb9 100644 --- a/src/buttons.tsx +++ b/src/buttons.tsx @@ -12,8 +12,8 @@ export interface IBtnSerProps { } export const ButtonSet = (props: IBtnSerProps) => { - const { state, dispatch } = useStateContext(); - const { source, color, toggle } = props; + const { state, dispatch } = useStateContext() + const { source, color, toggle } = props return <>