mirror of
https://github.com/Athou/commafeed.git
synced 2026-09-24 21:15:13 +00:00
nowrap on parent is actually enough
This commit is contained in:
@@ -2,8 +2,7 @@ import { msg } from "@lingui/core/macro"
|
|||||||
import { useLingui } from "@lingui/react"
|
import { useLingui } from "@lingui/react"
|
||||||
import { Box, Center, CloseButton, Divider, Group, Indicator, Popover, TextInput } from "@mantine/core"
|
import { Box, Center, CloseButton, Divider, Group, Indicator, Popover, TextInput } from "@mantine/core"
|
||||||
import { useForm } from "@mantine/form"
|
import { useForm } from "@mantine/form"
|
||||||
import { useElementSize, useViewportSize } from "@mantine/hooks"
|
import { type ReactNode, useEffect } from "react"
|
||||||
import { type ReactNode, type RefCallback, useEffect } from "react"
|
|
||||||
import {
|
import {
|
||||||
TbArrowDown,
|
TbArrowDown,
|
||||||
TbArrowUp,
|
TbArrowUp,
|
||||||
@@ -21,7 +20,7 @@ import {
|
|||||||
import { markAllAsReadWithConfirmationIfRequired, reloadEntries, search, selectNextEntry, selectPreviousEntry } from "@/app/entries/thunks"
|
import { markAllAsReadWithConfirmationIfRequired, reloadEntries, search, selectNextEntry, selectPreviousEntry } from "@/app/entries/thunks"
|
||||||
import { useAppDispatch, useAppSelector } from "@/app/store"
|
import { useAppDispatch, useAppSelector } from "@/app/store"
|
||||||
import { changeSettings } from "@/app/user/thunks"
|
import { changeSettings } from "@/app/user/thunks"
|
||||||
import { ActionButton, type Mode } from "@/components/ActionButton"
|
import { ActionButton } from "@/components/ActionButton"
|
||||||
import { Loader } from "@/components/Loader"
|
import { Loader } from "@/components/Loader"
|
||||||
import { useActionButton } from "@/hooks/useActionButton"
|
import { useActionButton } from "@/hooks/useActionButton"
|
||||||
import { useBrowserExtension } from "@/hooks/useBrowserExtension"
|
import { useBrowserExtension } from "@/hooks/useBrowserExtension"
|
||||||
@@ -32,7 +31,7 @@ function HeaderDivider() {
|
|||||||
return <Divider orientation="vertical" />
|
return <Divider orientation="vertical" />
|
||||||
}
|
}
|
||||||
|
|
||||||
function HeaderToolbar(props: { children: ReactNode; ref?: RefCallback<typeof HeaderToolbar> }) {
|
function HeaderToolbar(props: { children: ReactNode }) {
|
||||||
const { spacing } = useActionButton()
|
const { spacing } = useActionButton()
|
||||||
const mobile = useMobile("480px")
|
const mobile = useMobile("480px")
|
||||||
return mobile ? (
|
return mobile ? (
|
||||||
@@ -62,13 +61,6 @@ export function Header() {
|
|||||||
const searchFromStore = useAppSelector(state => state.entries.search)
|
const searchFromStore = useAppSelector(state => state.entries.search)
|
||||||
const { isBrowserExtensionPopup, openSettingsPage, openAppInNewTab } = useBrowserExtension()
|
const { isBrowserExtensionPopup, openSettingsPage, openAppInNewTab } = useBrowserExtension()
|
||||||
const dispatch = useAppDispatch()
|
const dispatch = useAppDispatch()
|
||||||
|
|
||||||
const viewport = useViewportSize()
|
|
||||||
const { ref: headerRef, width: headerWidth } = useElementSize()
|
|
||||||
const sidebarWidth = useAppSelector(state => state.user.localSettings.sidebarWidth)
|
|
||||||
const headerTooLarge = headerWidth > viewport.width - sidebarWidth
|
|
||||||
const mode: Mode = headerTooLarge ? "mobile" : "auto"
|
|
||||||
|
|
||||||
const { _ } = useLingui()
|
const { _ } = useLingui()
|
||||||
|
|
||||||
const searchForm = useForm<{ search: string }>()
|
const searchForm = useForm<{ search: string }>()
|
||||||
@@ -102,11 +94,10 @@ export function Header() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Center className="cf-toolbar-wrapper">
|
<Center className="cf-toolbar-wrapper">
|
||||||
<HeaderToolbar ref={headerRef}>
|
<HeaderToolbar>
|
||||||
<ActionButton
|
<ActionButton
|
||||||
icon={<TbArrowUp size={iconSize} />}
|
icon={<TbArrowUp size={iconSize} />}
|
||||||
label={msg`Previous`}
|
label={msg`Previous`}
|
||||||
mode={mode}
|
|
||||||
onClick={async () =>
|
onClick={async () =>
|
||||||
await dispatch(
|
await dispatch(
|
||||||
selectPreviousEntry({
|
selectPreviousEntry({
|
||||||
@@ -120,7 +111,6 @@ export function Header() {
|
|||||||
<ActionButton
|
<ActionButton
|
||||||
icon={<TbArrowDown size={iconSize} />}
|
icon={<TbArrowDown size={iconSize} />}
|
||||||
label={msg`Next`}
|
label={msg`Next`}
|
||||||
mode={mode}
|
|
||||||
onClick={async () =>
|
onClick={async () =>
|
||||||
await dispatch(
|
await dispatch(
|
||||||
selectNextEntry({
|
selectNextEntry({
|
||||||
@@ -137,13 +127,11 @@ export function Header() {
|
|||||||
<ActionButton
|
<ActionButton
|
||||||
icon={<TbRefresh size={iconSize} />}
|
icon={<TbRefresh size={iconSize} />}
|
||||||
label={msg`Refresh`}
|
label={msg`Refresh`}
|
||||||
mode={mode}
|
|
||||||
onClick={async () => await dispatch(reloadEntries())}
|
onClick={async () => await dispatch(reloadEntries())}
|
||||||
/>
|
/>
|
||||||
<ActionButton
|
<ActionButton
|
||||||
icon={<TbChecks size={iconSize} />}
|
icon={<TbChecks size={iconSize} />}
|
||||||
label={msg`Mark all as read`}
|
label={msg`Mark all as read`}
|
||||||
mode={mode}
|
|
||||||
onClick={() => dispatch(markAllAsReadWithConfirmationIfRequired())}
|
onClick={() => dispatch(markAllAsReadWithConfirmationIfRequired())}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
@@ -152,20 +140,18 @@ export function Header() {
|
|||||||
<ActionButton
|
<ActionButton
|
||||||
icon={settings.readingMode === "all" ? <TbEye size={iconSize} /> : <TbEyeOff size={iconSize} />}
|
icon={settings.readingMode === "all" ? <TbEye size={iconSize} /> : <TbEyeOff size={iconSize} />}
|
||||||
label={settings.readingMode === "all" ? msg`All` : msg`Unread`}
|
label={settings.readingMode === "all" ? msg`All` : msg`Unread`}
|
||||||
mode={mode}
|
|
||||||
onClick={toggleReadingMode}
|
onClick={toggleReadingMode}
|
||||||
/>
|
/>
|
||||||
<ActionButton
|
<ActionButton
|
||||||
icon={settings.readingOrder === "asc" ? <TbSortAscending size={iconSize} /> : <TbSortDescending size={iconSize} />}
|
icon={settings.readingOrder === "asc" ? <TbSortAscending size={iconSize} /> : <TbSortDescending size={iconSize} />}
|
||||||
label={settings.readingOrder === "asc" ? msg`Asc` : msg`Desc`}
|
label={settings.readingOrder === "asc" ? msg`Asc` : msg`Desc`}
|
||||||
mode={mode}
|
|
||||||
onClick={toggleReadingOrder}
|
onClick={toggleReadingOrder}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Popover>
|
<Popover>
|
||||||
<Popover.Target>
|
<Popover.Target>
|
||||||
<Indicator disabled={!searchFromStore}>
|
<Indicator disabled={!searchFromStore}>
|
||||||
<ActionButton icon={<TbSearch size={iconSize} />} label={msg`Search`} mode={mode} />
|
<ActionButton icon={<TbSearch size={iconSize} />} label={msg`Search`} />
|
||||||
</Indicator>
|
</Indicator>
|
||||||
</Popover.Target>
|
</Popover.Target>
|
||||||
<Popover.Dropdown>
|
<Popover.Dropdown>
|
||||||
@@ -183,7 +169,7 @@ export function Header() {
|
|||||||
|
|
||||||
<HeaderDivider />
|
<HeaderDivider />
|
||||||
|
|
||||||
<ProfileMenu control={<ActionButton icon={<TbUser size={iconSize} />} label={profile?.name} mode={mode} />} />
|
<ProfileMenu control={<ActionButton icon={<TbUser size={iconSize} />} label={profile?.name} />} />
|
||||||
|
|
||||||
{isBrowserExtensionPopup && (
|
{isBrowserExtensionPopup && (
|
||||||
<>
|
<>
|
||||||
@@ -192,13 +178,11 @@ export function Header() {
|
|||||||
<ActionButton
|
<ActionButton
|
||||||
icon={<TbSettings size={iconSize} />}
|
icon={<TbSettings size={iconSize} />}
|
||||||
label={msg`Extension options`}
|
label={msg`Extension options`}
|
||||||
mode={mode}
|
|
||||||
onClick={() => openSettingsPage()}
|
onClick={() => openSettingsPage()}
|
||||||
/>
|
/>
|
||||||
<ActionButton
|
<ActionButton
|
||||||
icon={<TbExternalLink size={iconSize} />}
|
icon={<TbExternalLink size={iconSize} />}
|
||||||
label={msg`Open CommaFeed`}
|
label={msg`Open CommaFeed`}
|
||||||
mode={mode}
|
|
||||||
onClick={() => openAppInNewTab()}
|
onClick={() => openAppInNewTab()}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
|
|||||||
Reference in New Issue
Block a user