Skip to content

Add tooltips to the note detail toolbar #599

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Sep 3, 2020
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/components/atoms/TagNavigatorListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import styled from '../../lib/styled'
import { mdiClose } from '@mdi/js'
import { flexCenter } from '../../lib/styled/styleFunctions'
import { useRouter } from '../../lib/router'
import { useTranslation } from 'react-i18next'

const TagItem = styled.li`
margin-right: 5px;
Expand Down Expand Up @@ -65,10 +66,13 @@ const TagNavigatorListItem = ({
currentTagName,
removeTagByName,
}: TagNavigatorListItemProps) => {
const { t } = useTranslation()
const { push } = useRouter()

return (
<TagItem>
<TagItemAnchor
title={`${tag}: ${t('general.allnote')}`}
onClick={() => {
push(`/app/storages/${storageId}/tags/${tag}/${noteId}`)
}}
Expand All @@ -77,6 +81,7 @@ const TagNavigatorListItem = ({
{tag}
</TagItemAnchor>
<TagRemoveButton
title={t('tag.remove')}
onClick={() => {
removeTagByName(tag)
}}
Expand Down
6 changes: 4 additions & 2 deletions src/components/atoms/ToolbarIconButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,18 @@ const ToolbarButtonContainer = styled.button`

interface ToolbarButtonProps {
iconPath: string
active?: boolean
active?: boolean,
title?: string,
onClick: React.MouseEventHandler
}

const ToolbarButton = React.forwardRef(
({ iconPath, onClick, active = false }: ToolbarButtonProps, ref) => (
({ iconPath, onClick, active = false, title }: ToolbarButtonProps, ref) => (
<ToolbarButtonContainer
onClick={onClick}
className={active ? 'active' : ''}
ref={ref}
title={title}
>
<Icon path={iconPath} />
</ToolbarButtonContainer>
Expand Down
10 changes: 10 additions & 0 deletions src/components/molecules/NoteDetailFolderNavigator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { mdiBookOpen, mdiSlashForward } from '@mdi/js'
import Icon from '../atoms/Icon'
import { useRouter, useRouteParams } from '../../lib/router'
import { flexCenter } from '../../lib/styled/styleFunctions'
import { useTranslation } from 'react-i18next'

const Container = styled.div`
display: flex;
Expand Down Expand Up @@ -60,6 +61,8 @@ const NoteDetailFolderNavigator = ({
noteId,
noteFolderPathname,
}: NoteDetailFolderNavigatorProps) => {
const { t } = useTranslation()

const { push } = useRouter()
const routeParams = useRouteParams()

Expand Down Expand Up @@ -87,12 +90,18 @@ const NoteDetailFolderNavigator = ({
return folderDataList
}, [noteFolderPathname])

const storageTooltip = `${t('storage.storage')} ${storageName}: ${t('general.allnote')}`;

const getFolderTooltip = (foldername: string) =>
`${t('folder.folder')} ${foldername}: ${t('general.allnote')}`;

return (
<Container>
<IconContainer>
<Icon path={mdiBookOpen} />
</IconContainer>
<FolderNavItem
title={storageTooltip}
href={`/app/storages/${storageId}/notes/${noteId}`}
onClick={(event: MouseEvent<HTMLAnchorElement>) => {
event.preventDefault()
Expand All @@ -106,6 +115,7 @@ const NoteDetailFolderNavigator = ({
<React.Fragment key={folderData.pathname}>
<Icon path={mdiSlashForward} />
<FolderNavItem
title={getFolderTooltip(folderData.name)}
onClick={() => {
push(
`/app/storages/${storageId}/notes${folderData.pathname}/${noteId}`
Expand Down
6 changes: 5 additions & 1 deletion src/components/molecules/NoteDetailTagNavigator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { useRouteParams } from '../../lib/router'
import ToolbarButton from '../atoms/ToolbarIconButton'
import TagNavigatorListItem from '../atoms/TagNavigatorListItem'
import TagNavigatorNewTagPopup from '../atoms/TagNavigatorNewTagPopup'
import { useTranslation } from 'react-i18next'

const Container = styled.div`
display: flex;
Expand Down Expand Up @@ -48,6 +49,8 @@ const NoteDetailTagNavigator = ({
appendTagByName,
removeTagByName,
}: NoteDetailTagNavigatorProps) => {
const { t } = useTranslation()

const routeParams = useRouteParams()

const currentTagName = useMemo(() => {
Expand Down Expand Up @@ -94,7 +97,7 @@ const NoteDetailTagNavigator = ({
return (
<>
<Container>
<IconContainer>
<IconContainer title={t('tag.tag')}>
<Icon path={mdiTagMultiple} />{' '}
</IconContainer>
<TagNavigatorList>
Expand All @@ -112,6 +115,7 @@ const NoteDetailTagNavigator = ({
})}
</TagNavigatorList>
<ToolbarButton
title={t('tag.add')}
iconPath={mdiPlus}
ref={buttonRef}
onClick={showNewTagPopup}
Expand Down
28 changes: 24 additions & 4 deletions src/components/molecules/NoteDetailToolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
} from '../../lib/exports'
import { usePreferences } from '../../lib/preferences'
import { usePreviewStyle } from '../../lib/preview'
import { useTranslation } from 'react-i18next'

const NoteDetailToolbarContainer = styled.div`
display: flex;
Expand Down Expand Up @@ -68,6 +69,8 @@ const NoteDetailToolbar = ({
bookmarkNote,
unbookmarkNote,
}: NoteDetailToolbarProps) => {
const { t } = useTranslation()

const storageTags = useMemo(() => {
if (storage == null) return []
return values(storage.tagMap).map((tag) => tag.name)
Expand Down Expand Up @@ -135,34 +138,51 @@ const NoteDetailToolbar = ({
<Control>
<ToolbarIconButton
active={viewMode === 'edit'}
title={t('note.edit')}
onClick={selectEditMode}
iconPath={mdiCodeTags}
/>
<ToolbarIconButton
active={viewMode === 'split'}
title={t('note.splitView')}
onClick={selectSplitMode}
iconPath={mdiViewSplitVertical}
/>
<ToolbarIconButton
active={viewMode === 'preview'}
title={t('note.preview')}
onClick={selectPreviewMode}
iconPath={mdiTextSubject}
/>
<ToolbarSeparator />
<ToolbarIconButton
active={!!note.data.bookmarked}
title={t(`bookmark.${!note.data.bookmarked ? 'add' : 'remove'}`)}
onClick={!note.data.bookmarked ? bookmarkNote : unbookmarkNote}
iconPath={note.data.bookmarked ? mdiStar : mdiStarOutline}
/>
{note.trashed ? (
<>
<ToolbarIconButton onClick={untrashNote} iconPath={mdiRestore} />
<ToolbarIconButton onClick={purgeNote} iconPath={mdiTrashCan} />
<ToolbarIconButton
title={t('note.restore')}
onClick={untrashNote}
iconPath={mdiRestore}
/>
<ToolbarIconButton
title={t('note.delete')}
onClick={purgeNote}
iconPath={mdiTrashCan}
/>
</>
) : (
<ToolbarIconButton onClick={trashNote} iconPath={mdiTrashCan} />
)}
<ToolbarIconButton
title={t('note.trash')}
onClick={trashNote}
iconPath={mdiTrashCan}
/>
)}
<ToolbarIconButton
title={t('note.export')}
onClick={openContextMenu}
iconPath={mdiDotsVertical}
/>
Expand Down
8 changes: 8 additions & 0 deletions src/locales/enUS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default {
'general.networkError': 'Network Error',

// Storage
'storage.storage': 'Storage',
'storage.name': 'Storage Name',
'storage.noStorage': 'No storages',
'storage.create': 'Create Storage',
Expand All @@ -34,6 +35,7 @@ export default {
'storage.syncDate': 'Last synced at',

//Folder
'folder.folder': 'Folder',
'folder.create': 'New Folder',
'folder.rename': 'Rename Folder',
'folder.renameMessage':
Expand All @@ -44,6 +46,7 @@ export default {

//Tag
'tag.tag': 'Tags',
'tag.add': 'Add Tag',
'tag.remove': 'Remove Tag',
'tag.removeMessage': 'The tag will be untagged from all notes.',

Expand All @@ -67,6 +70,11 @@ export default {
'note.createkeymessage2': 'Select a storage',
'note.createkeymessage3': 'to create a new note',
'note.restore': 'Restore',
'note.edit': 'Edit',
'note.splitView': 'Split View',
'note.preview': 'Preview',
'note.trash': 'Trash',
'note.export': 'Export',

//Bookmark
'bookmark.remove': 'Remove Bookmark',
Expand Down