pages235/src/react/SelectOption.tsx
Vitaly b199b2e6d8 feat: new singleplayer menu! Now migrated to IndexedDB storage:
- now you can store multiple different worlds and export them for native client at any time
- almost unlimited storage limit
- world auto save now works
- can configure world type
fix: texturepack should be applied when opening folders
feat(world-options): can now save worlds downloaded from url to browser storage (useful for ios, otherwise use folders)
feat: added new export method: directly to folder on the drive (which is faster) - available from main menu
fix: now 'singleplayer' qs opens temporary world which is not saved and 'loadSave' opens save with specific folder name
2023-10-26 04:26:58 +03:00

39 lines
1 KiB
TypeScript

import { proxy, useSnapshot } from 'valtio'
import { hideCurrentModal, showModal } from '../globalState'
import Screen from './Screen'
import { useIsModalActive } from './utils'
import Button from './Button'
const state = proxy({
title: '',
options: [] as string[]
})
let resolve
export const showOptionsModal = async <T extends string>(title: string, options: T[]): Promise<T | undefined> => {
showModal({ reactType: 'general-select' })
return new Promise((_resolve) => {
resolve = _resolve
Object.assign(state, {
title,
options
})
})
}
export default () => {
const { title, options } = useSnapshot(state)
const isModalActive = useIsModalActive('general-select')
if (!isModalActive) return
return <Screen title={title} backdrop>
{options.map(option => <Button key={option} onClick={() => {
hideCurrentModal()
resolve(option)
}}>{option}</Button>)}
<Button style={{ marginTop: 30 }} onClick={() => {
hideCurrentModal()
resolve(undefined)
}}>Cancel</Button>
</Screen>
}