-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Was going to call these 'roles' but that would clash with Dexie cloud's built-in roles table.
- Loading branch information
1 parent
fa39a39
commit ab5d157
Showing
17 changed files
with
901 additions
and
372 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,94 @@ | ||
import { IonPage } from '@ionic/react' | ||
import { | ||
IonContent, | ||
IonFab, | ||
IonFabButton, | ||
IonHeader, | ||
IonIcon, | ||
IonItem, | ||
IonLabel, | ||
IonList, | ||
IonPage, | ||
IonReorder, | ||
IonReorderGroup, | ||
IonSpinner, | ||
IonTitle, | ||
IonToolbar, | ||
} from '@ionic/react' | ||
import { useLiveQuery } from 'dexie-react-hooks' | ||
import { add, starOutline } from 'ionicons/icons' | ||
import { useCallback, useRef } from 'react' | ||
import { db } from '../db' | ||
import { useCreateStarRoleModal } from '../starRoles/create/useCreateStarRoleModal' | ||
|
||
export default function Constellation() { | ||
const starRoles = useLiveQuery(() => db.starRoles.toArray()) | ||
const isLoading = starRoles === undefined | ||
|
||
const fab = useRef<HTMLIonFabElement>(null) | ||
const [presentCreateStarRoleModal, dismiss] = useCreateStarRoleModal() | ||
const openCreateStarRoleModal = useCallback(() => { | ||
presentCreateStarRoleModal({ | ||
onWillDismiss: () => { | ||
if (fab.current) fab.current.activated = false | ||
}, | ||
}) | ||
}, [fab, presentCreateStarRoleModal]) | ||
|
||
return ( | ||
<IonPage> | ||
<h1>Constellation</h1> | ||
<IonHeader> | ||
<IonToolbar> | ||
<IonTitle>Constellation</IonTitle> | ||
</IonToolbar> | ||
</IonHeader> | ||
<IonContent fullscreen> | ||
{isLoading ? ( | ||
<div className="flex items-center justify-center h-full"> | ||
<IonSpinner | ||
className="w-20 h-20" | ||
name="dots" | ||
/> | ||
</div> | ||
) : starRoles.length === 0 ? ( | ||
<div className="flex flex-col items-center justify-center h-full gap-5"> | ||
<IonIcon | ||
icon={starOutline} | ||
size="large" | ||
/> | ||
<p> | ||
Create some roles to focus on what matters in different areas of | ||
your life | ||
</p> | ||
</div> | ||
) : ( | ||
<IonList inset> | ||
<IonReorderGroup | ||
disabled={false} | ||
// onIonItemReorder={handleReorder} | ||
> | ||
{starRoles.map(role => ( | ||
<IonItem | ||
button | ||
key={role.id} | ||
> | ||
<IonLabel>{role?.title}</IonLabel> | ||
<IonReorder slot="end"></IonReorder> | ||
</IonItem> | ||
))} | ||
</IonReorderGroup> | ||
</IonList> | ||
)} | ||
<IonFab | ||
ref={fab} | ||
slot="fixed" | ||
vertical="bottom" | ||
horizontal="end" | ||
> | ||
<IonFabButton onClick={openCreateStarRoleModal}> | ||
<IonIcon icon={add}></IonIcon> | ||
</IonFabButton> | ||
</IonFab> | ||
</IonContent> | ||
</IonPage> | ||
) | ||
} |
Oops, something went wrong.