-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(mobile): new journal tab, show App tab for journal page (#8738)
close AF-1648
- Loading branch information
Showing
4 changed files
with
168 additions
and
39 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
39 changes: 39 additions & 0 deletions
39
packages/frontend/core/src/mobile/components/app-tabs/journal.tsx
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { useJournalRouteHelper } from '@affine/core/components/hooks/use-journal'; | ||
import { DocDisplayMetaService } from '@affine/core/modules/doc-display-meta'; | ||
import { JournalService } from '@affine/core/modules/journal'; | ||
import { WorkbenchService } from '@affine/core/modules/workbench'; | ||
import { TodayIcon } from '@blocksuite/icons/rc'; | ||
import { useLiveData, useService } from '@toeverything/infra'; | ||
import { useCallback } from 'react'; | ||
|
||
import { tabItem } from './styles.css'; | ||
|
||
export const AppTabJournal = () => { | ||
const workbench = useService(WorkbenchService).workbench; | ||
const location = useLiveData(workbench.location$); | ||
const journalService = useService(JournalService); | ||
const docDisplayMetaService = useService(DocDisplayMetaService); | ||
|
||
const maybeDocId = location.pathname.split('/')[1]; | ||
const journalDate = useLiveData(journalService.journalDate$(maybeDocId)); | ||
const JournalIcon = useLiveData( | ||
docDisplayMetaService.icon$(maybeDocId, { compareDate: new Date() }) | ||
); | ||
|
||
const { openToday } = useJournalRouteHelper(); | ||
const handleOpenToday = useCallback(() => openToday(false), [openToday]); | ||
|
||
const Icon = journalDate ? JournalIcon : TodayIcon; | ||
|
||
return ( | ||
<div | ||
className={tabItem} | ||
onClick={handleOpenToday} | ||
data-active={!!journalDate} | ||
role="tab" | ||
aria-label="Journal" | ||
> | ||
<Icon /> | ||
</div> | ||
); | ||
}; |
9 changes: 7 additions & 2 deletions
9
packages/frontend/core/src/mobile/components/app-tabs/styles.css.ts
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