mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
add support for "n" and "p" keyboard shortcuts
This commit is contained in:
@@ -29,6 +29,22 @@ export function KeyboardShortcutsHelp() {
|
|||||||
<Kbd>K</Kbd>
|
<Kbd>K</Kbd>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<Trans>Set focus on next entry without opening it</Trans>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<Kbd>N</Kbd>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<Trans>Set focus on previous entry without opening it</Trans>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<Kbd>P</Kbd>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<Trans>Move the page down</Trans>
|
<Trans>Move the page down</Trans>
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ export function FeedEntries() {
|
|||||||
// scroll to entry when selected entry changes
|
// scroll to entry when selected entry changes
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!selectedEntryId) return
|
if (!selectedEntryId) return
|
||||||
|
if (!selectedEntry?.expanded) return
|
||||||
|
|
||||||
const selectedEntryElement = refs.current[selectedEntryId]
|
const selectedEntryElement = refs.current[selectedEntryId]
|
||||||
if (Constants.layout.isTopVisible(selectedEntryElement) && Constants.layout.isBottomVisible(selectedEntryElement)) return
|
if (Constants.layout.isTopVisible(selectedEntryElement) && Constants.layout.isBottomVisible(selectedEntryElement)) return
|
||||||
@@ -73,7 +74,7 @@ export function FeedEntries() {
|
|||||||
top: selectedEntryElement.offsetTop - 3,
|
top: selectedEntryElement.offsetTop - 3,
|
||||||
behavior: scrollSpeed && scrollSpeed > 0 ? "smooth" : "auto",
|
behavior: scrollSpeed && scrollSpeed > 0 ? "smooth" : "auto",
|
||||||
})
|
})
|
||||||
}, [selectedEntryId, scrollSpeed])
|
}, [selectedEntryId, selectedEntry?.expanded, scrollSpeed])
|
||||||
|
|
||||||
useMousetrap("r", () => {
|
useMousetrap("r", () => {
|
||||||
dispatch(reloadEntries())
|
dispatch(reloadEntries())
|
||||||
@@ -86,6 +87,14 @@ export function FeedEntries() {
|
|||||||
})
|
})
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
useMousetrap("n", () => {
|
||||||
|
dispatch(
|
||||||
|
selectNextEntry({
|
||||||
|
expand: false,
|
||||||
|
markAsRead: false,
|
||||||
|
})
|
||||||
|
)
|
||||||
|
})
|
||||||
useMousetrap("k", () => {
|
useMousetrap("k", () => {
|
||||||
dispatch(
|
dispatch(
|
||||||
selectPreviousEntry({
|
selectPreviousEntry({
|
||||||
@@ -94,6 +103,14 @@ export function FeedEntries() {
|
|||||||
})
|
})
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
useMousetrap("p", () => {
|
||||||
|
dispatch(
|
||||||
|
selectPreviousEntry({
|
||||||
|
expand: false,
|
||||||
|
markAsRead: false,
|
||||||
|
})
|
||||||
|
)
|
||||||
|
})
|
||||||
useMousetrap("space", () => {
|
useMousetrap("space", () => {
|
||||||
if (selectedEntry) {
|
if (selectedEntry) {
|
||||||
if (selectedEntry.expanded) {
|
if (selectedEntry.expanded) {
|
||||||
@@ -232,6 +249,7 @@ export function FeedEntries() {
|
|||||||
<FeedEntry
|
<FeedEntry
|
||||||
entry={entry}
|
entry={entry}
|
||||||
expanded={!!entry.expanded || viewMode === "expanded"}
|
expanded={!!entry.expanded || viewMode === "expanded"}
|
||||||
|
showSelectionIndicator={entry.id === selectedEntryId && (!entry.expanded || viewMode === "expanded")}
|
||||||
onHeaderClick={event => headerClicked(entry, event)}
|
onHeaderClick={event => headerClicked(entry, event)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import { FeedEntryHeader } from "./FeedEntryHeader"
|
|||||||
interface FeedEntryProps {
|
interface FeedEntryProps {
|
||||||
entry: Entry
|
entry: Entry
|
||||||
expanded: boolean
|
expanded: boolean
|
||||||
|
showSelectionIndicator: boolean
|
||||||
onHeaderClick: (e: React.MouseEvent) => void
|
onHeaderClick: (e: React.MouseEvent) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -19,7 +20,7 @@ const useStyles = createStyles((theme, props: FeedEntryProps) => {
|
|||||||
if (theme.colorScheme === "dark") backgroundColor = props.entry.read ? "inherit" : theme.colors.dark[5]
|
if (theme.colorScheme === "dark") backgroundColor = props.entry.read ? "inherit" : theme.colors.dark[5]
|
||||||
else backgroundColor = props.entry.read && !props.expanded ? theme.colors.gray[0] : "inherit"
|
else backgroundColor = props.entry.read && !props.expanded ? theme.colors.gray[0] : "inherit"
|
||||||
|
|
||||||
return {
|
const styles = {
|
||||||
paper: {
|
paper: {
|
||||||
backgroundColor,
|
backgroundColor,
|
||||||
marginTop: theme.spacing.xs,
|
marginTop: theme.spacing.xs,
|
||||||
@@ -33,6 +34,12 @@ const useStyles = createStyles((theme, props: FeedEntryProps) => {
|
|||||||
maxWidth: Constants.layout.entryMaxWidth,
|
maxWidth: Constants.layout.entryMaxWidth,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (props.showSelectionIndicator) {
|
||||||
|
styles.paper.borderLeftColor = theme.colors.orange[4]
|
||||||
|
}
|
||||||
|
|
||||||
|
return styles
|
||||||
})
|
})
|
||||||
|
|
||||||
export function FeedEntry(props: FeedEntryProps) {
|
export function FeedEntry(props: FeedEntryProps) {
|
||||||
|
|||||||
@@ -573,6 +573,14 @@ msgstr "Scroll smoothly when navigating between entries"
|
|||||||
msgid "Search"
|
msgid "Search"
|
||||||
msgstr "Search"
|
msgstr "Search"
|
||||||
|
|
||||||
|
#: src/components/KeyboardShortcutsHelp.tsx
|
||||||
|
msgid "Set focus on next entry without opening it"
|
||||||
|
msgstr "Set focus on next entry without opening it"
|
||||||
|
|
||||||
|
#: src/components/KeyboardShortcutsHelp.tsx
|
||||||
|
msgid "Set focus on previous entry without opening it"
|
||||||
|
msgstr "Set focus on previous entry without opening it"
|
||||||
|
|
||||||
#: src/components/header/ProfileMenu.tsx
|
#: src/components/header/ProfileMenu.tsx
|
||||||
msgid "Settings"
|
msgid "Settings"
|
||||||
msgstr "Settings"
|
msgstr "Settings"
|
||||||
|
|||||||
@@ -573,6 +573,14 @@ msgstr "Défilement animé lors de la navigation entre les entrées"
|
|||||||
msgid "Search"
|
msgid "Search"
|
||||||
msgstr "Rechercher"
|
msgstr "Rechercher"
|
||||||
|
|
||||||
|
#: src/components/KeyboardShortcutsHelp.tsx
|
||||||
|
msgid "Set focus on next entry without opening it"
|
||||||
|
msgstr "Sélectionner l'article suivant sans l'ouvrir"
|
||||||
|
|
||||||
|
#: src/components/KeyboardShortcutsHelp.tsx
|
||||||
|
msgid "Set focus on previous entry without opening it"
|
||||||
|
msgstr "Sélectionner l'article précédent sans l'ouvrir"
|
||||||
|
|
||||||
#: src/components/header/ProfileMenu.tsx
|
#: src/components/header/ProfileMenu.tsx
|
||||||
msgid "Settings"
|
msgid "Settings"
|
||||||
msgstr "Réglages"
|
msgstr "Réglages"
|
||||||
|
|||||||
Reference in New Issue
Block a user