export modal
This commit is contained in:
parent
bd271021f1
commit
c036d7d5ca
@ -2,25 +2,40 @@ import React, { useState } from "react"
|
|||||||
import RetakesConfig from "../types/RetakesConfig"
|
import RetakesConfig from "../types/RetakesConfig"
|
||||||
import AllDecks from "./AllDecks"
|
import AllDecks from "./AllDecks"
|
||||||
import MenuBar from "./MenuBar"
|
import MenuBar from "./MenuBar"
|
||||||
|
import Modal from "./Modal"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const App: React.FC = () => {
|
const App: React.FC = () => {
|
||||||
const [retakesConfig,setRetakesConfig] = useState(new RetakesConfig())
|
const [retakesConfig,setRetakesConfig] = useState(new RetakesConfig())
|
||||||
|
const [showExport,setShowExport] = useState(false)
|
||||||
|
const [exportText,setExportText] = useState("")
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="text-white">
|
<div className="text-white">
|
||||||
<MenuBar
|
<MenuBar
|
||||||
onExport={()=>{
|
onExport={()=>{
|
||||||
const exportString = retakesConfig.toCvar()
|
setExportText(retakesConfig.toCvar())
|
||||||
console.log(exportString)
|
setShowExport(true)
|
||||||
}}
|
}}
|
||||||
onExportJson={()=>{
|
onExportJson={()=>{
|
||||||
const jsonString = JSON.stringify(retakesConfig)
|
setExportText(JSON.stringify(retakesConfig))
|
||||||
console.log(jsonString)
|
setShowExport(true)
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<AllDecks retakesConfig={retakesConfig} onChange={(newConfig)=>setRetakesConfig(newConfig)} />
|
<AllDecks retakesConfig={retakesConfig} onChange={(newConfig)=>setRetakesConfig(newConfig)} />
|
||||||
|
|
||||||
|
<Modal show={showExport} onCloseClick={()=>setShowExport(false)}>
|
||||||
|
<div className="flex justify-center mb-2">
|
||||||
|
<textarea
|
||||||
|
cols={50} rows={10}
|
||||||
|
value={exportText}
|
||||||
|
readOnly
|
||||||
|
className="text-black bg-transparent border-2 border-gray-900"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="bg-gray-700 button flex justify-center" >Copy to clipboard</div>
|
||||||
|
</Modal>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
26
src/components/Modal.tsx
Normal file
26
src/components/Modal.tsx
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
import React from "react"
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
show: boolean
|
||||||
|
onCloseClick?: ()=>void
|
||||||
|
}
|
||||||
|
|
||||||
|
const Modal: React.FC<Props> = ({children,show,onCloseClick}) => {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className={`${!show?"hidden":"" }
|
||||||
|
fixed z-10 left-0 top-0 w-full h-full
|
||||||
|
flex justify-center items-center bg-gray-900 bg-opacity-80`}
|
||||||
|
onClick={()=>{
|
||||||
|
onCloseClick?.()
|
||||||
|
}}>
|
||||||
|
<div className="bg-gray-800 mx-auto p-5 border-2 border-gray-800 w-10/12 overflow-hidden max-h-full" onClick={(e)=>{
|
||||||
|
e.stopPropagation()
|
||||||
|
}}>
|
||||||
|
{children}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Modal
|
Loading…
Reference in New Issue
Block a user