Skip to content

Commit

Permalink
Make splash dialog work the exact way I want it to
Browse files Browse the repository at this point in the history
  • Loading branch information
0xi4o committed Aug 27, 2024
1 parent fc69e13 commit 7adc874
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 94 deletions.
169 changes: 76 additions & 93 deletions app/components/editor/splash-dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,6 @@ const SplashDialog = ({
})
}

useEffect(() => {
localStorage.setItem('aurelius:splash_shown', 'true')
}, [])

// TODO: synced devices is not picking up the correct value initially. it changes after a bit but it should be instant? investigate why.

return (
Expand Down Expand Up @@ -197,45 +193,44 @@ const SplashDialog = ({
className='w-full flex items-center justify-between'
key={post.id}
>
<Link
className='w-full'
to={`${ROUTES.EDITOR.POST}/${post.slug}`}
>
<SplashDialogButton
icon={
<FileTextIcon className='mr-2 w-4 h-4' />
}
label={
<span className='w-full flex items-center justify-between'>
<span
className='w-36 overflow-hidden text-ellipsis text-left'
title={
post.title
}
>
{post.title ||
'Untitled Post'}
</span>
<span
className='text-xs italic'
title={new Date(
<SplashDialogButton
icon={
<FileTextIcon className='mr-2 w-4 h-4' />
}
label={
<span className='w-full flex items-center justify-between'>
<span
className='w-36 overflow-hidden text-ellipsis text-left'
title={post.title}
>
{post.title ||
'Untitled Post'}
</span>
<span
className='text-xs italic'
title={new Date(
post.createdAt
).toDateString()}
>
{formatDistanceToNow(
new Date(
post.createdAt
).toDateString()}
>
{formatDistanceToNow(
new Date(
post.createdAt
),
{
addSuffix:
true,
}
)}
</span>
),
{
addSuffix:
true,
}
)}
</span>
}
/>
</Link>
</span>
}
onClick={() => {
setSplashOpen(false)
navigate(
`${ROUTES.EDITOR.POST}/${post.slug}`
)
}}
/>
</li>
))}
</ul>
Expand All @@ -247,60 +242,48 @@ const SplashDialog = ({
</h3>
<ul className='w-full text-sm flex flex-col gap-2'>
<li className='w-full flex items-center justify-between'>
<Link
className='w-full'
to={ROUTES.VIEW.POSTS}
>
<SplashDialogButton
icon={
<FolderOpenIcon className='mr-2 w-4 h-4' />
}
label='View All Posts'
onClick={() =>
triggerShortcut(
EditorShortcuts.VIEW_ALL_POSTS
)
}
shortcut={getShortcutWithModifiers(
allShortcuts[
EditorShortcuts
.VIEW_ALL_POSTS
].key,
allShortcuts[
EditorShortcuts
.VIEW_ALL_POSTS
].modifiers
)}
/>
</Link>
<SplashDialogButton
icon={
<FolderOpenIcon className='mr-2 w-4 h-4' />
}
label='View All Posts'
onClick={() => {
setSplashOpen(false)
navigate(ROUTES.VIEW.POSTS)
}}
shortcut={getShortcutWithModifiers(
allShortcuts[
EditorShortcuts.VIEW_ALL_POSTS
].key,
allShortcuts[
EditorShortcuts.VIEW_ALL_POSTS
].modifiers
)}
/>
</li>
<li className='w-full flex items-center justify-between'>
<Link
className='w-full'
to={ROUTES.VIEW.WRITING_SESSIONS}
>
<SplashDialogButton
icon={
<AlarmClockCheckIcon className='mr-2 w-4 h-4' />
}
label='View All Writing Sessions'
onClick={() =>
triggerShortcut(
EditorShortcuts.VIEW_ALL_WRITING_SESSIONS
)
}
shortcut={getShortcutWithModifiers(
allShortcuts[
EditorShortcuts
.VIEW_ALL_WRITING_SESSIONS
].key,
allShortcuts[
EditorShortcuts
.VIEW_ALL_WRITING_SESSIONS
].modifiers
)}
/>
</Link>
<SplashDialogButton
icon={
<AlarmClockCheckIcon className='mr-2 w-4 h-4' />
}
label='View All Writing Sessions'
onClick={() => {
setSplashOpen(false)
navigate(
ROUTES.VIEW.WRITING_SESSIONS
)
}}
shortcut={getShortcutWithModifiers(
allShortcuts[
EditorShortcuts
.VIEW_ALL_WRITING_SESSIONS
].key,
allShortcuts[
EditorShortcuts
.VIEW_ALL_WRITING_SESSIONS
].modifiers
)}
/>
</li>
</ul>
</div>
Expand Down
1 change: 0 additions & 1 deletion app/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ const App = ({ children }: { children: ReactNode }) => {

return () => {
document.head.removeChild(script)
localStorage.removeItem('aurelius:splash_shown')
}
}, [])

Expand Down

0 comments on commit 7adc874

Please sign in to comment.