refactor: add follow and autocomponent (#65)

* chore: move files

Signed-off-by: Innei <i@innei.in>

* fix: logo

Signed-off-by: Innei <i@innei.in>

* update style

Signed-off-by: Innei <i@innei.in>

* feat: modal add follow

Signed-off-by: Innei <i@innei.in>

---------

Signed-off-by: Innei <i@innei.in>
This commit is contained in:
Innei
2024-06-14 23:07:09 +08:00
committed by GitHub
parent 396a7d7cd6
commit c0c2513f19
53 changed files with 828 additions and 404 deletions
+1
View File
@@ -59,6 +59,7 @@
"electron-updater": "^6.1.7",
"framer-motion": "11.2.9",
"franc-min": "6.2.0",
"fuse.js": "7.0.0",
"hast-util-to-jsx-runtime": "2.3.0",
"hotkeys-js": "3.13.7",
"idb-keyval": "6.2.1",
+9
View File
@@ -121,6 +121,9 @@ importers:
franc-min:
specifier: 6.2.0
version: 6.2.0
fuse.js:
specifier: 7.0.0
version: 7.0.0
hast-util-to-jsx-runtime:
specifier: 2.3.0
version: 2.3.0
@@ -3159,6 +3162,10 @@ packages:
function-bind@1.1.2:
resolution: {integrity: sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==}
fuse.js@7.0.0:
resolution: {integrity: sha512-14F4hBIxqKvD4Zz/XjDc3y94mNZN6pRv3U13Udo0lNLCWRBUsrMv2xwcF/y/Z5sV6+FQW+/ow68cHpm4sunt8Q==}
engines: {node: '>=10'}
gauge@4.0.4:
resolution: {integrity: sha512-f9m+BEN5jkg6a0fZjleidjN51VE1X+mPFQ2DJ0uv1V39oCLCbsGe6yjbBnp7eK7z/+GAon99a3nHuqbuuthyPg==}
engines: {node: ^12.13.0 || ^14.15.0 || >=16.0.0}
@@ -8785,6 +8792,8 @@ snapshots:
function-bind@1.1.2: {}
fuse.js@7.0.0: {}
gauge@4.0.4:
dependencies:
aproba: 2.0.0
File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 147 KiB

+5 -3
View File
@@ -12,7 +12,7 @@ export function FollowSummary({
className?: string
}) {
return (
<div className={cn("select-text space-y-1 text-sm", className)}>
<div className={cn("flex select-text flex-col gap-2 text-sm", className)}>
<a
href={feed.siteUrl || void 0}
target="_blank"
@@ -22,7 +22,7 @@ export function FollowSummary({
<FeedIcon
feed={feed}
fallbackUrl={docs}
className="mr-2 size-8 shrink-0"
className="mask-squircle mask mr-2 size-8 shrink-0 rounded-none"
/>
<div className="truncate text-base font-semibold leading-tight">
{feed.title}
@@ -33,7 +33,9 @@ export function FollowSummary({
</a>
<div className="flex items-center gap-1 truncate text-zinc-500">
<i className="i-mingcute-right-line shrink-0" />
{feed.url || docs}
<a href={feed.url || docs} target="_blank" rel="noreferrer">
{feed.url || docs}
</a>
</div>
</div>
)
+19 -12
View File
@@ -8,18 +8,23 @@ import {
import { APP_NAME } from "@renderer/lib/constants"
import { Link } from "react-router-dom"
import { Logo } from "./icons/logo"
import { UserButton } from "./user-button"
const items = [{
name: "Home",
link: "/",
}, {
name: "Download",
link: "/download",
}, {
name: "Blog",
link: "/blog",
}]
const items = [
{
name: "Home",
link: "/",
},
{
name: "Download",
link: "/download",
},
{
name: "Blog",
link: "/blog",
},
]
export function Header() {
// TODO optimize ui in mobile view
@@ -28,7 +33,7 @@ export function Header() {
<div className="mx-auto flex w-full max-w-[1400px] items-center justify-between">
<div className="flex items-center gap-8">
<div className="flex items-center gap-2 text-xl font-bold">
<img src="../icon.svg" alt="logo" className="size-8" />
<Logo className="size-8" />
{APP_NAME}
</div>
<NavigationMenu className="hidden lg:block">
@@ -36,7 +41,9 @@ export function Header() {
{items.map((item) => (
<NavigationMenuItem key={item.link}>
<Link to={item.link}>
<NavigationMenuLink className={navigationMenuTriggerStyle()}>
<NavigationMenuLink
className={navigationMenuTriggerStyle()}
>
{item.name}
</NavigationMenuLink>
</Link>
@@ -0,0 +1,45 @@
export const Logo: Component = (props) => (
<svg
{...props}
viewBox="0 0 145 145"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<mask
id="mask0_54_296"
maskUnits="userSpaceOnUse"
x="0"
y="0"
width="145"
height="145"
>
<path
fillRule="evenodd"
clipRule="evenodd"
d="M144.491 45.4541C144.491 43.75 144.492 42.0456 144.481 40.3413C144.473 38.9056 144.456 37.4702 144.417 36.0352C144.333 32.9075 144.148 29.753 143.592 26.6601C143.028 23.5227 142.107 20.6027 140.655 17.752C139.228 14.9501 137.364 12.3862 135.139 10.1633C132.915 7.94053 130.351 6.07747 127.548 4.65117C124.694 3.19908 121.771 2.27818 118.63 1.71424C115.537 1.15884 112.381 0.974699 109.254 0.890204C107.818 0.851354 106.382 0.834978 104.945 0.826093C103.24 0.81564 101.535 0.816511 99.8296 0.816511L80.0305 0.745605H65.2222L45.7734 0.816511C44.0649 0.816511 42.3564 0.81564 40.6479 0.826093C39.2085 0.834978 37.7698 0.851354 36.331 0.890204C33.196 0.974699 30.0335 1.15902 26.933 1.71511C23.7879 2.27887 20.8604 3.19943 18.0029 4.65047C15.194 6.07694 12.6239 7.94018 10.3953 10.1633C8.1671 12.386 6.29934 14.9494 4.86956 17.7508C3.41382 20.6028 2.49083 23.5246 1.92533 26.6638C1.36854 29.7554 1.18405 32.9089 1.09921 36.0352C1.06053 37.4704 1.04381 38.9057 1.03509 40.3413C1.02464 42.0458 0.937012 44.163 0.937012 45.8674L0.937534 65.0468L0.937012 80.0136L1.02551 99.6005C1.02551 101.307 1.02482 103.014 1.03509 104.72C1.04381 106.158 1.06053 107.595 1.09938 109.032C1.18405 112.164 1.36889 115.323 1.9262 118.42C2.49153 121.562 3.41434 124.486 4.86886 127.34C6.29882 130.146 8.16692 132.713 10.3953 134.939C12.6237 137.165 15.1932 139.031 18.0015 140.459C20.8607 141.913 23.7896 142.835 26.9366 143.4C30.0357 143.956 33.1972 144.141 36.331 144.225C37.7698 144.264 39.2087 144.281 40.648 144.289C42.3566 144.3 44.0649 144.299 45.7734 144.299L65.398 144.3H80.243L99.8296 144.299C101.535 144.299 103.24 144.3 104.945 144.289C106.382 144.281 107.818 144.264 109.254 144.225C112.383 144.141 115.539 143.956 118.634 143.399C121.773 142.835 124.694 141.913 127.547 140.46C130.35 139.031 132.915 137.166 135.139 134.939C137.363 132.714 139.227 130.147 140.654 127.341C142.107 124.486 143.028 121.56 143.593 118.416C144.148 115.321 144.333 112.163 144.417 109.032C144.456 107.595 144.473 106.158 144.481 104.72C144.492 103.014 144.491 101.307 144.491 99.6005C144.491 99.6005 144.49 80.3594 144.49 80.0136V65.0311C144.49 64.7757 144.491 45.4541 144.491 45.4541Z"
fill="white"
/>
</mask>
<g mask="url(#mask0_54_296)">
<rect
x="0.414551"
y="-6.74585"
width="149.477"
height="158.537"
fill="#FF5C00"
/>
<path
d="M103.609 36.6948H53.5823C47.5327 36.6948 42.6284 41.5946 42.6284 47.6388C42.6284 53.683 47.5327 58.5828 53.5823 58.5828H103.609C109.659 58.5828 114.563 53.683 114.563 47.6388C114.563 41.5946 109.659 36.6948 103.609 36.6948Z"
fill="white"
/>
<path
d="M76.9348 65.1489H43.5916C37.5419 65.1489 32.6377 70.0487 32.6377 76.0929C32.6377 82.1371 37.5419 87.0369 43.5916 87.0369H76.9348C82.9845 87.0369 87.8888 82.1371 87.8888 76.0929C87.8888 70.0487 82.9845 65.1489 76.9348 65.1489Z"
fill="white"
/>
<path
d="M80.1608 104.571C80.1608 98.5272 75.2565 93.6274 69.2068 93.6274C63.1572 93.6274 58.2529 98.5272 58.2529 104.571C58.2529 110.616 63.1572 115.515 69.2068 115.515C75.2565 115.515 80.1608 110.616 80.1608 104.571Z"
fill="white"
/>
</g>
</svg>
)
@@ -0,0 +1,262 @@
import { stopPropagation } from "@renderer/lib/dom"
import { cn } from "@renderer/lib/utils"
import clsx from "clsx"
import { AnimatePresence, m } from "framer-motion"
import Fuse from "fuse.js"
import { merge, throttle } from "lodash-es"
import {
forwardRef,
useCallback,
useEffect,
useImperativeHandle,
useLayoutEffect,
useRef,
useState,
} from "react"
import { useEventCallback } from "usehooks-ts"
import { Input } from "../input"
import { RootPortal } from "../portal"
export type Suggestion = {
name: string
value: string
}
export interface AutocompleteProps
extends React.InputHTMLAttributes<HTMLInputElement> {
suggestions: Suggestion[]
renderSuggestion?: (suggestion: Suggestion) => any
onSuggestionSelected: (suggestion: Suggestion) => void
onConfirm?: (value: string) => void
onEndReached?: () => void
portal?: boolean
// classnames
wrapperClassName?: string
maxHeight?: number
}
const defaultRenderSuggestion = (suggestion: any) => suggestion.name
export const Autocomplete = forwardRef<HTMLInputElement, AutocompleteProps>(
(
{
suggestions,
renderSuggestion = defaultRenderSuggestion,
onSuggestionSelected,
onConfirm,
onEndReached,
onChange,
portal,
wrapperClassName,
maxHeight,
...inputProps
},
forwardedRef,
) => {
const [filterableSuggestions, setFilterableSuggestions] =
useState(suggestions)
const [inputValue, setInputValue] = useState(
inputProps.value || inputProps.defaultValue || "",
)
const doFilter = useEventCallback(() => {
const fuse = new Fuse(suggestions, {
keys: ["name", "value"],
})
const trimInputValue = (inputValue as string).trim()
if (!trimInputValue) return setFilterableSuggestions(suggestions)
const results = fuse.search(trimInputValue)
setFilterableSuggestions(results.map((result) => result.item))
})
useEffect(() => {
doFilter()
}, [inputValue, suggestions])
const [isOpen, setIsOpen] = useState(false)
const [listRef, setListRef] = useState<HTMLElement | null>(null)
const onBlur = useEventCallback((e: any) => {
inputProps.onBlur?.(e)
if (listRef?.contains(e.relatedTarget)) {
return
}
setIsOpen(false)
})
const handleInputKeyDown: React.KeyboardEventHandler<HTMLInputElement> =
useEventCallback((e) => {
if (e.key === "Enter") {
e.preventDefault()
onConfirm?.((e.target as HTMLInputElement).value)
setIsOpen(false)
}
inputProps.onKeyDown?.(e)
})
const inputRef = useRef<HTMLInputElement>(null)
useImperativeHandle(forwardedRef, () => inputRef.current!)
const [inputRect, setInputRect] = useState<DOMRect | null>(null)
const [dropdownHeight, setDropdownHeight] = useState(maxHeight || 200)
const [dropdownPos, setDropdownPos] = useState("down")
// useLayoutEffect(() => {
// const $list = listRef
// if (!$list) return
// const handler = () => {
// const rect = $list.getBoundingClientRect()
// setDropdownHeight(rect.height)
// }
// const ob = new ResizeObserver(handler)
// handler()
// // setInterval(handler, 1000)
// ob.observe($list)
// return () => {
// ob.disconnect()
// }
// }, [listRef])
useLayoutEffect(() => {
const $input = inputRef.current
if (!$input) return
const handler = () => {
const rect = $input.getBoundingClientRect()
setInputRect(rect)
const { top, height } = rect
if (top + height + dropdownHeight > window.innerHeight) {
setDropdownPos("up")
} else {
setDropdownPos("down")
}
}
handler()
const resizeObserver = new ResizeObserver(handler)
resizeObserver.observe($input)
return () => {
resizeObserver.disconnect()
}
}, [dropdownHeight])
const handleScroll = useEventCallback(
throttle(() => {
if (!listRef) return
const { scrollHeight, scrollTop, clientHeight } = listRef!
// gap 50px
if (scrollHeight - scrollTop - clientHeight < 50) {
onEndReached?.()
}
}, 30),
)
const handleChange = useEventCallback((e: any) => {
setInputValue(e.target.value)
onChange?.(e)
})
const ListElement = (
<div
className={clsx(
"pointer-events-auto z-[101] mt-1 overflow-hidden",
portal ? "absolute flex flex-col" : "absolute w-full",
)}
ref={useCallback((el) => {
setListRef(el)
const height = el?.getBoundingClientRect().height
if (height) {
setDropdownHeight(height)
}
}, [])}
style={merge(
{},
portal && inputRect ?
{
width: `${inputRect.width}px`,
left: `${inputRect.x}px`,
top: `${inputRect.y + inputRect.height}px`,
bottom: dropdownPos === "up" ? 0 : undefined,
transform:
dropdownPos === "up" ?
`translateY(-${dropdownHeight}px)` :
undefined,
maxHeight,
} :
{},
)}
>
<m.ul
initial={{ opacity: 0, y: 10 }}
animate={{ opacity: 1, y: 0 }}
exit={{ opacity: 0, y: 10 }}
className={clsx(
"pointer-events-auto max-h-48 grow",
"overflow-auto rounded-md border border-zinc-200 bg-zinc-50/90 backdrop-blur dark:border-neutral-800 dark:bg-neutral-900/90",
)}
// FIXME: https://github.com/radix-ui/primitives/issues/2125
onWheel={stopPropagation}
onScroll={handleScroll}
>
{filterableSuggestions.map((suggestion) => {
const handleClick = () => {
onSuggestionSelected(suggestion)
setIsOpen(false)
setInputValue(suggestion.name)
}
return (
<li
className="cursor-default px-4 py-2 text-sm hover:bg-zinc-200 dark:hover:bg-neutral-800"
key={suggestion.value}
onMouseDown={handleClick}
onClick={handleClick}
>
{renderSuggestion(suggestion)}
</li>
)
})}
</m.ul>
</div>
)
const handleFocus: React.FocusEventHandler<HTMLInputElement> =
useEventCallback((e) => {
setIsOpen(true)
inputProps.onFocus?.(e)
})
return (
<div className={cn("pointer-events-auto relative", wrapperClassName)}>
<Input
value={inputValue}
ref={inputRef}
{...inputProps}
onBlur={onBlur}
onKeyDown={handleInputKeyDown}
onChange={handleChange}
onFocus={handleFocus}
/>
<AnimatePresence>
{isOpen &&
filterableSuggestions.length > 0 &&
(portal ? <RootPortal>{ListElement}</RootPortal> : ListElement)}
</AnimatePresence>
</div>
)
},
)
Autocomplete.displayName = "Autocomplete"
@@ -0,0 +1 @@
export * from "./AutoCompletion"
+97 -41
View File
@@ -1,3 +1,4 @@
import * as Popover from "@radix-ui/react-popover"
import {
Command,
CommandGroup,
@@ -15,10 +16,13 @@ export interface InputProps
options: string[]
emptyMessage: string
value?: string | null
maxHeight?: number
}
/**
* @deprecated please use `ui/auto-completion` instead
*/
export const AutoComplete = React.forwardRef<HTMLInputElement, InputProps>(
({ options, emptyMessage, className, value, ...props }, ref) => {
({ options, emptyMessage, className, value, maxHeight, ...props }, ref) => {
const [open, setOpen] = useState(false)
const onValueChange = useCallback(
@@ -40,51 +44,103 @@ export const AutoComplete = React.forwardRef<HTMLInputElement, InputProps>(
[props.onChange],
)
const inputRef = React.useRef<HTMLInputElement>(null)
const [dropdownHeight, setDropdownHeight] = React.useState(
maxHeight || 200,
)
const [inputRect, setInputRect] = React.useState<DOMRect | null>(null)
const [dropdownPos, setDropdownPos] = React.useState("down")
React.useLayoutEffect(() => {
if (!inputRef.current) {
return
}
const rect = inputRef.current.getBoundingClientRect()
const { top, height } = rect
if (top + height + dropdownHeight > window.innerHeight) {
setDropdownPos("up")
} else {
setDropdownPos("down")
}
setInputRect(rect)
}, [inputRect?.height, dropdownHeight])
React.useImperativeHandle(ref, () => inputRef.current!)
return (
<Command className="relative overflow-visible rounded-lg border bg-background [&_.lucide-search]:hidden [&_[cmdk-input-wrapper]]:border-0">
<CommandInput
{...props}
className="h-10"
onBlur={(e) => {
setOpen(false)
props.onBlur?.(e)
}}
onFocus={(e) => {
setOpen(true)
props.onFocus?.(e)
}}
value={value || void 0}
onValueChange={(value) => {
setOpen(true)
onValueChange(value)
}}
ref={ref}
/>
{options.length > 0 && (
<Popover.Root open={open && options.length > 0}>
<Popover.Trigger>
<CommandInput
{...props}
className="h-10"
onBlur={(e) => {
setOpen(false)
props.onBlur?.(e)
}}
onFocus={(e) => {
setOpen(true)
props.onFocus?.(e)
}}
value={value || void 0}
onValueChange={(value) => {
setOpen(true)
onValueChange(value)
}}
ref={inputRef}
/>
</Popover.Trigger>
<CommandList>
<CommandGroup
className={cn(
"absolute top-full z-10 mt-1 hidden w-full rounded-lg border bg-background [&[hidden]]:!hidden",
open && "block",
)}
>
{options.map((option) => (
<CommandItem
key={option}
value={option}
onSelect={() => handleSelectOption(option)}
className="text-zinc-800"
onMouseDown={(event) => {
event.preventDefault()
event.stopPropagation()
<Popover.Portal>
<Popover.Content>
<div
style={{
width: inputRect?.width,
bottom: dropdownPos === "up" ? 0 : undefined,
transform:
dropdownPos === "up" ?
`translateY(-${
dropdownHeight + (inputRect?.height || 0)
}px)` :
undefined,
}}
>
{option}
</CommandItem>
))}
</CommandGroup>
<CommandGroup
className={cn(
"absolute top-full z-10 mt-1 hidden w-full rounded-lg border bg-background [&[hidden]]:!hidden",
open && "block",
)}
ref={(el: HTMLDivElement) => {
if (el) {
setDropdownHeight(el.clientHeight)
}
}}
style={{
maxHeight,
}}
>
{options.map((option) => (
<CommandItem
key={option}
value={option}
onSelect={() => handleSelectOption(option)}
className="text-zinc-800"
onMouseDown={(event) => {
event.preventDefault()
event.stopPropagation()
}}
>
{option}
</CommandItem>
))}
</CommandGroup>
</div>
</Popover.Content>
</Popover.Portal>
</CommandList>
)}
</Popover.Root>
</Command>
)
},
@@ -51,11 +51,11 @@ export const styledButtonVariant = cva(
},
variant: {
primary: cn(
"bg-theme-accent text-zinc-100",
"bg-theme-accent",
"hover:contrast-[1.10] active:contrast-125",
"font-semibold",
"disabled:bg-theme-accent/40 disabled:opacity-80 disabled:dark:text-zinc-50",
"dark:text-neutral-800",
"text-zinc-100 dark:text-zinc-200/90",
),
plain: cn(
+1 -1
View File
@@ -70,7 +70,7 @@ const CommandGroup = React.forwardRef<
<CommandPrimitive.Group
ref={ref}
className={cn(
"overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",
"overflow-auto p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",
className,
)}
{...props}
@@ -0,0 +1,14 @@
import type { FC, PropsWithChildren } from "react"
import { createPortal } from "react-dom"
import { useRootPortal } from "./provider"
export const RootPortal: FC<
{
to?: HTMLElement
} & PropsWithChildren
> = (props) => {
const to = useRootPortal()
return createPortal(props.children, props.to || to || document.body)
}
@@ -0,0 +1,15 @@
import { createContext, useContext } from "react"
export const useRootPortal = () => {
const ctx = useContext(RootPortalContext)
return ctx.to || document.body
}
const RootPortalContext = createContext<{
to?: HTMLElement | undefined
}>({
to: undefined,
})
export const RootPortalProvider = RootPortalContext.Provider
+1 -1
View File
@@ -9,7 +9,7 @@ const Switch = React.forwardRef<
<SwitchPrimitives.Root
className={cn(
"peer inline-flex h-6 w-11 shrink-0 items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50",
"data-[state=checked]:bg-primary data-[state=unchecked]:bg-input dark:data-[state=checked]:bg-neutral-500 dark:data-[state=unchecked]:bg-neutral-700",
"duration-200 data-[state=checked]:bg-theme-accent data-[state=unchecked]:bg-theme-accent-100/10",
className,
)}
{...props}
+2 -2
View File
@@ -46,8 +46,8 @@ const tabsTriggerVariants = cva(
{
variants: {
variant: {
default: "py-1.5 border-b-2 border-transparent data-[state=active]:border-foreground",
rounded: "py-1 rounded-sm data-[state=active]:bg-background data-[state=active]:shadow-sm",
default: "py-1.5 border-b-2 border-transparent data-[state=active]:border-current data-[state=active]:text-theme-accent dark:data-[state=active]:text-theme-accent-500",
rounded: "py-1 rounded-sm data-[state=active]:bg-theme-accent-300 dark:data-[state=active]:bg-theme-accent-800 data-[state=active]:shadow-sm",
},
},
defaultVariants: {
@@ -0,0 +1,248 @@
import { zodResolver } from "@hookform/resolvers/zod"
import { FollowSummary } from "@renderer/components/feed-summary"
import { Logo } from "@renderer/components/icons/logo"
import { Autocomplete } from "@renderer/components/ui/auto-completion"
import { StyledButton } from "@renderer/components/ui/button"
import { Card, CardHeader } from "@renderer/components/ui/card"
import {
Form,
FormControl,
FormDescription,
FormField,
FormItem,
FormLabel,
FormMessage,
} from "@renderer/components/ui/form"
import { LoadingCircle } from "@renderer/components/ui/loading"
import {
Select,
SelectTrigger,
SelectValue,
} from "@renderer/components/ui/select"
import { Switch } from "@renderer/components/ui/switch"
import { ViewSelectContent } from "@renderer/components/view-select-content"
import { useBizQuery } from "@renderer/hooks"
import { apiClient } from "@renderer/lib/api-fetch"
import { client } from "@renderer/lib/client"
import { FeedViewType } from "@renderer/lib/enum"
import { cn } from "@renderer/lib/utils"
import { Queries } from "@renderer/queries"
import { useFeed } from "@renderer/queries/feed"
import { useMutation } from "@tanstack/react-query"
import { useEffect } from "react"
import { useForm } from "react-hook-form"
import { toast } from "sonner"
import { z } from "zod"
const formSchema = z.object({
view: z.string(),
category: z.string().nullable().optional(),
isPrivate: z.boolean().optional(),
})
export const FeedForm: Component<{
url?: string
id?: string
defaultView?: FeedViewType
asWidget?: boolean
}> = ({ id, defaultView = FeedViewType.Articles, url, asWidget }) => {
const feed = useFeed({
url,
id,
})
const isSubscribed = !!feed.data?.subscription
const form = useForm<z.infer<typeof formSchema>>({
resolver: zodResolver(formSchema),
defaultValues: {
view: defaultView.toString(),
},
})
useEffect(() => {
if (feed.data?.subscription) {
form.setValue("view", `${feed.data?.subscription?.view}`)
form.setValue("category", feed.data?.subscription?.category)
form.setValue("isPrivate", feed.data?.subscription?.isPrivate || false)
}
}, [feed.data?.subscription])
const followMutation = useMutation({
mutationFn: async (values: z.infer<typeof formSchema>) => {
const body = {
url: feed.data?.feed.url,
view: Number.parseInt(values.view),
category: values.category,
isPrivate: values.isPrivate,
...(isSubscribed && { feedId: feed.data?.feed.id }),
}
const $method = isSubscribed ?
apiClient.subscriptions.$patch :
apiClient.subscriptions.$post
return $method({
// @ts-expect-error
json: body,
})
},
onSuccess: (_, variables) => {
if (
isSubscribed &&
variables.view !== `${feed.data?.subscription?.view}`
) {
Queries.subscription.byView(feed.data?.subscription?.view).invalidate()
client?.invalidateQuery(
Queries.subscription.byView(feed.data?.subscription?.view).key,
)
}
Queries.subscription.byView(Number.parseInt(variables.view)).invalidate()
client?.invalidateQuery(
Queries.subscription.byView(Number.parseInt(variables.view)).key,
)
const feedId = feed.data?.feed.id
if (feedId) {
Queries.feed.byId({ id: feedId }).invalidate()
client?.invalidateQuery(Queries.feed.byId({ id: feedId }).key)
}
toast(isSubscribed ? "🎉 Updated." : "🎉 Followed.", {
duration: 1000,
})
if (!isSubscribed) {
window.close()
}
},
})
function onSubmit(values: z.infer<typeof formSchema>) {
followMutation.mutate(values)
}
const categories = useBizQuery(
Queries.subscription.categories(Number.parseInt(form.watch("view"))),
)
return (
<div className={cn("flex h-full flex-col", !asWidget && "px-[18px] pb-[18px] pt-12")}>
{!asWidget && (
<div className="mb-4 mt-2 flex items-center gap-2 text-[22px] font-bold">
<Logo className="size-8" />
{isSubscribed ? "Update" : "Add"}
{" "}
follow
</div>
)}
{feed.isLoading ? (
<div className="flex flex-1 items-center justify-center">
<LoadingCircle size="large" />
</div>
) : !feed.data?.feed ?
(
<div className="flex flex-1 flex-col items-center justify-center gap-2">
<p>Feed not found.</p>
<p>{url}</p>
</div>
) :
(
<div className="flex flex-1 flex-col gap-y-4">
<Card>
<CardHeader>
<FollowSummary feed={feed.data?.feed} />
</CardHeader>
</Card>
<Form {...form}>
<form
onSubmit={form.handleSubmit(onSubmit)}
className="flex flex-1 flex-col gap-y-4"
>
<FormField
control={form.control}
name="view"
render={({ field }) => (
<FormItem>
<FormLabel>View</FormLabel>
<Select onValueChange={field.onChange} value={field.value}>
<FormControl>
<SelectTrigger>
<SelectValue />
</SelectTrigger>
</FormControl>
<ViewSelectContent />
</Select>
<FormMessage />
</FormItem>
)}
/>
<FormField
control={form.control}
name="category"
render={({ field }) => (
<FormItem>
<div>
<FormLabel>Category</FormLabel>
<FormDescription>
By default, your follows will be grouped by website.
</FormDescription>
</div>
<FormControl>
<div>
<Autocomplete
maxHeight={window.innerHeight < 600 ? 120 : 240}
portal
suggestions={categories.data?.map((i) => ({
name: i,
value: i,
})) || []}
{...(field as any)}
onSuggestionSelected={(suggestion) => {
field.onChange(suggestion.value)
}}
/>
</div>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<FormField
control={form.control}
name="isPrivate"
render={({ field }) => (
<FormItem>
<div className="flex items-center justify-between">
<div>
<FormLabel>Private Follow</FormLabel>
<FormDescription>
Whether this follow is publicly visible on your
profile page.
</FormDescription>
</div>
<FormControl>
<Switch
className="shrink-0"
checked={field.value}
onCheckedChange={field.onChange}
/>
</FormControl>
</div>
</FormItem>
)}
/>
<div className="flex flex-1 items-end justify-end">
<StyledButton
type="submit"
isLoading={followMutation.isPending}
>
{isSubscribed ? "Update" : "Follow"}
</StyledButton>
</div>
</form>
</Form>
</div>
)}
</div>
)
}
@@ -1,5 +1,5 @@
import { zodResolver } from "@hookform/resolvers/zod"
import { Button } from "@renderer/components/ui/button"
import { Button, StyledButton } from "@renderer/components/ui/button"
import {
Card,
CardContent,
@@ -16,17 +16,17 @@ import {
} from "@renderer/components/ui/form"
import { Image } from "@renderer/components/ui/image"
import { Input } from "@renderer/components/ui/input"
import { useModalStack } from "@renderer/components/ui/modal/stacked/hooks"
import { apiClient } from "@renderer/lib/api-fetch"
import { FeedViewType } from "@renderer/lib/enum"
import { useFeedStore } from "@renderer/store"
import { DEEPLINK_SCHEME } from "@shared/constants"
import { openElectronWindow } from "@shared/electron"
import { useMutation } from "@tanstack/react-query"
import { useEffect } from "react"
import { useForm } from "react-hook-form"
import { z } from "zod"
import { FollowSummary } from "../feed-summary"
import { FollowSummary } from "../../components/feed-summary"
import { FeedForm } from "./feed-form"
const formSchema = z.object({
keyword: z.string().min(1),
@@ -91,6 +91,8 @@ export function DiscoverForm({ type }: { type: string }) {
}
}, [keyword])
const { present } = useModalStack()
return (
<>
<Form {...form}>
@@ -111,9 +113,11 @@ export function DiscoverForm({ type }: { type: string }) {
</FormItem>
)}
/>
<Button type="submit" isLoading={mutation.isPending}>
Search
</Button>
<div className="center flex">
<StyledButton type="submit" isLoading={mutation.isPending}>
Search
</StyledButton>
</div>
</form>
</Form>
{mutation.isSuccess && (
@@ -186,26 +190,17 @@ export function DiscoverForm({ type }: { type: string }) {
) : (
<Button
onClick={() => {
const searchParams = new URLSearchParams()
if (item.feed.id) {
searchParams.set("id", item.feed.id)
} else {
searchParams.set("url", item.feed.url)
}
searchParams.set(
"view",
String(`${useFeedStore.getState().activeList?.view ||
FeedViewType.Articles}`),
)
openElectronWindow(
`${DEEPLINK_SCHEME}add?${
searchParams.toString()
}`,
{
resizable: false,
height: 550,
},
)
present({
title: "Add follow",
content: () => (
<FeedForm
asWidget
url={item.feed.url}
id={item.feed.id}
defaultView={FeedViewType.Articles}
/>
),
})
}}
>
Follow
@@ -18,7 +18,7 @@ import { useMutation } from "@tanstack/react-query"
import { useForm } from "react-hook-form"
import { z } from "zod"
import { FollowSummary } from "../feed-summary"
import { FollowSummary } from "../../components/feed-summary"
type FeedResponseList = {
id: string
@@ -1,12 +1,12 @@
import { EntryTranslation } from "@renderer/components/entry-column/translation"
import { FeedIcon } from "@renderer/components/feed-icon"
import { Image } from "@renderer/components/ui/image"
import { useAsRead } from "@renderer/hooks"
import dayjs from "@renderer/lib/dayjs"
import { cn } from "@renderer/lib/utils"
import { EntryTranslation } from "@renderer/modules/entry-column/translation"
import { useEntry } from "@renderer/store/entry/hooks"
import { ReactVirtuosoItemPlaceholder } from "../ui/placeholder"
import { ReactVirtuosoItemPlaceholder } from "../../components/ui/placeholder"
import type { UniversalItemProps } from "./types"
export function ArticleItem({ entryId, entryPreview, translation }: UniversalItemProps) {
@@ -1,10 +1,10 @@
import { EntryTranslation } from "@renderer/components/entry-column/translation"
import { FeedIcon } from "@renderer/components/feed-icon"
import dayjs from "@renderer/lib/dayjs"
import { cn } from "@renderer/lib/utils"
import { EntryTranslation } from "@renderer/modules/entry-column/translation"
import { useEntry } from "@renderer/store/entry/hooks"
import { ReactVirtuosoItemPlaceholder } from "../ui/placeholder"
import { ReactVirtuosoItemPlaceholder } from "../../components/ui/placeholder"
import type { UniversalItemProps } from "./types"
export function AudioItem({ entryId, entryPreview, translation }: UniversalItemProps) {
@@ -40,8 +40,8 @@ import { Virtuoso, VirtuosoGrid } from "react-virtuoso"
import { useEventCallback } from "usehooks-ts"
import { useShallow } from "zustand/react/shallow"
import { EmptyIcon } from "../icons/empty"
import { LoadingCircle } from "../ui/loading"
import { EmptyIcon } from "../../components/icons/empty"
import { LoadingCircle } from "../../components/ui/loading"
import { EntryItem } from "./item"
const unreadOnlyAtom = atomWithStorage<boolean>(
@@ -10,7 +10,7 @@ import { useEntry } from "@renderer/store/entry/hooks"
import type { FC } from "react"
import { memo, useCallback } from "react"
import { ReactVirtuosoItemPlaceholder } from "../ui/placeholder"
import { ReactVirtuosoItemPlaceholder } from "../../components/ui/placeholder"
import { ArticleItem } from "./article-item"
import { AudioItem } from "./audio-item"
import { NotificationItem } from "./notification-item"
@@ -1,10 +1,10 @@
import { EntryTranslation } from "@renderer/components/entry-column/translation"
import { FeedIcon } from "@renderer/components/feed-icon"
import dayjs from "@renderer/lib/dayjs"
import { cn } from "@renderer/lib/utils"
import { EntryTranslation } from "@renderer/modules/entry-column/translation"
import { useEntry } from "@renderer/store/entry/hooks"
import { ReactVirtuosoItemPlaceholder } from "../ui/placeholder"
import { ReactVirtuosoItemPlaceholder } from "../../components/ui/placeholder"
import type { UniversalItemProps } from "./types"
export function NotificationItem({ entryId, entryPreview, translation }: UniversalItemProps) {
@@ -1,12 +1,12 @@
import { EntryTranslation } from "@renderer/components/entry-column/translation"
import { FeedIcon } from "@renderer/components/feed-icon"
import { SwipeImages } from "@renderer/components/ui/image/swipe-images"
import { ReactVirtuosoItemPlaceholder } from "@renderer/components/ui/placeholder"
import dayjs from "@renderer/lib/dayjs"
import { cn } from "@renderer/lib/utils"
import { EntryTranslation } from "@renderer/modules/entry-column/translation"
import { useEntry } from "@renderer/store/entry/hooks"
import { usePreviewImages } from "../ui/image/hooks"
import { usePreviewImages } from "../../components/ui/image/hooks"
import type { UniversalItemProps } from "./types"
export function PictureItem({ entryId, entryPreview, translation }: UniversalItemProps) {
@@ -4,7 +4,7 @@ import dayjs from "@renderer/lib/dayjs"
import { cn } from "@renderer/lib/utils"
import { useEntry } from "@renderer/store/entry/hooks"
import { ReactVirtuosoItemPlaceholder } from "../ui/placeholder"
import { ReactVirtuosoItemPlaceholder } from "../../components/ui/placeholder"
import { EntryTranslation } from "./translation"
import type { UniversalItemProps } from "./types"
@@ -7,7 +7,7 @@ import { useEntry } from "@renderer/store/entry/hooks"
import { useHover } from "@use-gesture/react"
import { useMemo, useRef, useState } from "react"
import { ReactVirtuosoItemPlaceholder } from "../ui/placeholder"
import { ReactVirtuosoItemPlaceholder } from "../../components/ui/placeholder"
import type { UniversalItemProps } from "./types"
export function VideoItem({ entryId, entryPreview, translation }: UniversalItemProps) {
@@ -1,3 +1,4 @@
import { Logo } from "@renderer/components/icons/logo"
import { useBizQuery } from "@renderer/hooks"
import { parseHtml } from "@renderer/lib/parse-html"
import type { ActiveEntryId } from "@renderer/models"
@@ -6,8 +7,8 @@ import { useEntry, useFeedStore } from "@renderer/store"
import { m } from "framer-motion"
import { useEffect, useState } from "react"
import { LoadingCircle } from "../../components/ui/loading"
import { EntryTranslation } from "../entry-column/translation"
import { LoadingCircle } from "../ui/loading"
import { EntryShare } from "./share"
export const EntryContent = ({ entry }: { entry: ActiveEntryId }) => {
@@ -20,11 +21,7 @@ export const EntryContent = ({ entry }: { entry: ActiveEntryId }) => {
initial={{ opacity: 0.01, y: 300 }}
animate={{ opacity: 1, y: 0 }}
>
<img
src="./icon.svg"
alt="logo"
className="size-16 opacity-40 grayscale"
/>
<Logo className="size-16 opacity-40 grayscale" />
{activeList?.name}
</m.div>
)
@@ -84,7 +81,10 @@ function EntryContentRender({ entryId }: { entryId: string }) {
rel="noreferrer"
>
<div className="select-text break-words text-3xl font-bold">
<EntryTranslation source={entry.entries.title} target={translation.data?.title} />
<EntryTranslation
source={entry.entries.title}
target={translation.data?.title}
/>
</div>
<div className="mt-2 text-[13px] font-medium text-zinc-500">
{entry.feeds?.title}
@@ -3,8 +3,8 @@ import { Queries } from "@renderer/queries"
import { subscriptionActions } from "@renderer/store"
import { useMutation } from "@tanstack/react-query"
import { StyledButton } from "../ui/button"
import { useCurrentModal } from "../ui/modal"
import { StyledButton } from "../../components/ui/button"
import { useCurrentModal } from "../../components/ui/modal"
export function CategoryRemoveDialogContent({
feedIdList,
@@ -14,7 +14,7 @@ import {
import { AnimatePresence, m } from "framer-motion"
import { useEffect, useState } from "react"
import { useModalStack } from "../ui/modal/stacked/hooks"
import { useModalStack } from "../../components/ui/modal/stacked/hooks"
import { CategoryRemoveDialogContent } from "./category-remove-dialog"
import {
CategoryRenameContent,
@@ -1,3 +1,4 @@
import { Logo } from "@renderer/components/icons/logo"
import { ActionButton } from "@renderer/components/ui/button"
import { ProfileButton } from "@renderer/components/user-button"
import { APP_NAME, levels, views } from "@renderer/lib/constants"
@@ -10,7 +11,7 @@ import { Lethargy } from "lethargy"
import { useEffect, useRef, useState } from "react"
import { Link } from "react-router-dom"
import { Vibrancy } from "../ui/background"
import { Vibrancy } from "../../components/ui/background"
import { FeedList } from "./list"
const lethargy = new Lethargy()
@@ -86,7 +87,7 @@ export function FeedColumn() {
})
}}
>
<img src="./icon.svg" alt="logo" className="size-6" />
<Logo className="size-6" />
{APP_NAME}
</div>
)}
@@ -19,6 +19,7 @@ import {
useFeedActiveList,
useUnreadStore,
} from "@renderer/store"
import { openElectronWindow } from "@shared/electron"
import { useMutation } from "@tanstack/react-query"
import { toast } from "sonner"
@@ -118,7 +119,12 @@ export function FeedItem({
{
type: "text",
label: "Edit",
click: () => window.open(`follow://add?id=${feed.feedId}`),
click: () =>
openElectronWindow(`follow://add?id=${feed.feedId}`, {
resizable: false,
height: 550,
}),
},
{
type: "text",
@@ -1,9 +1,3 @@
import { ArticleItem } from "@renderer/components/entry-column/article-item"
import { NotificationItem } from "@renderer/components/entry-column/notification-item"
import { PictureItem } from "@renderer/components/entry-column/picture-item"
import { SocialMediaItem } from "@renderer/components/entry-column/social-media-item"
import type { UniversalItemProps } from "@renderer/components/entry-column/types"
import { VideoItem } from "@renderer/components/entry-column/video-item"
import { FeedIcon } from "@renderer/components/feed-icon"
import { FollowIcon } from "@renderer/components/icons/follow"
import { StyledButton } from "@renderer/components/ui/button"
@@ -12,6 +6,12 @@ import { APP_NAME, views } from "@renderer/lib/constants"
import { FeedViewType } from "@renderer/lib/enum"
import { cn } from "@renderer/lib/utils"
import type { FeedModel } from "@renderer/models"
import { ArticleItem } from "@renderer/modules/entry-column/article-item"
import { NotificationItem } from "@renderer/modules/entry-column/notification-item"
import { PictureItem } from "@renderer/modules/entry-column/picture-item"
import { SocialMediaItem } from "@renderer/modules/entry-column/social-media-item"
import type { UniversalItemProps } from "@renderer/modules/entry-column/types"
import { VideoItem } from "@renderer/modules/entry-column/video-item"
import { useEntriesPreview } from "@renderer/queries/entries"
import { useFeed } from "@renderer/queries/feed"
import { DEEPLINK_SCHEME } from "@shared/constants"
+2 -1
View File
@@ -1,4 +1,5 @@
import { signIn, useSession } from "@hono/auth-js/react"
import { Logo } from "@renderer/components/icons/logo"
import { Button } from "@renderer/components/ui/button"
import { useSignOut } from "@renderer/hooks"
import { LOGIN_CALLBACK_URL, loginHandler } from "@renderer/lib/auth"
@@ -32,7 +33,7 @@ export function Component() {
return (
<div className="flex h-screen w-full flex-col items-center justify-center gap-10">
<img src="./icon.svg" alt="logo" className="size-20" />
<Logo className="size-20" />
<h1 className="text-3xl font-bold">
Log in to
{" "}
@@ -1,3 +1,4 @@
import { Logo } from "@renderer/components/icons/logo"
import { Button } from "@renderer/components/ui/button"
import { UserButton } from "@renderer/components/user-button"
import { apiClient } from "@renderer/lib/api-fetch"
@@ -27,7 +28,7 @@ export function Component() {
return (
<div className="flex h-screen w-full flex-col items-center justify-center gap-10">
<img src="./icon.svg" alt="logo" className="size-20" />
<Logo className="size-20" />
<UserButton className="bg-stone-100 px-10 py-4 text-2xl" />
<h1 className="text-3xl font-bold">
Successfully connected to
@@ -1,12 +1,12 @@
import { DiscoverForm } from "@renderer/components/discover/form"
import { DiscoverImport } from "@renderer/components/discover/import"
import { Recommendations } from "@renderer/components/discover/recommendations"
import {
Tabs,
TabsContent,
TabsList,
TabsTrigger,
} from "@renderer/components/ui/tabs"
import { DiscoverForm } from "@renderer/modules/discover/form"
import { DiscoverImport } from "@renderer/modules/discover/import"
import { Recommendations } from "@renderer/modules/discover/recommendations"
export function Component() {
const tabs = [
@@ -1,4 +1,3 @@
import { FeedList } from "@renderer/components/feed-column/list"
import {
Avatar,
AvatarFallback,
@@ -8,6 +7,7 @@ import { Button } from "@renderer/components/ui/button"
import { useSignOut } from "@renderer/hooks"
import { views } from "@renderer/lib/constants"
import { cn } from "@renderer/lib/utils"
import { FeedList } from "@renderer/modules/feed-column/list"
import { useSession } from "@renderer/queries/auth"
export function Component() {
@@ -1,7 +1,7 @@
import { EntryColumn } from "@renderer/components/entry-column"
import { EntryContent } from "@renderer/components/entry-content"
import { views } from "@renderer/lib/constants"
import { cn } from "@renderer/lib/utils"
import { EntryColumn } from "@renderer/modules/entry-column"
import { EntryContent } from "@renderer/modules/entry-content"
import {
feedActions,
uiActions,
@@ -1,5 +1,5 @@
import { setMainContainerElement } from "@renderer/atoms"
import { FeedColumn } from "@renderer/components/feed-column"
import { FeedColumn } from "@renderer/modules/feed-column"
import { Outlet } from "react-router-dom"
export function Component() {
+9 -216
View File
@@ -1,42 +1,6 @@
import { zodResolver } from "@hookform/resolvers/zod"
import { FollowSummary } from "@renderer/components/feed-summary"
import { AutoComplete } from "@renderer/components/ui/autocomplete"
import { Button } from "@renderer/components/ui/button"
import { Card, CardHeader } from "@renderer/components/ui/card"
import {
Form,
FormControl,
FormDescription,
FormField,
FormItem,
FormLabel,
FormMessage,
} from "@renderer/components/ui/form"
import { LoadingCircle } from "@renderer/components/ui/loading"
import {
Select,
SelectTrigger,
SelectValue,
} from "@renderer/components/ui/select"
import { Switch } from "@renderer/components/ui/switch"
import { ViewSelectContent } from "@renderer/components/view-select-content"
import { useBizQuery } from "@renderer/hooks"
import { apiClient } from "@renderer/lib/api-fetch"
import { client } from "@renderer/lib/client"
import { FeedViewType } from "@renderer/lib/enum"
import { Queries } from "@renderer/queries"
import { useFeed } from "@renderer/queries/feed"
import { useMutation } from "@tanstack/react-query"
import { useEffect } from "react"
import { useForm } from "react-hook-form"
import { toast } from "sonner"
import { z } from "zod"
const formSchema = z.object({
view: z.string(),
category: z.string().nullable().optional(),
isPrivate: z.boolean().optional(),
})
import { FeedForm } from "@renderer/modules/discover/feed-form"
import { useLayoutEffect } from "react"
export function Component() {
const urlSearchParams = new URLSearchParams(location.search)
@@ -45,186 +9,15 @@ export function Component() {
const id = urlSearchParams.get("id") || undefined
const defaultView = urlSearchParams.get("view") || FeedViewType.Articles
const feed = useFeed({
url,
id,
})
const isSubscribed = !!feed.data?.subscription
const form = useForm<z.infer<typeof formSchema>>({
resolver: zodResolver(formSchema),
defaultValues: {
view: defaultView.toString(),
},
})
useEffect(() => {
if (feed.data?.subscription) {
form.setValue("view", `${feed.data?.subscription?.view}`)
form.setValue("category", feed.data?.subscription?.category)
form.setValue("isPrivate", feed.data?.subscription?.isPrivate || false)
useLayoutEffect(() => {
document.body.style.overflow = "hidden"
return () => {
document.body.style.overflow = ""
}
}, [feed.data?.subscription])
const followMutation = useMutation({
mutationFn: async (values: z.infer<typeof formSchema>) => {
const body = {
url: feed.data?.feed.url,
view: Number.parseInt(values.view),
category: values.category,
isPrivate: values.isPrivate,
...(isSubscribed && { feedId: feed.data?.feed.id }),
}
const $method = isSubscribed ?
apiClient.subscriptions.$patch :
apiClient.subscriptions.$post
return $method({
// @ts-expect-error
json: body,
})
},
onSuccess: (_, variables) => {
if (
isSubscribed &&
variables.view !== `${feed.data?.subscription?.view}`
) {
Queries.subscription.byView(feed.data?.subscription?.view).invalidate()
client?.invalidateQuery(
Queries.subscription.byView(feed.data?.subscription?.view).key,
)
}
Queries.subscription.byView(Number.parseInt(variables.view)).invalidate()
client?.invalidateQuery(
Queries.subscription.byView(Number.parseInt(variables.view)).key,
)
const feedId = feed.data?.feed.id
if (feedId) {
Queries.feed.byId({ id: feedId }).invalidate()
client?.invalidateQuery(Queries.feed.byId({ id: feedId }).key)
}
toast(isSubscribed ? "🎉 Updated." : "🎉 Followed.", {
duration: 1000,
})
if (!isSubscribed) {
window.close()
}
},
})
function onSubmit(values: z.infer<typeof formSchema>) {
followMutation.mutate(values)
}
const categories = useBizQuery(
Queries.subscription.categories(Number.parseInt(form.watch("view"))),
)
}, [])
return (
<div className="flex h-full flex-col bg-background/90 px-[18px] pb-[18px] pt-12">
<div className="mb-4 mt-2 flex items-center gap-2 text-[22px] font-bold">
<img src="../icon.svg" alt="logo" className="size-8" />
Add follow
</div>
{feed.isLoading ? (
<div className="flex flex-1 items-center justify-center">
<LoadingCircle size="large" />
</div>
) : !feed.data?.feed ?
(
<div className="flex flex-1 flex-col items-center justify-center gap-2">
<p>Feed not found.</p>
<p>{url}</p>
</div>
) :
(
<div className="space-y-4">
<Card>
<CardHeader>
<FollowSummary feed={feed.data?.feed} />
</CardHeader>
</Card>
<Form {...form}>
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-4">
<FormField
control={form.control}
name="view"
render={({ field }) => (
<FormItem>
<FormLabel>View</FormLabel>
<Select onValueChange={field.onChange} value={field.value}>
<FormControl>
<SelectTrigger>
<SelectValue />
</SelectTrigger>
</FormControl>
<ViewSelectContent />
</Select>
<FormMessage />
</FormItem>
)}
/>
<FormField
control={form.control}
name="category"
render={({ field }) => (
<FormItem>
<div>
<FormLabel>Category</FormLabel>
<FormDescription>
By default, your follows will be grouped by website.
</FormDescription>
</div>
<FormControl>
<AutoComplete
options={categories.data || []}
emptyMessage="No results."
{...field}
/>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<FormField
control={form.control}
name="isPrivate"
render={({ field }) => (
<FormItem>
<div className="flex items-center justify-between">
<div>
<FormLabel>Private Follow</FormLabel>
<FormDescription>
Whether this follow is publicly visible on your
profile page.
</FormDescription>
</div>
<FormControl>
<Switch
className="shrink-0"
checked={field.value}
onCheckedChange={field.onChange}
/>
</FormControl>
</div>
</FormItem>
)}
/>
<div className="flex justify-end">
<Button
size="sm"
type="submit"
isLoading={followMutation.isPending}
>
{isSubscribed ? "Update" : "Follow"}
</Button>
</div>
</form>
</Form>
</div>
)}
<div className="h-full overflow-hidden bg-background">
<FeedForm url={url} id={id} defaultView={defaultView as FeedViewType} />
</div>
)
}
+2 -2
View File
@@ -1,9 +1,9 @@
import { ActionCard } from "@renderer/components/settings/action-card"
import { SettingsTitle } from "@renderer/components/settings/title"
import { Button } from "@renderer/components/ui/button"
import { useBizQuery } from "@renderer/hooks"
import { apiClient } from "@renderer/lib/api-fetch"
import type { ActionsResponse } from "@renderer/models"
import { ActionCard } from "@renderer/modules/settings/action-card"
import { SettingsTitle } from "@renderer/modules/settings/title"
import { Queries } from "@renderer/queries"
import { useMutation } from "@tanstack/react-query"
import { useEffect, useState } from "react"
+1 -1
View File
@@ -1,5 +1,5 @@
import { AppearanceSwitch } from "@renderer/components/appearance-switch"
import { SettingsTitle } from "@renderer/components/settings/title"
import { SettingsTitle } from "@renderer/modules/settings/title"
export function Component() {
return (
+4 -2
View File
@@ -1,6 +1,7 @@
import { SettingsTitle } from "@renderer/components/settings/title"
import { Logo } from "@renderer/components/icons/logo"
import { Vibrancy } from "@renderer/components/ui/background"
import { settingTabs } from "@renderer/lib/constants"
import { SettingsTitle } from "@renderer/modules/settings/title"
import { Link, Outlet, useLocation } from "react-router-dom"
export function Component() {
@@ -12,7 +13,8 @@ export function Component() {
<div className="flex flex-1">
<Vibrancy className="w-44 border-r px-2.5 py-3 pt-3.5">
<div className="mb-3 flex justify-end">
<img src="./icon.svg" alt="logo" className="size-6" />
<Logo className="size-6" />
</div>
{settingTabs.map((t) => (
<Link
+1 -1
View File
@@ -1,5 +1,4 @@
import { zodResolver } from "@hookform/resolvers/zod"
import { SettingsTitle } from "@renderer/components/settings/title"
import { Button } from "@renderer/components/ui/button"
import {
Form,
@@ -12,6 +11,7 @@ import {
} from "@renderer/components/ui/form"
import { Input } from "@renderer/components/ui/input"
import { apiClient } from "@renderer/lib/api-fetch"
import { SettingsTitle } from "@renderer/modules/settings/title"
import { useSession } from "@renderer/queries/auth"
import { useMutation } from "@tanstack/react-query"
import { useForm } from "react-hook-form"
+1 -1
View File
@@ -1,4 +1,4 @@
import { SettingsTitle } from "@renderer/components/settings/title"
import { SettingsTitle } from "@renderer/modules/settings/title"
export function Component() {
return (
+15 -1
View File
@@ -63,7 +63,21 @@ module.exports = {
},
theme: {
accent: "#FF5C00",
// https://uicolors.app/create
accent: {
DEFAULT: "#ff5c00",
50: "#fff7ec",
100: "#ffeed3",
200: "#ffd9a5",
300: "#ffbd6d",
400: "#ff9532",
500: "#ff760a",
600: "#ff5c00",
700: "#cc4102",
800: "#a1330b",
900: "#822c0c",
950: "#461304",
},
vibrancyFg: "var(--fo-vibrancy-foreground)",
vibrancyBg: "var(--fo-vibrancy-background)",