mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-01-27 19:16:32 +01:00
56 lines
1.1 KiB
React
56 lines
1.1 KiB
React
|
import './index.css';
|
||
|
|
||
|
import './app.css';
|
||
|
|
||
|
import '@github/time-elements';
|
||
|
import { render } from 'preact';
|
||
|
import { useEffect, useState } from 'preact/hooks';
|
||
|
|
||
|
import Compose from './components/compose';
|
||
|
|
||
|
function App() {
|
||
|
const [uiState, setUIState] = useState('default');
|
||
|
|
||
|
const { editStatus, replyToStatus, draftStatus } = window.__COMPOSE__ || {};
|
||
|
|
||
|
useEffect(() => {
|
||
|
if (uiState === 'closed') {
|
||
|
window.close();
|
||
|
}
|
||
|
}, [uiState]);
|
||
|
|
||
|
if (uiState === 'closed') {
|
||
|
return (
|
||
|
<div>
|
||
|
<p>You may close this page now.</p>
|
||
|
<p>
|
||
|
<button
|
||
|
onClick={() => {
|
||
|
window.close();
|
||
|
}}
|
||
|
>
|
||
|
Close window
|
||
|
</button>
|
||
|
</p>
|
||
|
</div>
|
||
|
);
|
||
|
}
|
||
|
|
||
|
return (
|
||
|
<Compose
|
||
|
editStatus={editStatus}
|
||
|
replyToStatus={replyToStatus}
|
||
|
draftStatus={draftStatus}
|
||
|
standalone
|
||
|
onClose={(fn = () => {}) => {
|
||
|
try {
|
||
|
fn();
|
||
|
setUIState('closed');
|
||
|
} catch (e) {}
|
||
|
}}
|
||
|
/>
|
||
|
);
|
||
|
}
|
||
|
|
||
|
render(<App />, document.getElementById('app'));
|