-
-
Notifications
You must be signed in to change notification settings - Fork 5
Stephen #238
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Stephen #238
Changes from 25 commits
89feff7
8b05aaf
2c681e6
2da0f4e
dd80b2e
d7ab968
ab9048f
c0227ce
dc9ce36
4e59a03
2f65942
9d30e34
014b8b5
a0b4378
2f6fbd3
5cb1ea7
c1acc00
8ab6e92
a502517
34719bf
f0171e6
4520190
78a65c0
4e21557
cf7889f
01bfd8f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -55,7 +55,10 @@ export const usePlayerLogic = (props: PlayerLogicProps) => { | |||||||||||||||||
| const loadSegments = () => { | ||||||||||||||||||
| const segs = mediafileRef.current?.attributes?.segments || '{}'; | ||||||||||||||||||
| if (allowSegment) { | ||||||||||||||||||
| segmentsRef.current = getSegments(allowSegment, segs); | ||||||||||||||||||
| segmentsRef.current = | ||||||||||||||||||
| suggestedSegments && suggestedSegments.length > 0 | ||||||||||||||||||
| ? suggestedSegments | ||||||||||||||||||
| : getSegments(allowSegment, segs); | ||||||||||||||||||
|
Comment on lines
+58
to
+61
|
||||||||||||||||||
| segmentsRef.current = | |
| suggestedSegments && suggestedSegments.length > 0 | |
| ? suggestedSegments | |
| : getSegments(allowSegment, segs); | |
| // On mediafile change, always load segments from the mediafile itself. | |
| // Any suggestedSegments override is applied separately in the effect | |
| // that watches [allowSegment, suggestedSegments]. | |
| segmentsRef.current = getSegments(allowSegment, segs); |
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -0,0 +1,262 @@ | ||||
| import { | ||||
| Box, | ||||
| Button, | ||||
| Checkbox, | ||||
| Dialog, | ||||
| DialogActions, | ||||
| DialogContent, | ||||
| DialogTitle, | ||||
| FormControlLabel, | ||||
| NativeSelect, | ||||
| Typography, | ||||
| } from '@mui/material'; | ||||
| import type { ChangeEvent } from 'react'; | ||||
| import { useEffect, useState } from 'react'; | ||||
|
|
||||
| const suffixOptions = ['', 'a', 'b', 'c', 'd', 'e']; | ||||
| const selectSx = { | ||||
| minWidth: 64, | ||||
| '& .MuiNativeSelect-select': { | ||||
| fontSize: 40, | ||||
| lineHeight: 1.1, | ||||
| textAlign: 'center', | ||||
| pr: 3, | ||||
| }, | ||||
| '& .MuiNativeSelect-icon': { | ||||
| fontSize: 24, | ||||
| right: 0, | ||||
| }, | ||||
| }; | ||||
| const verseSelectSx = { | ||||
| ...selectSx, | ||||
| '& .MuiNativeSelect-select': { | ||||
| ...selectSx['& .MuiNativeSelect-select'], | ||||
| fontSize: 28, | ||||
| }, | ||||
| }; | ||||
| const suffixOptionStyle = { | ||||
| fontSize: 50, | ||||
| }; | ||||
| const verseOptionStyle = { | ||||
| fontSize: 48, | ||||
| }; | ||||
|
|
||||
| export interface EditReferenceValue { | ||||
| splitVerse: boolean; | ||||
| canSplit: boolean; | ||||
| startChapter: number; | ||||
| startVerse: number; | ||||
| startSuffix: string; | ||||
| endChapter: number; | ||||
| endVerse: number; | ||||
| endSuffix: string; | ||||
| } | ||||
|
|
||||
| interface EditReferenceDropdownProps { | ||||
| open: boolean; | ||||
| limits: string; | ||||
| maxVerse: number; | ||||
| verseOptions: number[]; | ||||
| title: string; | ||||
| cancelLabel: string; | ||||
| saveLabel: string; | ||||
| splitVerseLabel: string; | ||||
| value: EditReferenceValue; | ||||
| onCancel: () => void; | ||||
| onSave: (value: EditReferenceValue) => void; | ||||
| } | ||||
|
|
||||
| export default function EditReferenceDropdown({ | ||||
| open, | ||||
| limits, | ||||
| maxVerse, | ||||
| verseOptions, | ||||
| title, | ||||
| cancelLabel, | ||||
| saveLabel, | ||||
| splitVerseLabel, | ||||
| value, | ||||
| onCancel, | ||||
| onSave, | ||||
| }: EditReferenceDropdownProps) { | ||||
| const [draft, setDraft] = useState<EditReferenceValue>(value); | ||||
| const verseNumberOptions = Array.from( | ||||
| new Set([...verseOptions, draft.startVerse, draft.endVerse, maxVerse]) | ||||
| ).sort((left, right) => left - right); | ||||
|
|
||||
| useEffect(() => { | ||||
| setDraft(value); | ||||
| }, [value]); | ||||
|
|
||||
| const handleSplitChange = ( | ||||
| event: ChangeEvent<HTMLInputElement>, | ||||
| checked: boolean | ||||
| ) => { | ||||
| setDraft((current) => ({ | ||||
| ...current, | ||||
| splitVerse: checked, | ||||
| })); | ||||
| }; | ||||
|
|
||||
| const handleSuffixChange = | ||||
| (key: 'startSuffix' | 'endSuffix') => | ||||
| (event: ChangeEvent<HTMLSelectElement>) => { | ||||
| const nextSuffix = event.target.value.toLowerCase(); | ||||
| setDraft((current) => ({ | ||||
| ...current, | ||||
| [key]: nextSuffix, | ||||
| })); | ||||
| }; | ||||
|
|
||||
| const handleVerseChange = | ||||
| (key: 'startVerse' | 'endVerse') => | ||||
| (event: ChangeEvent<HTMLSelectElement>) => { | ||||
| const nextVerse = parseInt(event.target.value, 10); | ||||
| if (Number.isNaN(nextVerse)) return; | ||||
|
|
||||
| setDraft((current) => ({ | ||||
| ...current, | ||||
| [key]: nextVerse, | ||||
| })); | ||||
| }; | ||||
|
|
||||
| const displayEndChapter = draft.endChapter; | ||||
| const displayEndVerse = draft.endVerse; | ||||
| const canEditEndSuffix = draft.canSplit || draft.splitVerse; | ||||
|
|
||||
| return ( | ||||
| <Dialog | ||||
| open={open} | ||||
| onClose={onCancel} | ||||
| aria-labelledby="edit-reference-dialog-title" | ||||
| fullWidth | ||||
| maxWidth="xs" | ||||
| > | ||||
| <DialogTitle id="edit-reference-dialog-title"> | ||||
| {`${title} ${limits}`} | ||||
| </DialogTitle> | ||||
| <DialogContent sx={{ pt: 1 }}> | ||||
| <Box | ||||
| sx={{ | ||||
| display: 'flex', | ||||
| justifyContent: 'center', | ||||
| alignItems: 'center', | ||||
| gap: 1.5, | ||||
| mb: 2, | ||||
| fontVariantNumeric: 'tabular-nums', | ||||
| }} | ||||
| > | ||||
| <Box sx={{ textAlign: 'center' }}> | ||||
| <Box | ||||
| sx={{ | ||||
| display: 'flex', | ||||
| alignItems: 'center', | ||||
| justifyContent: 'center', | ||||
| gap: 0.5, | ||||
| }} | ||||
| > | ||||
| <Typography | ||||
| sx={{ fontSize: 28 }} | ||||
| >{`${draft.startChapter}:`}</Typography> | ||||
| <NativeSelect | ||||
| value={draft.startVerse} | ||||
| onChange={handleVerseChange('startVerse')} | ||||
| inputProps={{ 'aria-label': 'start verse number' }} | ||||
| sx={verseSelectSx} | ||||
| > | ||||
| {verseNumberOptions.map((option) => ( | ||||
| <option | ||||
| key={`start-verse-${option}`} | ||||
| value={option} | ||||
| style={verseOptionStyle} | ||||
| > | ||||
| {option} | ||||
| </option> | ||||
| ))} | ||||
| </NativeSelect> | ||||
| </Box> | ||||
| <NativeSelect | ||||
| value={draft.startSuffix} | ||||
| onChange={handleSuffixChange('startSuffix')} | ||||
| inputProps={{ 'aria-label': 'start verse suffix' }} | ||||
| sx={selectSx} | ||||
| > | ||||
| {suffixOptions.map((option) => ( | ||||
| <option | ||||
| key={option || 'none-start'} | ||||
| value={option} | ||||
| style={suffixOptionStyle} | ||||
| > | ||||
| {option || ' '} | ||||
| </option> | ||||
| ))} | ||||
| </NativeSelect> | ||||
| </Box> | ||||
| <Typography variant="h6">-</Typography> | ||||
| <Box sx={{ textAlign: 'center' }}> | ||||
| <Box | ||||
| sx={{ | ||||
| display: 'flex', | ||||
| alignItems: 'center', | ||||
| justifyContent: 'center', | ||||
| gap: 0.5, | ||||
| }} | ||||
| > | ||||
| <Typography | ||||
| sx={{ fontSize: 24 }} | ||||
| >{`${displayEndChapter}:`}</Typography> | ||||
| <NativeSelect | ||||
| value={displayEndVerse} | ||||
| onChange={handleVerseChange('endVerse')} | ||||
| disabled={!draft.splitVerse} | ||||
| inputProps={{ 'aria-label': 'end verse number' }} | ||||
| sx={verseSelectSx} | ||||
| > | ||||
| {verseNumberOptions.map((option) => ( | ||||
| <option | ||||
| key={`end-verse-${option}`} | ||||
| value={option} | ||||
| style={verseOptionStyle} | ||||
| > | ||||
| {option} | ||||
| </option> | ||||
| ))} | ||||
| </NativeSelect> | ||||
| </Box> | ||||
| <NativeSelect | ||||
| value={draft.endSuffix} | ||||
| onChange={handleSuffixChange('endSuffix')} | ||||
| disabled={!canEditEndSuffix} | ||||
| inputProps={{ 'aria-label': 'end verse suffix' }} | ||||
| sx={selectSx} | ||||
| > | ||||
| {suffixOptions.map((option) => ( | ||||
| <option | ||||
| key={option || 'none-end'} | ||||
| value={option} | ||||
| style={suffixOptionStyle} | ||||
| > | ||||
| {option || ' '} | ||||
| </option> | ||||
| ))} | ||||
| </NativeSelect> | ||||
| </Box> | ||||
| </Box> | ||||
|
|
||||
| <FormControlLabel | ||||
| control={ | ||||
| <Checkbox checked={draft.splitVerse} onChange={handleSplitChange} /> | ||||
| } | ||||
| label={splitVerseLabel} | ||||
| /> | ||||
| </DialogContent> | ||||
| <DialogActions sx={{ px: 3, pb: 2 }}> | ||||
| <Button onClick={onCancel}>{cancelLabel}</Button> | ||||
| <Button variant="contained" onClick={() => onSave(draft)}> | ||||
| {saveLabel} | ||||
| </Button> | ||||
| </DialogActions> | ||||
| </Dialog> | ||||
| ); | ||||
| } | ||||
| // test | ||||
|
||||
| // test |
Uh oh!
There was an error while loading. Please reload this page.