refactor(monorepo): migrate to monorepo (#1059)
* init Signed-off-by: Innei <i@innei.in> * chore: utils import Signed-off-by: Innei <tukon479@gmail.com> * remove stable router Signed-off-by: Innei <tukon479@gmail.com> * refactor: components import Signed-off-by: Innei <tukon479@gmail.com> * chore: auto-fix linting and formatting issues * minify Signed-off-by: Innei <tukon479@gmail.com> * update Signed-off-by: Innei <tukon479@gmail.com> * fix: test Signed-off-by: Innei <tukon479@gmail.com> * chore: ui component extract Signed-off-by: Innei <tukon479@gmail.com> * fix: import Signed-off-by: Innei <tukon479@gmail.com> * re-render Signed-off-by: Innei <tukon479@gmail.com> * refactor: remove hooks Signed-off-by: Innei <tukon479@gmail.com> * fix Signed-off-by: Innei <tukon479@gmail.com> * update Signed-off-by: Innei <tukon479@gmail.com> * setting Signed-off-by: Innei <tukon479@gmail.com> * update Signed-off-by: Innei <tukon479@gmail.com> * refactor: remove icons Signed-off-by: Innei <i@innei.in> * typings Signed-off-by: Innei <i@innei.in> * feat: add horizontal scroll functionality to TimelineTabs (#1081) Co-authored-by: xhuajin <xhuajin@users.noreply.github.com> Co-authored-by: Stephen Zhou <38493346+hyoban@users.noreply.github.com> * fix: Wrong initial position of tab animation (#1087) Co-authored-by: hamster1963 <hamster1963@users.noreply.github.com> * fix: disable auto toggle readability in web * fix: margin condition in EntryListHeader (#1103) * chore(i18n): add daily reward system translation (#1102) Co-authored-by: lc4t <lc4t@users.noreply.github.com> * fix: deps Signed-off-by: Innei <i@innei.in> * fix: type Signed-off-by: Innei <i@innei.in> * update Signed-off-by: Innei <i@innei.in> * fix Signed-off-by: Innei <i@innei.in> --------- Signed-off-by: Innei <i@innei.in> Signed-off-by: Innei <tukon479@gmail.com> Co-authored-by: Innei <Innei@users.noreply.github.com> Co-authored-by: Huajin <114134574+xhuajin@users.noreply.github.com> Co-authored-by: xhuajin <xhuajin@users.noreply.github.com> Co-authored-by: Stephen Zhou <38493346+hyoban@users.noreply.github.com> Co-authored-by: 仓鼠 <71394853+hamster1963@users.noreply.github.com> Co-authored-by: hamster1963 <hamster1963@users.noreply.github.com> Co-authored-by: Konv Suu <2583695112@qq.com> Co-authored-by: lc4t <11334449+lc4t@users.noreply.github.com> Co-authored-by: lc4t <lc4t@users.noreply.github.com>
This commit is contained in:
co-authored by
xhuajin
Stephen Zhou
hamster1963
lc4t
Innei
Huajin
仓鼠
Konv Suu
lc4t
parent
ee7d168ab4
commit
3a85febb6e
Vendored
+17
-5
@@ -54,13 +54,25 @@
|
||||
"rule": "unused-imports/no-unused-imports",
|
||||
"severity": "off"
|
||||
},
|
||||
{ "rule": "@typescript-eslint/require-await", "severity": "info" },
|
||||
{ "rule": "@typescript-eslint/await-thenable", "severity": "info" },
|
||||
{ "rule": "@typescript-eslint/no-floating-promises", "severity": "info" },
|
||||
{ "rule": "@typescript-eslint/no-misused-promises", "severity": "info" }
|
||||
{
|
||||
"rule": "@typescript-eslint/require-await",
|
||||
"severity": "info"
|
||||
},
|
||||
{
|
||||
"rule": "@typescript-eslint/await-thenable",
|
||||
"severity": "info"
|
||||
},
|
||||
{
|
||||
"rule": "@typescript-eslint/no-floating-promises",
|
||||
"severity": "info"
|
||||
},
|
||||
{
|
||||
"rule": "@typescript-eslint/no-misused-promises",
|
||||
"severity": "info"
|
||||
}
|
||||
],
|
||||
"cSpell.words": ["Hydable", "rsshub", "Русский"],
|
||||
"editor.foldingImportsByDefault": true,
|
||||
// "editor.foldingImportsByDefault": true,
|
||||
"commentTranslate.hover.enabled": false,
|
||||
"typescript.tsdk": "node_modules/typescript/lib",
|
||||
"i18n-ally.enabledFrameworks": ["i18next"],
|
||||
|
||||
@@ -30,8 +30,6 @@
|
||||
"@mozilla/readability": "^0.5.0",
|
||||
"@sentry/electron": "5.6.0",
|
||||
"builder-util-runtime": "9.2.10",
|
||||
"dayjs": "1.11.13",
|
||||
"dotenv": "16.4.5",
|
||||
"electron-context-menu": "4.0.4",
|
||||
"electron-log": "5.2.0",
|
||||
"electron-squirrel-startup": "1.0.1",
|
||||
@@ -39,10 +37,8 @@
|
||||
"font-list": "1.5.1",
|
||||
"i18next": "^23.16.0",
|
||||
"linkedom": "^0.18.5",
|
||||
"lodash-es": "4.17.21",
|
||||
"lowdb": "7.0.1",
|
||||
"msedge-tts": "1.3.4",
|
||||
"nanoid": "5.0.7",
|
||||
"ofetch": "1.4.1",
|
||||
"semver": "7.6.3",
|
||||
"vscode-languagedetection": "npm:@vscode/vscode-languagedetection@^1.0.22"
|
||||
|
||||
+10
-16
@@ -4,6 +4,7 @@
|
||||
"private": true,
|
||||
"main": "./dist/main/index.js",
|
||||
"scripts": {
|
||||
"dev": "cd ../.. && pnpm dev:web",
|
||||
"test": "vitest",
|
||||
"typecheck": "tsc --noEmit"
|
||||
},
|
||||
@@ -16,39 +17,28 @@
|
||||
"@headlessui/react": "2.1.10",
|
||||
"@hono/auth-js": "1.0.11",
|
||||
"@hookform/resolvers": "3.9.0",
|
||||
"@iconify/tools": "4.0.7",
|
||||
"@lottiefiles/dotlottie-react": "0.9.1",
|
||||
"@microflash/remark-callout-directives": "4.3.1",
|
||||
"@mozilla/readability": "^0.5.0",
|
||||
"@openpanel/web": "1.0.1",
|
||||
"@radix-ui/react-avatar": "1.1.1",
|
||||
"@radix-ui/react-checkbox": "1.1.2",
|
||||
"@radix-ui/react-context-menu": "2.2.2",
|
||||
"@radix-ui/react-dialog": "1.1.2",
|
||||
"@radix-ui/react-dropdown-menu": "2.1.2",
|
||||
"@radix-ui/react-hover-card": "1.1.2",
|
||||
"@radix-ui/react-label": "2.1.0",
|
||||
"@radix-ui/react-popover": "1.1.2",
|
||||
"@radix-ui/react-radio-group": "1.2.1",
|
||||
"@radix-ui/react-scroll-area": "1.2.0",
|
||||
"@radix-ui/react-select": "2.1.2",
|
||||
"@radix-ui/react-slider": "^1.2.1",
|
||||
"@radix-ui/react-slot": "1.1.0",
|
||||
"@radix-ui/react-switch": "1.1.1",
|
||||
"@radix-ui/react-tabs": "1.1.1",
|
||||
"@radix-ui/react-toast": "1.2.2",
|
||||
"@radix-ui/react-tooltip": "1.1.3",
|
||||
"@sentry/react": "8.34.0",
|
||||
"@shikijs/transformers": "1.22.0",
|
||||
"@t3-oss/env-core": "^0.11.1",
|
||||
"@tanstack/query-sync-storage-persister": "5.59.13",
|
||||
"@tanstack/react-query": "5.59.14",
|
||||
"@tanstack/react-query-devtools": "5.59.14",
|
||||
"@tanstack/react-query-persist-client": "5.59.14",
|
||||
"@use-gesture/react": "10.3.1",
|
||||
"@welldone-software/why-did-you-render": "8.0.3",
|
||||
"@yornaath/batshit": "0.10.1",
|
||||
"camelcase-keys": "9.1.3",
|
||||
"class-variance-authority": "0.7.0",
|
||||
"click-to-react-component": "1.1.0",
|
||||
"clsx": "2.1.1",
|
||||
"cmdk": "1.0.0",
|
||||
@@ -79,7 +69,7 @@
|
||||
"path-to-regexp": "8.2.0",
|
||||
"re-resizable": "6.10.0",
|
||||
"react-blurhash": "^0.3.0",
|
||||
"react-error-boundary": "4.0.13",
|
||||
"react-error-boundary": "4.1.2",
|
||||
"react-fast-marquee": "1.6.5",
|
||||
"react-hook-form": "7.53.0",
|
||||
"react-hotkeys-hook": "4.5.1",
|
||||
@@ -87,7 +77,6 @@
|
||||
"react-intersection-observer": "9.13.1",
|
||||
"react-resizable-layout": "npm:@innei/react-resizable-layout@0.7.3-fork.1",
|
||||
"react-router-dom": "6.27.0",
|
||||
"react-selecto": "1.26.3",
|
||||
"react-shadow": "20.5.0",
|
||||
"react-virtuoso": "4.12.0",
|
||||
"rehype-infer-description-meta": "2.0.0",
|
||||
@@ -102,8 +91,6 @@
|
||||
"shiki": "1.22.0",
|
||||
"sonner": "^1.5.0",
|
||||
"swiper": "11.1.14",
|
||||
"tailwind-merge": "2.5.4",
|
||||
"tailwindcss-motion": "0.3.0-beta",
|
||||
"tldts": "6.1.51",
|
||||
"unified": "11.0.5",
|
||||
"use-context-selector": "2.0.0",
|
||||
@@ -115,7 +102,14 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/generator": "7.25.7",
|
||||
"@follow/atoms": "workspace:*",
|
||||
"@follow/components": "workspace:*",
|
||||
"@follow/constants": "workspace:*",
|
||||
"@follow/hooks": "workspace:*",
|
||||
"@follow/models": "workspace:*",
|
||||
"@follow/shared": "workspace:*",
|
||||
"@follow/types": "workspace:*",
|
||||
"@follow/utils": "workspace:*",
|
||||
"@hono/node-server": "1.13.2",
|
||||
"@types/katex": "0.16.7",
|
||||
"@types/lodash-es": "4.17.12",
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { IN_ELECTRON } from "@follow/shared/constants"
|
||||
import { cn, getOS } from "@follow/utils/utils"
|
||||
import { useEffect, useLayoutEffect } from "react"
|
||||
import { Outlet } from "react-router-dom"
|
||||
|
||||
@@ -9,7 +10,6 @@ import { useUISettingKey } from "./atoms/settings/ui"
|
||||
import { navigateEntry } from "./hooks/biz/useNavigateEntry"
|
||||
import { applyAfterReadyCallbacks } from "./initialize/queue"
|
||||
import { appLog } from "./lib/log"
|
||||
import { cn, getOS } from "./lib/utils"
|
||||
import { Titlebar } from "./modules/app/Titlebar"
|
||||
import { RootProviders } from "./providers/root-providers"
|
||||
import { handlers } from "./tipc"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { Models } from "@follow/models"
|
||||
import camelcaseKeys from "camelcase-keys"
|
||||
|
||||
import { apiFetch } from "~/lib/api-fetch"
|
||||
import type { Models } from "~/models"
|
||||
|
||||
const v1ApiPrefix = "/v1"
|
||||
export const getTrendingAggregates = async () => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { getStorageNS } from "@follow/utils/ns"
|
||||
import { atomWithStorage } from "jotai/utils"
|
||||
|
||||
import { createAtomHooks } from "~/lib/jotai"
|
||||
import { getStorageNS } from "~/lib/ns"
|
||||
|
||||
type CornerPlayerAtomValue = {
|
||||
show: boolean
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
import type { ExtractAtomValue } from "jotai"
|
||||
import { useAtomValue } from "jotai"
|
||||
import { selectAtom } from "jotai/utils"
|
||||
import { useCallback } from "react"
|
||||
|
||||
import { jotaiStore } from "~/lib/jotai"
|
||||
|
||||
import { viewportAtom } from "../viewport"
|
||||
|
||||
export const useViewport = <T>(selector: (value: ExtractAtomValue<typeof viewportAtom>) => T): T =>
|
||||
useAtomValue(
|
||||
selectAtom(
|
||||
viewportAtom,
|
||||
useCallback((atomValue) => selector(atomValue), []),
|
||||
),
|
||||
)
|
||||
|
||||
export const useIsMobile = () =>
|
||||
useViewport(useCallback((v: ExtractAtomValue<typeof viewportAtom>) => isMobile(v), []))
|
||||
|
||||
const isMobile = (v: ExtractAtomValue<typeof viewportAtom>) => (v.sm || v.md || !v.sm) && !v.lg
|
||||
export const currentIsMobile = () => {
|
||||
const v = jotaiStore.get(viewportAtom)
|
||||
return isMobile(v)
|
||||
}
|
||||
|
||||
export const getViewport = () => jotaiStore.get(viewportAtom)
|
||||
@@ -1,10 +1,10 @@
|
||||
import { getStorageNS } from "@follow/utils/ns"
|
||||
import { noop } from "foxact/noop"
|
||||
import { atomWithStorage, createJSONStorage } from "jotai/utils"
|
||||
import type { SyncStorage } from "jotai/vanilla/utils/atomWithStorage"
|
||||
|
||||
import { getRouteParams } from "~/hooks/biz/useRouteParams"
|
||||
import { createAtomHooks } from "~/lib/jotai"
|
||||
import { getStorageNS } from "~/lib/ns"
|
||||
|
||||
type PlayerAtomValue = {
|
||||
show: boolean
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
import { atom, useAtomValue } from "jotai"
|
||||
import { selectAtom } from "jotai/utils"
|
||||
import { useMemo } from "react"
|
||||
import type { Location, NavigateFunction, Params } from "react-router-dom"
|
||||
|
||||
import { createAtomHooks } from "~/lib/jotai"
|
||||
|
||||
interface RouteAtom {
|
||||
params: Readonly<Params<string>>
|
||||
searchParams: URLSearchParams
|
||||
location: Location<any>
|
||||
}
|
||||
|
||||
export const [routeAtom, , , , getReadonlyRoute, setRoute] = createAtomHooks(
|
||||
atom<RouteAtom>({
|
||||
params: {},
|
||||
searchParams: new URLSearchParams(),
|
||||
|
||||
location: {
|
||||
pathname: "",
|
||||
search: "",
|
||||
hash: "",
|
||||
state: null,
|
||||
key: "",
|
||||
},
|
||||
}),
|
||||
)
|
||||
|
||||
const noop = []
|
||||
export const useReadonlyRouteSelector = <T>(
|
||||
selector: (route: RouteAtom) => T,
|
||||
deps: any[] = noop,
|
||||
): T => useAtomValue(useMemo(() => selectAtom(routeAtom, (route) => selector(route)), deps))
|
||||
|
||||
// Vite HMR will create new router instance, but RouterProvider always stable
|
||||
|
||||
const [, , , , navigate, setNavigate] = createAtomHooks(
|
||||
atom<{ fn: NavigateFunction | null }>({ fn() {} }),
|
||||
)
|
||||
const getStableRouterNavigate = () => navigate().fn
|
||||
export { getStableRouterNavigate, setNavigate }
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { ServerConfigs } from "@follow/models/types"
|
||||
import { atom } from "jotai"
|
||||
|
||||
import { createAtomHooks } from "~/lib/jotai"
|
||||
import type { ServerConfigs } from "~/models"
|
||||
|
||||
export const [, , useServerConfigs, , getServerConfigs, setServerConfigs] = createAtomHooks(
|
||||
atom<Nullable<ServerConfigs>>(null),
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import { createSettingAtom } from "@follow/atoms/helper/setting.js"
|
||||
import type { GeneralSettings } from "@follow/shared/interface/settings"
|
||||
|
||||
import { jotaiStore } from "~/lib/jotai"
|
||||
|
||||
import { createSettingAtom } from "./helper"
|
||||
|
||||
const createDefaultSettings = (): GeneralSettings => ({
|
||||
// App
|
||||
appLaunchOnStartup: false,
|
||||
|
||||
@@ -1,155 +0,0 @@
|
||||
import { useAtomValue } from "jotai"
|
||||
import { atomWithStorage, selectAtom } from "jotai/utils"
|
||||
import { useMemo } from "react"
|
||||
|
||||
import { useRefValue } from "~/hooks/common"
|
||||
import { EventBus } from "~/lib/event-bus"
|
||||
import { createAtomHooks } from "~/lib/jotai"
|
||||
import { getStorageNS } from "~/lib/ns"
|
||||
import type { SettingItem } from "~/modules/settings/setting-builder"
|
||||
import { createSettingBuilder } from "~/modules/settings/setting-builder"
|
||||
|
||||
declare module "~/lib/event-bus" {
|
||||
interface CustomEvent {
|
||||
SETTING_CHANGE_EVENT: {
|
||||
updated: number
|
||||
payload: Record<string, any>
|
||||
key: string
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export const createSettingAtom = <T extends object>(
|
||||
settingKey: string,
|
||||
createDefaultSettings: () => T,
|
||||
) => {
|
||||
const atom = atomWithStorage(getStorageNS(settingKey), createDefaultSettings(), undefined, {
|
||||
getOnInit: true,
|
||||
})
|
||||
|
||||
const [, , useSettingValue, , getSettings, setSettings] = createAtomHooks(atom)
|
||||
|
||||
const initializeDefaultSettings = () => {
|
||||
const currentSettings = getSettings()
|
||||
const defaultSettings = createDefaultSettings()
|
||||
if (typeof currentSettings !== "object") setSettings(defaultSettings)
|
||||
const newSettings = { ...defaultSettings, ...currentSettings }
|
||||
setSettings(newSettings)
|
||||
}
|
||||
|
||||
const selectAtomCacheMap = {} as Record<keyof ReturnType<typeof getSettings>, any>
|
||||
|
||||
const useSettingKey = <T extends keyof ReturnType<typeof getSettings>>(key: T) => {
|
||||
let selectedAtom = selectAtomCacheMap[key]
|
||||
if (!selectedAtom) {
|
||||
selectedAtom = selectAtom(atom, (s) => s[key])
|
||||
selectAtomCacheMap[key] = selectedAtom
|
||||
}
|
||||
|
||||
return useAtomValue(selectedAtom) as ReturnType<typeof getSettings>[T]
|
||||
}
|
||||
|
||||
const useSettingSelector = <
|
||||
T extends keyof ReturnType<typeof getSettings>,
|
||||
S extends ReturnType<typeof getSettings>,
|
||||
R = S[T],
|
||||
>(
|
||||
selector: (s: S) => R,
|
||||
): R => {
|
||||
const stableSelector = useRefValue(selector)
|
||||
|
||||
return useAtomValue(
|
||||
// @ts-expect-error
|
||||
useMemo(() => selectAtom(atom, stableSelector.current), [stableSelector]),
|
||||
)
|
||||
}
|
||||
|
||||
const setSetting = <K extends keyof ReturnType<typeof getSettings>>(
|
||||
key: K,
|
||||
value: ReturnType<typeof getSettings>[K],
|
||||
) => {
|
||||
const updated = Date.now()
|
||||
setSettings({
|
||||
...getSettings(),
|
||||
[key]: value,
|
||||
|
||||
updated,
|
||||
})
|
||||
|
||||
EventBus.dispatch("SETTING_CHANGE_EVENT", {
|
||||
payload: { [key]: value },
|
||||
updated,
|
||||
key: settingKey,
|
||||
})
|
||||
}
|
||||
|
||||
const clearSettings = () => {
|
||||
setSettings(createDefaultSettings())
|
||||
}
|
||||
|
||||
Object.defineProperty(useSettingValue, "select", {
|
||||
value: useSettingSelector,
|
||||
})
|
||||
|
||||
return {
|
||||
useSettingKey,
|
||||
useSettingSelector,
|
||||
setSetting,
|
||||
clearSettings,
|
||||
initializeDefaultSettings,
|
||||
|
||||
useSettingValue,
|
||||
getSettings,
|
||||
|
||||
settingAtom: atom,
|
||||
} as {
|
||||
useSettingKey: typeof useSettingKey
|
||||
useSettingSelector: typeof useSettingSelector
|
||||
setSetting: typeof setSetting
|
||||
clearSettings: typeof clearSettings
|
||||
initializeDefaultSettings: typeof initializeDefaultSettings
|
||||
useSettingValue: typeof useSettingValue & {
|
||||
select: <T extends keyof ReturnType<() => T>>(key: T) => Awaited<T[T]>
|
||||
}
|
||||
getSettings: typeof getSettings
|
||||
settingAtom: typeof atom
|
||||
}
|
||||
}
|
||||
|
||||
export const createDefineSettingItem =
|
||||
<T>(_getSetting: () => T, setSetting: (key: any, value: Partial<T>) => void) =>
|
||||
<K extends keyof T>(
|
||||
key: K,
|
||||
options: {
|
||||
label: string
|
||||
description?: string | JSX.Element
|
||||
onChange?: (value: T[K]) => void
|
||||
hide?: boolean
|
||||
} & Omit<SettingItem<any>, "onChange" | "description" | "label" | "hide" | "key">,
|
||||
): any => {
|
||||
const { label, description, onChange, hide, ...rest } = options
|
||||
|
||||
return {
|
||||
key,
|
||||
label,
|
||||
description,
|
||||
onChange: (value: any) => {
|
||||
if (onChange) return onChange(value as any)
|
||||
setSetting(key, value as any)
|
||||
},
|
||||
disabled: hide,
|
||||
...rest,
|
||||
} as SettingItem<any>
|
||||
}
|
||||
|
||||
export const createSetting = <T extends object>(
|
||||
useSetting: () => T,
|
||||
setSetting: (key: any, value: Partial<T>) => void,
|
||||
) => {
|
||||
const SettingBuilder = createSettingBuilder(useSetting)
|
||||
const defineSettingItem = createDefineSettingItem(useSetting, setSetting)
|
||||
return {
|
||||
SettingBuilder,
|
||||
defineSettingItem,
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
import { createSettingAtom } from "@follow/atoms/helper/setting.js"
|
||||
import type { IntegrationSettings } from "@follow/shared/interface/settings"
|
||||
|
||||
import { createSettingAtom } from "./helper"
|
||||
|
||||
export const createDefaultSettings = (): IntegrationSettings => ({
|
||||
// eagle
|
||||
enableEagle: true,
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { createSettingAtom } from "@follow/atoms/helper/setting.js"
|
||||
import type { UISettings } from "@follow/shared/interface/settings"
|
||||
|
||||
import { createSettingAtom } from "./helper"
|
||||
|
||||
export const createDefaultSettings = (): UISettings => ({
|
||||
// Sidebar
|
||||
entryColWidth: 356,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { FeedViewType } from "@follow/constants"
|
||||
import { atom } from "jotai"
|
||||
|
||||
import { getRouteParams } from "~/hooks/biz/useRouteParams"
|
||||
import { FeedViewType } from "~/lib/enum"
|
||||
import { createAtomHooks } from "~/lib/jotai"
|
||||
|
||||
const defaultFeedView = FeedViewType.Articles
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { getStorageNS } from "@follow/utils/ns"
|
||||
import { atomWithStorage } from "jotai/utils"
|
||||
|
||||
import { createAtomHooks } from "~/lib/jotai"
|
||||
import { getStorageNS } from "~/lib/ns"
|
||||
|
||||
export const [, , useUpdaterStatus, , , setUpdaterStatus] = createAtomHooks(
|
||||
atomWithStorage(getStorageNS("updater"), false, undefined, {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { User } from "@auth/core/types"
|
||||
import type { UserRole } from "@follow/constants"
|
||||
import { atom } from "jotai"
|
||||
|
||||
import type { UserRole } from "~/lib/enum"
|
||||
import { createAtomHooks } from "~/lib/jotai"
|
||||
|
||||
export const [, , useWhoami, , whoami, setWhoami] = createAtomHooks(atom<Nullable<User>>(null))
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
import { atom } from "jotai"
|
||||
|
||||
export const viewportAtom = atom({
|
||||
/**
|
||||
* 640px
|
||||
*/
|
||||
sm: false,
|
||||
|
||||
/**
|
||||
* 768px
|
||||
*/
|
||||
md: false,
|
||||
|
||||
/**
|
||||
* 1024px
|
||||
*/
|
||||
lg: false,
|
||||
|
||||
/**
|
||||
* 1280px
|
||||
*/
|
||||
xl: false,
|
||||
|
||||
/**
|
||||
* 1536px
|
||||
*/
|
||||
"2xl": false,
|
||||
|
||||
h: 0,
|
||||
w: 0,
|
||||
})
|
||||
@@ -1,3 +1,4 @@
|
||||
import { Button } from "@follow/components/ui/button/index.js"
|
||||
import { captureException } from "@sentry/react"
|
||||
import { useEffect, useRef } from "react"
|
||||
import { isRouteErrorResponse, useNavigate, useRouteError } from "react-router-dom"
|
||||
@@ -7,7 +8,6 @@ import { attachOpenInEditor } from "~/lib/dev"
|
||||
import { getNewIssueUrl } from "~/lib/issues"
|
||||
import { clearLocalPersistStoreData } from "~/store/utils/clear"
|
||||
|
||||
import { Button } from "../ui/button"
|
||||
import { PoweredByFooter } from "./PoweredByFooter"
|
||||
|
||||
export function ErrorElement() {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { LoadingCircle } from "@follow/components/ui/loading/index.jsx"
|
||||
import { useInView } from "react-intersection-observer"
|
||||
|
||||
import { LoadingCircle } from "../ui/loading"
|
||||
|
||||
export const LoadMoreIndicator: Component<{
|
||||
onLoading: () => void
|
||||
}> = ({ onLoading, children, className }) => {
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import { LoadingCircle } from "@follow/components/ui/loading/index.jsx"
|
||||
import type { FC, ReactNode } from "react"
|
||||
import { createElement, useEffect, useState } from "react"
|
||||
|
||||
import { LoadingCircle } from "../ui/loading"
|
||||
|
||||
export const LoadRemixAsyncComponent: FC<{
|
||||
loader: () => Promise<any>
|
||||
Header: FC<{ loader: () => any; [key: string]: any }>
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
import type { FC } from "react"
|
||||
import { memo, useMemo } from "react"
|
||||
|
||||
export const MemoedDangerousHTMLStyle: FC<
|
||||
{
|
||||
children: string
|
||||
} & React.DetailedHTMLProps<React.StyleHTMLAttributes<HTMLStyleElement>, HTMLStyleElement> &
|
||||
Record<string, unknown>
|
||||
> = memo(({ children, ...rest }) => (
|
||||
<style
|
||||
{...rest}
|
||||
dangerouslySetInnerHTML={useMemo(
|
||||
() => ({
|
||||
__html: children,
|
||||
}),
|
||||
[children],
|
||||
)}
|
||||
/>
|
||||
))
|
||||
@@ -1,3 +1,5 @@
|
||||
import { Logo } from "@follow/components/icons/logo.jsx"
|
||||
import { Button } from "@follow/components/ui/button/index.js"
|
||||
import { captureException } from "@sentry/react"
|
||||
import { useEffect } from "react"
|
||||
import type { Location } from "react-router-dom"
|
||||
@@ -5,8 +7,6 @@ import { useLocation, useNavigate } from "react-router-dom"
|
||||
|
||||
import { isElectronBuild } from "~/constants"
|
||||
|
||||
import { Logo } from "../icons/logo"
|
||||
import { Button } from "../ui/button"
|
||||
import { PoweredByFooter } from "./PoweredByFooter"
|
||||
|
||||
class AccessNotFoundError extends Error {
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import { Logo } from "@follow/components/icons/logo.jsx"
|
||||
import { cn } from "@follow/utils/utils"
|
||||
import pkg from "@pkg"
|
||||
|
||||
import { cn } from "~/lib/utils"
|
||||
|
||||
import { Logo } from "../icons/logo"
|
||||
|
||||
export const PoweredByFooter: Component = ({ className }) => (
|
||||
<footer className={cn("center mt-12 flex gap-2", className)}>
|
||||
Powered by <Logo className="size-5" />{" "}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { MemoedDangerousHTMLStyle } from "@follow/components/common/MemoedDangerousHTMLStyle.js"
|
||||
import { useIsDark } from "@follow/hooks"
|
||||
import { nanoid } from "nanoid"
|
||||
import type { FC, PropsWithChildren, ReactNode } from "react"
|
||||
import { createContext, createElement, useContext, useLayoutEffect, useMemo, useState } from "react"
|
||||
@@ -5,9 +7,6 @@ import root from "react-shadow"
|
||||
|
||||
import { useUISettingKey } from "~/atoms/settings/ui"
|
||||
import { useReduceMotion } from "~/hooks/biz/useReduceMotion"
|
||||
import { useIsDark } from "~/hooks/common"
|
||||
|
||||
import { MemoedDangerousHTMLStyle } from "./MemoedDangerousHTMLStyle"
|
||||
|
||||
const ShadowDOMContext = createContext(false)
|
||||
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
import { Button } from "@follow/components/ui/button/index.js"
|
||||
import type { FeedModel } from "@follow/models/types"
|
||||
import { nextFrame } from "@follow/utils/dom"
|
||||
import type { FC } from "react"
|
||||
import { useNavigate } from "react-router-dom"
|
||||
|
||||
import { getSidebarActiveView } from "~/atoms/sidebar"
|
||||
import { getRouteParams } from "~/hooks/biz/useRouteParams"
|
||||
import { nextFrame } from "~/lib/dom"
|
||||
import type { FeedModel } from "~/models"
|
||||
import { FeedForm } from "~/modules/discover/feed-form"
|
||||
import { entries } from "~/queries/entries"
|
||||
|
||||
import type { AppErrorFallbackProps } from "../common/AppErrorBoundary"
|
||||
import { Button } from "../ui/button"
|
||||
import { useModalStack } from "../ui/modal"
|
||||
import { CustomSafeError, useResetErrorWhenRouteChange } from "./helper"
|
||||
import { FeedPreview } from "./previews/FeedPreview"
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { Logo } from "@follow/components/icons/logo.jsx"
|
||||
import { Button } from "@follow/components/ui/button/index.js"
|
||||
import type { FC } from "react"
|
||||
import { useNavigate } from "react-router-dom"
|
||||
|
||||
import type { AppErrorFallbackProps } from "../common/AppErrorBoundary"
|
||||
import { Logo } from "../icons/logo"
|
||||
import { Button } from "../ui/button"
|
||||
import { CustomSafeError, useResetErrorWhenRouteChange } from "./helper"
|
||||
|
||||
const FeedNotFoundErrorFallback: FC<AppErrorFallbackProps> = ({ resetError, error }) => {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { Button } from "@follow/components/ui/button/index.js"
|
||||
import type { FC } from "react"
|
||||
|
||||
import { attachOpenInEditor } from "~/lib/dev"
|
||||
@@ -5,7 +6,6 @@ import { attachOpenInEditor } from "~/lib/dev"
|
||||
import type { AppErrorFallbackProps } from "../common/AppErrorBoundary"
|
||||
import { FeedbackIssue } from "../common/ErrorElement"
|
||||
import { m } from "../common/Motion"
|
||||
import { Button } from "../ui/button"
|
||||
import { useCurrentModal } from "../ui/modal"
|
||||
import { parseError } from "./helper"
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { Button } from "@follow/components/ui/button/index.js"
|
||||
import type { FC } from "react"
|
||||
|
||||
import { attachOpenInEditor } from "~/lib/dev"
|
||||
|
||||
import type { AppErrorFallbackProps } from "../common/AppErrorBoundary"
|
||||
import { FeedbackIssue } from "../common/ErrorElement"
|
||||
import { Button } from "../ui/button"
|
||||
import { parseError, useResetErrorWhenRouteChange } from "./helper"
|
||||
|
||||
const PageErrorFallback: FC<AppErrorFallbackProps> = (props) => {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { nextFrame } from "@follow/utils/dom"
|
||||
import type { FC } from "react"
|
||||
import { createElement, useEffect, useRef } from "react"
|
||||
import { useLocation } from "react-router-dom"
|
||||
|
||||
import { nextFrame } from "~/lib/dom"
|
||||
import { createErrorToaster } from "~/lib/error-parser"
|
||||
|
||||
import type { AppErrorFallbackProps } from "../common/AppErrorBoundary"
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
import { LoadingCircle } from "@follow/components/ui/loading/index.jsx"
|
||||
import type { FeedViewType } from "@follow/constants"
|
||||
import { views } from "@follow/constants"
|
||||
import type { FeedModel } from "@follow/models/types"
|
||||
import { cn } from "@follow/utils/utils"
|
||||
import type { FC } from "react"
|
||||
import { useTranslation } from "react-i18next"
|
||||
import { useSearchParams } from "react-router-dom"
|
||||
|
||||
import { FeedCertification } from "~/components/feed-certification"
|
||||
import { FeedIcon } from "~/components/feed-icon"
|
||||
import { LoadingCircle } from "~/components/ui/loading"
|
||||
import { views } from "~/constants"
|
||||
import type { FeedViewType } from "~/lib/enum"
|
||||
import { cn } from "~/lib/utils"
|
||||
import type { FeedModel } from "~/models"
|
||||
import { getItemComponentByView } from "~/modules/entry-column/Items"
|
||||
import type { UniversalItemProps } from "~/modules/entry-column/types"
|
||||
import { FeedCertification } from "~/modules/feed/feed-certification"
|
||||
import { FeedIcon } from "~/modules/feed/feed-icon"
|
||||
import { useEntriesPreview } from "~/queries/entries"
|
||||
import { useFeed } from "~/queries/feed"
|
||||
|
||||
|
||||
@@ -1,95 +0,0 @@
|
||||
import type { MotionValue } from "framer-motion"
|
||||
import { useMotionValueEvent, useScroll } from "framer-motion"
|
||||
import type { FC } from "react"
|
||||
import { cloneElement, useState } from "react"
|
||||
import { useTranslation } from "react-i18next"
|
||||
import { Link } from "react-router-dom"
|
||||
|
||||
import { whoami } from "~/atoms/user"
|
||||
import { cn } from "~/lib/utils"
|
||||
import { usePresentUserProfileModal } from "~/modules/profile/hooks"
|
||||
|
||||
import { UserAvatar } from "../modules/user/UserAvatar"
|
||||
import { FollowIcon } from "./icons/follow"
|
||||
import { Logo } from "./icons/logo"
|
||||
|
||||
const useMotionValueToState = (value: MotionValue<number>) => {
|
||||
const [state, setState] = useState(value.get())
|
||||
useMotionValueEvent(value, "change", (v) => setState(v))
|
||||
return state
|
||||
}
|
||||
|
||||
export function Header() {
|
||||
const present = usePresentUserProfileModal()
|
||||
const { t } = useTranslation("external")
|
||||
|
||||
const { scrollY } = useScroll()
|
||||
const scrollYState = useMotionValueToState(scrollY)
|
||||
|
||||
return (
|
||||
<header className="fixed inset-x-0 top-0 z-[99] px-5 py-2 xl:px-0">
|
||||
<div className="relative mx-auto my-4 flex w-full max-w-[1240px] items-center justify-between">
|
||||
<div
|
||||
className="absolute inset-0 z-0 -mx-3 -my-2 rounded-full bg-slate-50/80 backdrop-blur-lg dark:bg-neutral-900/80 xl:-mx-8"
|
||||
style={{
|
||||
opacity: scrollYState / 100,
|
||||
}}
|
||||
/>
|
||||
|
||||
<div className="relative z-10 flex w-full items-center justify-between gap-8 px-3">
|
||||
<div className="flex grow items-center gap-8">
|
||||
<div className="flex items-center gap-2 text-xl font-bold">
|
||||
<Logo className="size-8" />
|
||||
</div>
|
||||
|
||||
<div className="mx-6 hidden gap-12 text-sm font-medium lg:flex [&>div]:hover:cursor-pointer">
|
||||
<HoverableLink
|
||||
href="/"
|
||||
icon={<FollowIcon className="!size-3" />}
|
||||
label={t("header.app")}
|
||||
/>
|
||||
|
||||
<HoverableLink
|
||||
href="https://github.com/RSSNext/follow/releases"
|
||||
icon={<i className="i-mgc-download-2-cute-fi" />}
|
||||
label={t("header.download")}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<button
|
||||
className="cursor-pointer"
|
||||
type="button"
|
||||
onClick={() => {
|
||||
present(whoami()?.id)
|
||||
}}
|
||||
>
|
||||
<UserAvatar className="h-10 bg-transparent p-0" hideName />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
)
|
||||
}
|
||||
|
||||
const HoverableLink: FC<{
|
||||
label: string
|
||||
icon: React.JSX.Element
|
||||
href: string
|
||||
className?: string
|
||||
}> = ({ icon, label, href, className }) => (
|
||||
<Link
|
||||
to={href}
|
||||
target={href.startsWith("http") ? "_blank" : undefined}
|
||||
className={cn("group center flex gap-3 duration-200 hover:text-accent", className)}
|
||||
>
|
||||
<span className="center">
|
||||
{cloneElement(icon, { className: `size-4 ${icon.props.className}` })}
|
||||
</span>
|
||||
<span className="inline-flex h-[1.5em] flex-col overflow-hidden leading-[1.5em]">
|
||||
<span className="inline-flex flex-col gap-2 duration-200 group-hover:translate-y-[calc(-50%-0.25em)]">
|
||||
<span>{label}</span>
|
||||
<span>{label}</span>
|
||||
</span>
|
||||
</span>
|
||||
</Link>
|
||||
)
|
||||
@@ -1,78 +0,0 @@
|
||||
import type { SVGProps } from "react"
|
||||
|
||||
export function MdiLanguageTypescript(props: SVGProps<SVGSVGElement>) {
|
||||
return (
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24" {...props}>
|
||||
<path
|
||||
fill="currentColor"
|
||||
d="M3 3h18v18H3zm10.71 14.86c.5.98 1.51 1.73 3.09 1.73c1.6 0 2.8-.83 2.8-2.36c0-1.41-.81-2.04-2.25-2.66l-.42-.18c-.73-.31-1.04-.52-1.04-1.02c0-.41.31-.73.81-.73c.48 0 .8.21 1.09.73l1.31-.87c-.55-.96-1.33-1.33-2.4-1.33c-1.51 0-2.48.96-2.48 2.23c0 1.38.81 2.03 2.03 2.55l.42.18c.78.34 1.24.55 1.24 1.13c0 .48-.45.83-1.15.83c-.83 0-1.31-.43-1.67-1.03zM13 11.25H8v1.5h1.5V20h1.75v-7.25H13z"
|
||||
/>
|
||||
</svg>
|
||||
)
|
||||
}
|
||||
|
||||
export function UilReact(props: SVGProps<SVGSVGElement>) {
|
||||
return (
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24" {...props}>
|
||||
<path
|
||||
fill="currentColor"
|
||||
d="M11.103 10.438a1.786 1.786 0 1 0 2.44.654a1.786 1.786 0 0 0-2.44-.654m8.005 1.938q-.176-.201-.371-.403q.136-.144.264-.287c1.605-1.804 2.283-3.614 1.655-4.701c-.602-1.043-2.393-1.354-4.636-.918q-.331.065-.659.146q-.063-.216-.133-.43C14.467 3.49 13.238 1.999 11.982 2c-1.204 0-2.368 1.397-3.111 3.558q-.11.32-.203.644q-.219-.054-.44-.1c-2.366-.485-4.271-.165-4.898.924c-.601 1.043.027 2.75 1.528 4.472q.224.255.46.5c-.186.19-.361.381-.525.571c-1.465 1.698-2.057 3.376-1.457 4.415c.62 1.074 2.498 1.425 4.785.975q.278-.055.553-.124q.1.351.221.697C9.635 20.649 10.792 22 11.992 22c1.24 0 2.482-1.453 3.235-3.659c.06-.174.115-.355.169-.541q.355.088.715.156c2.203.417 3.952.09 4.551-.95c.619-1.075-.02-2.877-1.554-4.63M4.07 7.452c.386-.67 1.943-.932 3.986-.512q.196.04.399.09a20.464 20.464 0 0 0-.422 2.678A20.887 20.887 0 0 0 5.93 11.4q-.219-.227-.427-.465C4.216 9.461 3.708 8.081 4.07 7.452m3.887 5.728c-.51-.387-.985-.783-1.416-1.181c.43-.396.905-.79 1.415-1.176q-.028.589-.027 1.179q0 .59.028 1.178m0 3.94a7.237 7.237 0 0 1-2.64.094a1.766 1.766 0 0 1-1.241-.657c-.365-.63.111-1.978 1.364-3.43q.236-.273.488-.532a20.49 20.49 0 0 0 2.107 1.7a20.802 20.802 0 0 0 .426 2.712q-.25.063-.505.114m7.1-8.039q-.503-.317-1.018-.613q-.508-.292-1.027-.563a18.7 18.7 0 0 1 1.739-.635a18.218 18.218 0 0 1 .306 1.811M9.68 5.835c.636-1.85 1.578-2.98 2.304-2.98c.773-.001 1.777 1.218 2.434 3.197q.064.194.12.39a20.478 20.478 0 0 0-2.526.97a20.061 20.061 0 0 0-2.52-.981q.087-.3.188-.596m-.4 1.424a18.307 18.307 0 0 1 1.73.642q-1.052.542-2.048 1.181c.08-.638.187-1.249.318-1.823m-.317 7.66q.497.319 1.009.613q.522.3 1.057.576a18.196 18.196 0 0 1-1.744.665a19.144 19.144 0 0 1-.322-1.853m5.456 3.146a7.236 7.236 0 0 1-1.238 2.333a1.766 1.766 0 0 1-1.188.748c-.729 0-1.658-1.085-2.29-2.896q-.112-.321-.206-.648a20.109 20.109 0 0 0 2.53-1.01a20.8 20.8 0 0 0 2.547.979q-.072.249-.155.494m.362-1.324a19.267 19.267 0 0 1-1.762-.646q.509-.267 1.025-.565q.53-.306 1.032-.627a18.152 18.152 0 0 1-.295 1.838m.447-4.743q0 .911-.057 1.82c-.493.334-1.013.66-1.554.972c-.54.311-1.073.597-1.597.856q-.827-.396-1.622-.854q-.79-.455-1.544-.969q-.07-.91-.07-1.822q0-.911.068-1.821a24.168 24.168 0 0 1 3.158-1.823q.816.397 1.603.851q.79.454 1.55.959q.065.914.065 1.831m.956-5.093c1.922-.373 3.37-.122 3.733.507c.387.67-.167 2.148-1.554 3.706q-.115.129-.238.259a20.061 20.061 0 0 0-2.144-1.688a20.04 20.04 0 0 0-.405-2.649q.31-.076.608-.135m-.13 3.885a18.164 18.164 0 0 1 1.462 1.188a18.12 18.12 0 0 1-1.457 1.208q.023-.594.023-1.188q0-.604-.028-1.208m3.869 5.789c-.364.631-1.768.894-3.653.538q-.324-.061-.664-.146a20.069 20.069 0 0 0 .387-2.682a19.94 19.94 0 0 0 2.137-1.715q.177.183.336.364a7.234 7.234 0 0 1 1.403 2.238a1.766 1.766 0 0 1 .054 1.403"
|
||||
/>
|
||||
</svg>
|
||||
)
|
||||
}
|
||||
|
||||
export function MdiLanguageJavascript(props: SVGProps<SVGSVGElement>) {
|
||||
return (
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24" {...props}>
|
||||
<path
|
||||
fill="currentColor"
|
||||
d="M3 3h18v18H3zm4.73 15.04c.4.85 1.19 1.55 2.54 1.55c1.5 0 2.53-.8 2.53-2.55v-5.78h-1.7V17c0 .86-.35 1.08-.9 1.08c-.58 0-.82-.4-1.09-.87zm5.98-.18c.5.98 1.51 1.73 3.09 1.73c1.6 0 2.8-.83 2.8-2.36c0-1.41-.81-2.04-2.25-2.66l-.42-.18c-.73-.31-1.04-.52-1.04-1.02c0-.41.31-.73.81-.73c.48 0 .8.21 1.09.73l1.31-.87c-.55-.96-1.33-1.33-2.4-1.33c-1.51 0-2.48.96-2.48 2.23c0 1.38.81 2.03 2.03 2.55l.42.18c.78.34 1.24.55 1.24 1.13c0 .48-.45.83-1.15.83c-.83 0-1.31-.43-1.67-1.03z"
|
||||
/>
|
||||
</svg>
|
||||
)
|
||||
}
|
||||
|
||||
export function MdiBash(props: SVGProps<SVGSVGElement>) {
|
||||
return (
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24" {...props}>
|
||||
<path
|
||||
fill="currentColor"
|
||||
d="M5 9h2.31l.32-3h2l-.32 3h2l.32-3h2l-.32 3H15v2h-1.9l-.2 2H15v2h-2.31l-.32 3h-2l.32-3h-2l-.32 3h-2l.32-3H5v-2h1.9l.2-2H5zm4.1 2l-.2 2h2l.2-2M19 6h-2v8h2m0 2h-2v2h2Z"
|
||||
/>
|
||||
</svg>
|
||||
)
|
||||
}
|
||||
|
||||
export function MdiLanguageCss3(props: SVGProps<SVGSVGElement>) {
|
||||
return (
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24" {...props}>
|
||||
<path
|
||||
fill="currentColor"
|
||||
d="m5 3l-.65 3.34h13.59L17.5 8.5H3.92l-.66 3.33h13.59l-.76 3.81l-5.48 1.81l-4.75-1.81l.33-1.64H2.85l-.79 4l7.85 3l9.05-3l1.2-6.03l.24-1.21L21.94 3z"
|
||||
/>
|
||||
</svg>
|
||||
)
|
||||
}
|
||||
|
||||
export function MdiLanguageHtml5(props: SVGProps<SVGSVGElement>) {
|
||||
return (
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24" {...props}>
|
||||
<path
|
||||
fill="currentColor"
|
||||
d="m12 17.56l4.07-1.13l.55-6.1H9.38L9.2 8.3h7.6l.2-1.99H7l.56 6.01h6.89l-.23 2.58l-2.22.6l-2.22-.6l-.14-1.66h-2l.29 3.19zM4.07 3h15.86L18.5 19.2L12 21l-6.5-1.8z"
|
||||
/>
|
||||
</svg>
|
||||
)
|
||||
}
|
||||
|
||||
export function RiMarkdownFill(props: SVGProps<SVGSVGElement>) {
|
||||
return (
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24" {...props}>
|
||||
<path
|
||||
fill="currentColor"
|
||||
d="M3 3h18a1 1 0 0 1 1 1v16a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1m4 12.5v-4l2 2l2-2v4h2v-7h-2l-2 2l-2-2H5v7zm11-3v-4h-2v4h-2l3 3l3-3z"
|
||||
/>
|
||||
</svg>
|
||||
)
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
import type { SVGProps } from "react"
|
||||
|
||||
export function OouiUserAnonymous(props: SVGProps<SVGSVGElement>) {
|
||||
return (
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 20 20" {...props}>
|
||||
<path fill="currentColor" d="M15 2H5L4 8h12zM0 10s2 1 10 1s10-1 10-1l-4-2H4zm8 4h4v1H8z" />
|
||||
<circle cx="6" cy="15" r="3" fill="currentColor" />
|
||||
<circle cx="14" cy="15" r="3" fill="currentColor" />
|
||||
</svg>
|
||||
)
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
import type { SVGProps } from "react"
|
||||
|
||||
export function PhCloudCheck(props: SVGProps<SVGSVGElement>) {
|
||||
return (
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="1em"
|
||||
height="1em"
|
||||
viewBox="0 0 256 256"
|
||||
{...props}
|
||||
>
|
||||
<path
|
||||
fill="currentColor"
|
||||
d="M160 40a88.09 88.09 0 0 0-78.71 48.67A64 64 0 1 0 72 216h88a88 88 0 0 0 0-176m0 160H72a48 48 0 0 1 0-96c1.1 0 2.2 0 3.29.11A88 88 0 0 0 72 128a8 8 0 0 0 16 0a72 72 0 1 1 72 72m37.66-93.66a8 8 0 0 1 0 11.32l-48 48a8 8 0 0 1-11.32 0l-24-24a8 8 0 0 1 11.32-11.32L144 148.69l42.34-42.35a8 8 0 0 1 11.32 0"
|
||||
/>
|
||||
</svg>
|
||||
)
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
import type { SVGProps } from "react"
|
||||
|
||||
export function PhCloudWarning(props: SVGProps<SVGSVGElement>) {
|
||||
return (
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="1em"
|
||||
height="1em"
|
||||
viewBox="0 0 256 256"
|
||||
{...props}
|
||||
>
|
||||
<path
|
||||
fill="currentColor"
|
||||
d="M160 40a88.09 88.09 0 0 0-78.71 48.67A64 64 0 1 0 72 216h88a88 88 0 0 0 0-176m0 160H72a48 48 0 0 1 0-96c1.1 0 2.2 0 3.29.11A88 88 0 0 0 72 128a8 8 0 0 0 16 0a72 72 0 1 1 72 72m-8-72V88a8 8 0 0 1 16 0v40a8 8 0 0 1-16 0m20 36a12 12 0 1 1-12-12a12 12 0 0 1 12 12"
|
||||
/>
|
||||
</svg>
|
||||
)
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
import type { SVGProps } from "react"
|
||||
|
||||
export function PhCloudX(props: SVGProps<SVGSVGElement>) {
|
||||
return (
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="1em"
|
||||
height="1em"
|
||||
viewBox="0 0 256 256"
|
||||
{...props}
|
||||
>
|
||||
<path
|
||||
fill="currentColor"
|
||||
d="M160 40a88.09 88.09 0 0 0-78.71 48.67A64 64 0 1 0 72 216h88a88 88 0 0 0 0-176m0 160H72a48 48 0 0 1 0-96c1.1 0 2.2 0 3.29.11A88 88 0 0 0 72 128a8 8 0 0 0 16 0a72 72 0 1 1 72 72m29.66-82.34L171.31 136l18.35 18.34a8 8 0 0 1-11.32 11.32L160 147.31l-18.34 18.35a8 8 0 0 1-11.32-11.32L148.69 136l-18.35-18.34a8 8 0 0 1 11.32-11.32L160 124.69l18.34-18.35a8 8 0 0 1 11.32 11.32"
|
||||
/>
|
||||
</svg>
|
||||
)
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
import { cn } from "~/lib/utils"
|
||||
|
||||
export const EmptyIcon: Component = ({ className }) => (
|
||||
<svg
|
||||
version="1.1"
|
||||
x="0px"
|
||||
y="0px"
|
||||
width="59.227px"
|
||||
height="59.227px"
|
||||
viewBox="0 0 59.227 59.227"
|
||||
className={cn("fill-current", className)}
|
||||
>
|
||||
<g>
|
||||
<g>
|
||||
<path
|
||||
d="M51.586,10.029c-0.333-0.475-0.897-0.689-1.449-0.607c-0.021-0.005-0.042-0.014-0.063-0.017L27.469,6.087
|
||||
c-0.247-0.037-0.499-0.01-0.734,0.076L8.63,12.799c-0.008,0.003-0.015,0.008-0.023,0.011c-0.019,0.008-0.037,0.02-0.057,0.027
|
||||
c-0.099,0.044-0.191,0.096-0.276,0.157c-0.026,0.019-0.051,0.038-0.077,0.059c-0.093,0.076-0.178,0.159-0.249,0.254
|
||||
c-0.004,0.006-0.01,0.009-0.014,0.015L0.289,23.78c-0.293,0.401-0.369,0.923-0.202,1.391c0.167,0.469,0.556,0.823,1.038,0.947
|
||||
l6.634,1.713v16.401c0,0.659,0.431,1.242,1.062,1.435l24.29,7.422c0.008,0.004,0.017,0.001,0.025,0.005
|
||||
c0.13,0.036,0.266,0.059,0.402,0.06c0.003,0,0.007,0.002,0.011,0.002l0,0h0.001c0.143,0,0.283-0.026,0.423-0.067
|
||||
c0.044-0.014,0.085-0.033,0.13-0.052c0.059-0.022,0.117-0.038,0.175-0.068l17.43-9.673c0.477-0.265,0.772-0.767,0.772-1.312
|
||||
V25.586l5.896-2.83c0.397-0.19,0.69-0.547,0.802-0.973c0.111-0.427,0.03-0.88-0.223-1.241L51.586,10.029z M27.41,9.111
|
||||
l17.644,2.59L33.35,17.143l-18.534-3.415L27.41,9.111z M9.801,15.854l21.237,3.914l-6.242,9.364l-20.78-5.365L9.801,15.854z
|
||||
M10.759,43.122V28.605l14.318,3.697c0.125,0.031,0.25,0.048,0.375,0.048c0.493,0,0.965-0.244,1.248-0.668l5.349-8.023v25.968
|
||||
L10.759,43.122z M49.479,41.1l-14.431,8.007V25.414l2.635,5.599c0.171,0.361,0.479,0.641,0.854,0.773
|
||||
c0.163,0.06,0.333,0.087,0.502,0.087c0.223,0,0.444-0.05,0.649-0.146l9.789-4.698L49.479,41.1L49.479,41.1z M39.755,28.368
|
||||
l-4.207-8.938L49.85,12.78l5.634,8.037L39.755,28.368z"
|
||||
/>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
)
|
||||
@@ -1,12 +0,0 @@
|
||||
export const FollowIcon: Component = (props) => (
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 344 330" fill="none" {...props}>
|
||||
<g fill="currentColor" clipPath="url(#a)">
|
||||
<path d="M297.639 0H88.19C62.862 0 42.33 20.514 42.33 45.82c0 25.305 20.532 45.819 45.86 45.819H297.64c25.328 0 45.861-20.514 45.861-45.82C343.5 20.514 322.967 0 297.639 0ZM185.96 119.13H46.361C21.033 119.13.5 139.644.5 164.95c0 25.305 20.533 45.819 45.861 45.819H185.96c25.328 0 45.861-20.514 45.861-45.819 0-25.306-20.533-45.82-45.861-45.82ZM199.466 284.181c0-25.306-20.533-45.82-45.861-45.82-25.328 0-45.861 20.514-45.861 45.82 0 25.305 20.533 45.819 45.861 45.819 25.328 0 45.861-20.514 45.861-45.819Z" />
|
||||
</g>
|
||||
<defs>
|
||||
<clipPath id="a">
|
||||
<path fill="currentColor" d="M.5 0h343v330H.5z" />
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
||||
)
|
||||
@@ -1,29 +0,0 @@
|
||||
import { forwardRef } from "react"
|
||||
|
||||
export const Logo = forwardRef<SVGSVGElement, React.SVGProps<SVGSVGElement>>((props, ref) => (
|
||||
<svg {...props} ref={ref} 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>
|
||||
))
|
||||
@@ -1,12 +0,0 @@
|
||||
import type { SVGProps } from "react"
|
||||
|
||||
export function LetsIconsResizeDownRightLight(props: SVGProps<SVGSVGElement>) {
|
||||
return (
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24" {...props}>
|
||||
<g fill="none" stroke="currentColor">
|
||||
<path d="M10 20h10V10" />
|
||||
<path d="M12 17h5v-5" />
|
||||
</g>
|
||||
</svg>
|
||||
)
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
import type { SVGAttributes } from "react"
|
||||
|
||||
export function UserArrowLeftIcon(props: SVGAttributes<SVGElement>) {
|
||||
return (
|
||||
<svg
|
||||
width="1em"
|
||||
height="1em"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
{...props}
|
||||
>
|
||||
<path
|
||||
d="M11 15H7C4.79086 15 3 16.7909 3 19C3 20.1046 3.89543 21 5 21H15M16.8744 13C16.2164 13.4935 15.6221 14.066 15.1049 14.7043C15.035 14.7906 15 14.8953 15 15M16.8744 17C16.2164 16.5065 15.6221 15.934 15.1049 15.2957C15.035 15.2094 15 15.1047 15 15M15 15H21M15 7C15 9.20914 13.2091 11 11 11C8.79086 11 7 9.20914 7 7C7 4.79086 8.79086 3 11 3C13.2091 3 15 4.79086 15 7Z"
|
||||
stroke="currentColor"
|
||||
strokeWidth="2"
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
/>
|
||||
</svg>
|
||||
)
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
import type { SVGProps } from "react"
|
||||
|
||||
export function PhUsersBold(props: SVGProps<SVGSVGElement>) {
|
||||
return (
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="1em"
|
||||
height="1em"
|
||||
viewBox="0 0 256 256"
|
||||
{...props}
|
||||
>
|
||||
<path
|
||||
fill="currentColor"
|
||||
d="M125.18 156.94a64 64 0 1 0-82.36 0a100.23 100.23 0 0 0-39.49 32a12 12 0 0 0 19.35 14.2a76 76 0 0 1 122.64 0a12 12 0 0 0 19.36-14.2a100.33 100.33 0 0 0-39.5-32M44 108a40 40 0 1 1 40 40a40 40 0 0 1-40-40m206.1 97.67a12 12 0 0 1-16.78-2.57A76.31 76.31 0 0 0 172 172a12 12 0 0 1 0-24a40 40 0 1 0-10.3-78.67a12 12 0 1 1-6.16-23.19a64 64 0 0 1 57.64 110.8a100.23 100.23 0 0 1 39.49 32a12 12 0 0 1-2.57 16.73"
|
||||
/>
|
||||
</svg>
|
||||
)
|
||||
}
|
||||
@@ -1,111 +0,0 @@
|
||||
import { useEffect, useMemo, useState } from "react"
|
||||
|
||||
import { getColorScheme, stringToHue } from "~/lib/color"
|
||||
import { getImageProxyUrl } from "~/lib/img-proxy"
|
||||
import { cn, getUrlIcon } from "~/lib/utils"
|
||||
|
||||
import { PlatformIcon } from "./ui/platform-icon"
|
||||
/**
|
||||
*
|
||||
* @deprecated please use `FeedIcon` instead
|
||||
* @returns
|
||||
*/
|
||||
export function SiteIcon({
|
||||
url,
|
||||
className,
|
||||
style,
|
||||
fallback,
|
||||
fallbackText,
|
||||
proxy,
|
||||
src,
|
||||
}: {
|
||||
url?: string
|
||||
className?: string
|
||||
style?: React.CSSProperties
|
||||
/**
|
||||
* Fallback image when the site icon is not available
|
||||
*/
|
||||
fallback?: boolean
|
||||
fallbackText?: string
|
||||
|
||||
src?: string
|
||||
proxy?: {
|
||||
width: number
|
||||
height: number
|
||||
}
|
||||
}) {
|
||||
const colors = useMemo(() => {
|
||||
const id = src || url
|
||||
return id && fallback ? getColorScheme(stringToHue(id), true) : null
|
||||
}, [fallback, src, url])
|
||||
|
||||
const [showFallback, setShowFallback] = useState(false)
|
||||
useEffect(() => {
|
||||
setShowFallback(false)
|
||||
}, [url])
|
||||
|
||||
const stableProxy = useState(proxy)[0]
|
||||
|
||||
const [nextSrc, fallbackUrl] = useMemo((): [string, string] => {
|
||||
// src ? getProxyUrl(src) : "";
|
||||
if (src) {
|
||||
if (stableProxy) {
|
||||
return [
|
||||
getImageProxyUrl({
|
||||
url: src,
|
||||
width: stableProxy.width,
|
||||
height: stableProxy.height,
|
||||
}),
|
||||
"",
|
||||
]
|
||||
}
|
||||
|
||||
return [src, ""]
|
||||
}
|
||||
if (!url) return ["", ""]
|
||||
const ret = getUrlIcon(url, fallback)
|
||||
|
||||
return [ret.src, ret.fallbackUrl]
|
||||
}, [fallback, stableProxy, src, url])
|
||||
|
||||
if (!nextSrc) return null
|
||||
|
||||
return (
|
||||
<PlatformIcon
|
||||
url={nextSrc}
|
||||
style={style}
|
||||
className={cn("relative mr-2 size-5 shrink-0 rounded-sm", className)}
|
||||
>
|
||||
{showFallback && fallback ? (
|
||||
<div
|
||||
data-error-image={nextSrc || fallbackUrl}
|
||||
className="center absolute inset-0 bg-[var(--fo-light-background)] text-[9px] text-white dark:bg-[var(--fo-dark-background)]"
|
||||
style={
|
||||
{
|
||||
"--fo-light-background": colors.light.background,
|
||||
"--fo-dark-background": colors.dark.background,
|
||||
} as any
|
||||
}
|
||||
>
|
||||
{!!fallbackText && fallbackText[0]}
|
||||
</div>
|
||||
) : (
|
||||
<img
|
||||
src={nextSrc}
|
||||
loading="lazy"
|
||||
onError={(e) => {
|
||||
if (fallbackUrl && e.currentTarget.src !== fallbackUrl) {
|
||||
e.currentTarget.src = fallbackUrl
|
||||
} else if (fallback) {
|
||||
setShowFallback(true)
|
||||
} else {
|
||||
// Empty svg
|
||||
e.currentTarget.src =
|
||||
"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3C/svg%3E"
|
||||
}
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</PlatformIcon>
|
||||
)
|
||||
}
|
||||
@@ -1,217 +0,0 @@
|
||||
// @copy internal masonic hooks
|
||||
import { clearRequestTimeout, requestTimeout } from "@essentials/request-timeout"
|
||||
import { useWindowSize } from "@react-hook/window-size"
|
||||
import { useForceUpdate } from "framer-motion"
|
||||
import { isEqual, throttle } from "lodash-es"
|
||||
import type { ContainerPosition, MasonryProps, MasonryScrollerProps, Positioner } from "masonic"
|
||||
import { createResizeObserver, useMasonry, usePositioner, useScrollToIndex } from "masonic"
|
||||
import * as React from "react"
|
||||
|
||||
import { useScrollViewElement } from "./scroll-area/hooks"
|
||||
/**
|
||||
* A "batteries included" masonry grid which includes all of the implementation details below. This component is the
|
||||
* easiest way to get off and running in your app, before switching to more advanced implementations, if necessary.
|
||||
* It will change its column count to fit its container's width and will decide how many rows to render based upon
|
||||
* the height of the browser `window`.
|
||||
*
|
||||
* @param props
|
||||
*/
|
||||
export const Masonry = <Item,>(props: MasonryProps<Item>) => {
|
||||
const [scrollTop, setScrollTop] = React.useState(0)
|
||||
const [isScrolling, setIsScrolling] = React.useState(false)
|
||||
const scrollElement = useScrollViewElement()
|
||||
|
||||
const fps = props.scrollFps || 12
|
||||
React.useEffect(() => {
|
||||
if (!scrollElement) return
|
||||
|
||||
const scrollTimer: number | null = null
|
||||
const handleScroll = throttle(() => {
|
||||
setIsScrolling(true)
|
||||
setScrollTop(scrollElement.scrollTop)
|
||||
}, 1000 / fps)
|
||||
|
||||
scrollElement.addEventListener("scroll", handleScroll)
|
||||
|
||||
return () => {
|
||||
scrollElement.removeEventListener("scroll", handleScroll)
|
||||
if (scrollTimer) {
|
||||
clearTimeout(scrollTimer)
|
||||
}
|
||||
}
|
||||
}, [fps, scrollElement])
|
||||
const didMount = React.useRef(0)
|
||||
React.useEffect(() => {
|
||||
if (didMount.current === 1) setIsScrolling(true)
|
||||
let didUnsubscribe = false
|
||||
const to = requestTimeout(
|
||||
() => {
|
||||
if (didUnsubscribe) return
|
||||
// This is here to prevent premature bail outs while maintaining high resolution
|
||||
// unsets. Without it there will always bee a lot of unnecessary DOM writes to style.
|
||||
setIsScrolling(false)
|
||||
},
|
||||
40 + 1000 / fps,
|
||||
)
|
||||
didMount.current = 1
|
||||
return () => {
|
||||
didUnsubscribe = true
|
||||
clearRequestTimeout(to)
|
||||
}
|
||||
}, [fps, scrollTop])
|
||||
|
||||
const containerRef = React.useRef<null | HTMLElement>(null)
|
||||
const windowSize = useWindowSize({
|
||||
initialWidth: props.ssrWidth,
|
||||
initialHeight: props.ssrHeight,
|
||||
})
|
||||
const containerPos = useContainerPosition(containerRef, windowSize)
|
||||
|
||||
const nextProps = Object.assign(
|
||||
{
|
||||
offset: containerPos.offset,
|
||||
width: containerPos.width || windowSize[0],
|
||||
height: containerPos.height || windowSize[1],
|
||||
containerRef,
|
||||
},
|
||||
props,
|
||||
) as any
|
||||
|
||||
// Workaround for https://github.com/jaredLunde/masonic/issues/12
|
||||
const itemCounter = React.useRef<number>(props.items.length)
|
||||
|
||||
let shrunk = false
|
||||
|
||||
if (props.items.length !== itemCounter.current) {
|
||||
if (props.items.length < itemCounter.current) shrunk = true
|
||||
|
||||
itemCounter.current = props.items.length
|
||||
}
|
||||
|
||||
nextProps.positioner = usePositioner(nextProps, [shrunk && Math.random()])
|
||||
|
||||
nextProps.resizeObserver = useResizeObserver(nextProps.positioner)
|
||||
nextProps.scrollTop = scrollTop
|
||||
nextProps.isScrolling = isScrolling
|
||||
nextProps.height = window.innerHeight
|
||||
|
||||
const scrollToIndex = useScrollToIndex(nextProps.positioner, {
|
||||
height: nextProps.height,
|
||||
offset: containerPos.offset,
|
||||
align: typeof props.scrollToIndex === "object" ? props.scrollToIndex.align : void 0,
|
||||
})
|
||||
const index =
|
||||
props.scrollToIndex &&
|
||||
(typeof props.scrollToIndex === "number" ? props.scrollToIndex : props.scrollToIndex.index)
|
||||
|
||||
React.useEffect(() => {
|
||||
if (index !== void 0) scrollToIndex(index)
|
||||
}, [index, scrollToIndex])
|
||||
|
||||
return React.createElement(MasonryScroller, nextProps)
|
||||
}
|
||||
|
||||
function MasonryScroller<Item>(
|
||||
props: MasonryScrollerProps<Item> & {
|
||||
scrollTop: number
|
||||
isScrolling: boolean
|
||||
},
|
||||
) {
|
||||
// We put this in its own layer because it's the thing that will trigger the most updates
|
||||
// and we don't want to slower ourselves by cycling through all the functions, objects, and effects
|
||||
// of other hooks
|
||||
// const { scrollTop, isScrolling } = useScroller(props.offset, props.scrollFps)
|
||||
// This is an update-heavy phase and while we could just Object.assign here,
|
||||
// it is way faster to inline and there's a relatively low hit to he bundle
|
||||
// size.
|
||||
|
||||
return useMasonry<Item>({
|
||||
scrollTop: props.scrollTop,
|
||||
isScrolling: props.isScrolling,
|
||||
positioner: props.positioner,
|
||||
resizeObserver: props.resizeObserver,
|
||||
items: props.items,
|
||||
onRender: props.onRender,
|
||||
as: props.as,
|
||||
id: props.id,
|
||||
className: props.className,
|
||||
style: props.style,
|
||||
role: props.role,
|
||||
tabIndex: props.tabIndex,
|
||||
containerRef: props.containerRef,
|
||||
itemAs: props.itemAs,
|
||||
itemStyle: props.itemStyle,
|
||||
itemHeightEstimate: props.itemHeightEstimate,
|
||||
itemKey: props.itemKey,
|
||||
overscanBy: props.overscanBy,
|
||||
height: props.height,
|
||||
render: props.render,
|
||||
})
|
||||
}
|
||||
|
||||
function useContainerPosition(
|
||||
elementRef: React.MutableRefObject<HTMLElement | null>,
|
||||
deps: React.DependencyList = [],
|
||||
): ContainerPosition & {
|
||||
height: number
|
||||
} {
|
||||
const [containerPosition, setContainerPosition] = React.useState<
|
||||
ContainerPosition & {
|
||||
height: number
|
||||
}
|
||||
>({
|
||||
offset: 0,
|
||||
width: 0,
|
||||
height: 0,
|
||||
})
|
||||
|
||||
React.useLayoutEffect(() => {
|
||||
const { current } = elementRef
|
||||
if (current !== null) {
|
||||
let offset = 0
|
||||
let el = current
|
||||
|
||||
do {
|
||||
offset += el.offsetTop || 0
|
||||
el = el.offsetParent as HTMLElement
|
||||
} while (el)
|
||||
|
||||
if (offset !== containerPosition.offset || current.offsetWidth !== containerPosition.width) {
|
||||
setContainerPosition({
|
||||
offset,
|
||||
width: current.offsetWidth,
|
||||
height: current.offsetHeight,
|
||||
})
|
||||
}
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, deps)
|
||||
|
||||
React.useEffect(() => {
|
||||
const resizeObserver = new ResizeObserver(() => {
|
||||
setContainerPosition((prev) => {
|
||||
const next = {
|
||||
...prev,
|
||||
width: elementRef.current?.offsetWidth || 0,
|
||||
}
|
||||
if (isEqual(next, prev)) return prev
|
||||
return next
|
||||
})
|
||||
})
|
||||
resizeObserver.observe(elementRef.current as HTMLElement)
|
||||
return () => {
|
||||
resizeObserver.disconnect()
|
||||
}
|
||||
}, [containerPosition, elementRef])
|
||||
|
||||
return containerPosition
|
||||
}
|
||||
|
||||
function useResizeObserver(positioner: Positioner) {
|
||||
const [forceUpdate] = useForceUpdate()
|
||||
const resizeObserver = createResizeObserver(positioner, throttle(forceUpdate, 1000 / 12))
|
||||
// Cleans up the resize observers when they change or the
|
||||
// component unmounts
|
||||
React.useEffect(() => () => resizeObserver.disconnect(), [resizeObserver])
|
||||
return resizeObserver
|
||||
}
|
||||
@@ -1,12 +1,11 @@
|
||||
import { Input } from "@follow/components/ui/input/index.js"
|
||||
import { stopPropagation } from "@follow/utils/dom"
|
||||
import { cn } from "@follow/utils/utils"
|
||||
import { Combobox, ComboboxInput, ComboboxOption, ComboboxOptions } from "@headlessui/react"
|
||||
import { AnimatePresence, m } from "framer-motion"
|
||||
import Fuse from "fuse.js"
|
||||
import { forwardRef, Fragment, useCallback, useEffect, useState } from "react"
|
||||
|
||||
import { stopPropagation } from "~/lib/dom"
|
||||
import { cn } from "~/lib/utils"
|
||||
|
||||
import { Input } from "../input"
|
||||
import { useCorrectZIndex } from "../modal"
|
||||
|
||||
export type Suggestion = {
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
import * as AvatarPrimitive from "@radix-ui/react-avatar"
|
||||
import * as React from "react"
|
||||
|
||||
import { cn } from "~/lib/utils"
|
||||
|
||||
const Avatar = React.forwardRef<
|
||||
React.ElementRef<typeof AvatarPrimitive.Root>,
|
||||
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Root>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<AvatarPrimitive.Root
|
||||
ref={ref}
|
||||
className={cn("relative flex size-10 shrink-0 overflow-hidden rounded-full", className)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
Avatar.displayName = AvatarPrimitive.Root.displayName
|
||||
|
||||
const AvatarImage = React.forwardRef<
|
||||
React.ElementRef<typeof AvatarPrimitive.Image>,
|
||||
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Image>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<AvatarPrimitive.Image
|
||||
ref={ref}
|
||||
className={cn("aspect-square size-full", className)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
AvatarImage.displayName = AvatarPrimitive.Image.displayName
|
||||
|
||||
const AvatarFallback = React.forwardRef<
|
||||
React.ElementRef<typeof AvatarPrimitive.Fallback>,
|
||||
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Fallback>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<AvatarPrimitive.Fallback
|
||||
ref={ref}
|
||||
className={cn("flex size-full items-center justify-center rounded-full bg-muted", className)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName
|
||||
|
||||
export { Avatar, AvatarFallback, AvatarImage }
|
||||
@@ -1,7 +1,7 @@
|
||||
import { SYSTEM_CAN_UNDER_BLUR_WINDOW } from "@follow/shared/constants"
|
||||
import { cn } from "@follow/utils/utils"
|
||||
|
||||
import { useUISettingKey } from "~/atoms/settings/ui"
|
||||
import { cn } from "~/lib/utils"
|
||||
|
||||
type Props = Component<
|
||||
React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>
|
||||
|
||||
@@ -1,241 +0,0 @@
|
||||
import type { VariantProps } from "class-variance-authority"
|
||||
import type { HTMLMotionProps } from "framer-motion"
|
||||
import { m } from "framer-motion"
|
||||
import * as React from "react"
|
||||
import { useHotkeys } from "react-hotkeys-hook"
|
||||
import type { OptionsOrDependencyArray } from "react-hotkeys-hook/dist/types"
|
||||
|
||||
import { stopPropagation } from "~/lib/dom"
|
||||
import { cn, getOS } from "~/lib/utils"
|
||||
|
||||
import { KbdCombined } from "../kbd/Kbd"
|
||||
import { LoadingCircle } from "../loading"
|
||||
import { Tooltip, TooltipContent, TooltipPortal, TooltipTrigger } from "../tooltip"
|
||||
import { styledButtonVariant } from "./variants"
|
||||
|
||||
export interface BaseButtonProps {
|
||||
isLoading?: boolean
|
||||
}
|
||||
|
||||
// BIZ buttons
|
||||
|
||||
interface ActionButtonProps {
|
||||
icon?: React.ReactNode | React.FC<ComponentType>
|
||||
tooltip?: React.ReactNode
|
||||
tooltipSide?: "top" | "bottom"
|
||||
active?: boolean
|
||||
disabled?: boolean
|
||||
shortcut?: string
|
||||
disableTriggerShortcut?: boolean
|
||||
size?: "sm" | "md" | "base"
|
||||
}
|
||||
|
||||
const actionButtonStyleVariant = {
|
||||
size: {
|
||||
base: tw`text-xl size-8`,
|
||||
sm: tw`text-sm size-6`,
|
||||
},
|
||||
}
|
||||
export const ActionButton = React.forwardRef<
|
||||
HTMLButtonElement,
|
||||
ComponentType<ActionButtonProps> & React.HTMLAttributes<HTMLButtonElement>
|
||||
>(
|
||||
(
|
||||
{
|
||||
icon,
|
||||
|
||||
tooltip,
|
||||
className,
|
||||
tooltipSide,
|
||||
children,
|
||||
active,
|
||||
shortcut,
|
||||
disabled,
|
||||
disableTriggerShortcut,
|
||||
size = "base",
|
||||
...rest
|
||||
},
|
||||
ref,
|
||||
) => {
|
||||
const finalShortcut =
|
||||
getOS() === "Windows" ? shortcut?.replace("meta", "ctrl").replace("Meta", "Ctrl") : shortcut
|
||||
const buttonRef = React.useRef<HTMLButtonElement>(null)
|
||||
React.useImperativeHandle(ref, () => buttonRef.current!)
|
||||
|
||||
const Trigger = (
|
||||
<button
|
||||
ref={buttonRef}
|
||||
// @see https://github.com/radix-ui/primitives/issues/2248#issuecomment-2147056904
|
||||
onFocusCapture={stopPropagation}
|
||||
className={cn(
|
||||
"no-drag-region inline-flex items-center justify-center",
|
||||
active && "bg-zinc-500/15 hover:bg-zinc-500/20",
|
||||
"rounded-md duration-200 hover:bg-theme-button-hover data-[state=open]:bg-theme-button-hover",
|
||||
"disabled:cursor-not-allowed disabled:opacity-50",
|
||||
actionButtonStyleVariant.size[size],
|
||||
className,
|
||||
)}
|
||||
type="button"
|
||||
disabled={disabled}
|
||||
{...rest}
|
||||
>
|
||||
{typeof icon === "function"
|
||||
? React.createElement(icon, {
|
||||
className: "size-4 grayscale text-current",
|
||||
})
|
||||
: icon}
|
||||
|
||||
{children}
|
||||
</button>
|
||||
)
|
||||
return (
|
||||
<>
|
||||
{finalShortcut && !disableTriggerShortcut && (
|
||||
<HotKeyTrigger shortcut={finalShortcut} fn={() => buttonRef.current?.click()} />
|
||||
)}
|
||||
{tooltip ? (
|
||||
<Tooltip disableHoverableContent>
|
||||
<TooltipTrigger aria-label={typeof tooltip === "string" ? tooltip : undefined} asChild>
|
||||
{Trigger}
|
||||
</TooltipTrigger>
|
||||
<TooltipPortal>
|
||||
<TooltipContent className="flex items-center gap-1" side={tooltipSide ?? "bottom"}>
|
||||
{tooltip}
|
||||
{!!finalShortcut && (
|
||||
<div className="ml-1">
|
||||
<KbdCombined className="text-foreground/80">{finalShortcut}</KbdCombined>
|
||||
</div>
|
||||
)}
|
||||
</TooltipContent>
|
||||
</TooltipPortal>
|
||||
</Tooltip>
|
||||
) : (
|
||||
Trigger
|
||||
)}
|
||||
</>
|
||||
)
|
||||
},
|
||||
)
|
||||
|
||||
const HotKeyTrigger = ({
|
||||
shortcut,
|
||||
fn,
|
||||
options,
|
||||
}: {
|
||||
shortcut: string
|
||||
fn: () => void
|
||||
options?: OptionsOrDependencyArray
|
||||
}) => {
|
||||
useHotkeys(shortcut, fn, {
|
||||
preventDefault: true,
|
||||
...options,
|
||||
})
|
||||
return null
|
||||
}
|
||||
export const MotionButtonBase = React.forwardRef<HTMLButtonElement, HTMLMotionProps<"button">>(
|
||||
({ children, ...rest }, ref) => (
|
||||
<m.button
|
||||
layout="size"
|
||||
initial
|
||||
whileFocus={{ scale: 1.02 }}
|
||||
whileTap={{ scale: 0.95 }}
|
||||
{...rest}
|
||||
ref={ref}
|
||||
>
|
||||
{children}
|
||||
</m.button>
|
||||
),
|
||||
)
|
||||
|
||||
MotionButtonBase.displayName = "MotionButtonBase"
|
||||
|
||||
export const Button = React.forwardRef<
|
||||
HTMLButtonElement,
|
||||
React.PropsWithChildren<
|
||||
Omit<HTMLMotionProps<"button">, "children"> &
|
||||
BaseButtonProps &
|
||||
VariantProps<typeof styledButtonVariant> & {
|
||||
buttonClassName?: string
|
||||
}
|
||||
>
|
||||
>(({ className, buttonClassName, isLoading, variant, status, ...props }, ref) => {
|
||||
const handleClick: React.MouseEventHandler<HTMLButtonElement> = React.useCallback(
|
||||
(e) => {
|
||||
if (isLoading || props.disabled) {
|
||||
e.preventDefault()
|
||||
return
|
||||
}
|
||||
|
||||
props.onClick?.(e)
|
||||
},
|
||||
[isLoading, props],
|
||||
)
|
||||
return (
|
||||
<MotionButtonBase
|
||||
ref={ref}
|
||||
className={cn(
|
||||
styledButtonVariant({
|
||||
variant,
|
||||
status: isLoading || props.disabled ? "disabled" : undefined,
|
||||
}),
|
||||
className,
|
||||
buttonClassName,
|
||||
)}
|
||||
{...props}
|
||||
onClick={handleClick}
|
||||
>
|
||||
<span className="contents">
|
||||
{typeof isLoading === "boolean" && (
|
||||
<m.span
|
||||
className="center"
|
||||
animate={{
|
||||
width: isLoading ? "auto" : "0px",
|
||||
}}
|
||||
>
|
||||
{isLoading && <LoadingCircle size="small" className="center mr-2" />}
|
||||
</m.span>
|
||||
)}
|
||||
<span className={cn("center", className)}>{props.children}</span>
|
||||
</span>
|
||||
</MotionButtonBase>
|
||||
)
|
||||
})
|
||||
|
||||
export const IconButton = React.forwardRef<
|
||||
HTMLButtonElement,
|
||||
React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement> &
|
||||
React.PropsWithChildren<{
|
||||
icon: React.JSX.Element
|
||||
}>
|
||||
>((props, ref) => {
|
||||
const { icon, ...rest } = props
|
||||
return (
|
||||
<button
|
||||
ref={ref}
|
||||
type="button"
|
||||
{...rest}
|
||||
className={cn(
|
||||
styledButtonVariant({
|
||||
variant: "ghost",
|
||||
}),
|
||||
"group relative gap-2 bg-accent/10 px-4 hover:bg-accent dark:bg-accent/20 dark:hover:bg-accent/60",
|
||||
rest.className,
|
||||
)}
|
||||
>
|
||||
<span className="center">
|
||||
{React.cloneElement(icon, {
|
||||
className: cn("invisible", icon.props.className),
|
||||
})}
|
||||
|
||||
{React.cloneElement(icon, {
|
||||
className: cn(
|
||||
"group-hover:text-white dark:group-hover:text-inherit",
|
||||
"absolute left-4 top-1/2 -translate-y-1/2 duration-200 group-hover:left-1/2 group-hover:-translate-x-1/2",
|
||||
icon.props.className,
|
||||
),
|
||||
})}
|
||||
</span>
|
||||
<span className="duration-200 group-hover:opacity-0">{props.children}</span>
|
||||
</button>
|
||||
)
|
||||
})
|
||||
@@ -1,75 +0,0 @@
|
||||
import { cva } from "class-variance-authority"
|
||||
|
||||
import { cn } from "~/lib/utils"
|
||||
|
||||
// Design
|
||||
// @see https://x.com/uiuxadrian/status/1822947443186504176
|
||||
|
||||
export const styledButtonVariant = cva(
|
||||
[
|
||||
"inline-flex cursor-button select-none items-center justify-center outline-offset-2 transition active:transition-none disabled:cursor-not-allowed",
|
||||
"ring-accent/20 duration-200 disabled:ring-0",
|
||||
"align-middle",
|
||||
],
|
||||
{
|
||||
compoundVariants: [
|
||||
{
|
||||
variant: "primary",
|
||||
status: "disabled",
|
||||
className: "text-zinc-50 bg-theme-disabled",
|
||||
},
|
||||
{
|
||||
variant: "outline",
|
||||
status: "disabled",
|
||||
className:
|
||||
"text-theme-disabled border-theme-inactive dark:border-zinc-800 hover:!bg-theme-background",
|
||||
},
|
||||
{
|
||||
variant: "text",
|
||||
status: "disabled",
|
||||
className: "opacity-60",
|
||||
},
|
||||
{
|
||||
variant: "ghost",
|
||||
status: "disabled",
|
||||
className: "opacity-50 hover:!bg-transparent",
|
||||
},
|
||||
],
|
||||
variants: {
|
||||
size: {
|
||||
default: "px-3 py-1.5 rounded-lg text-sm",
|
||||
},
|
||||
|
||||
status: {
|
||||
disabled: "cursor-not-allowed !ring-0",
|
||||
},
|
||||
variant: {
|
||||
primary: cn(
|
||||
"bg-accent",
|
||||
"hover:contrast-[1.10] active:contrast-125",
|
||||
"font-semibold",
|
||||
"disabled:bg-theme-disabled disabled:dark:text-zinc-50",
|
||||
"text-zinc-100 dark:text-zinc-200/90",
|
||||
"focus:border-accent/80 focus:outline-none focus:ring-2",
|
||||
),
|
||||
|
||||
outline: cn(
|
||||
"bg-theme-background font-semibold duration-200",
|
||||
"border border-border hover:bg-zinc-50 dark:bg-neutral-900/30 dark:hover:bg-neutral-900/80",
|
||||
"focus:border-accent/80",
|
||||
),
|
||||
text: cn(
|
||||
"font-semibold text-accent",
|
||||
"hover:contrast-[1.10] active:contrast-125",
|
||||
"focus:text-accent focus:outline-none",
|
||||
),
|
||||
ghost: cn("px-1.5 font-semibold", "hover:bg-theme-button-hover"),
|
||||
},
|
||||
},
|
||||
|
||||
defaultVariants: {
|
||||
variant: "primary",
|
||||
size: "default",
|
||||
},
|
||||
},
|
||||
)
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
MdiLanguageTypescript,
|
||||
RiMarkdownFill,
|
||||
UilReact,
|
||||
} from "~/components/icons/Language"
|
||||
} from "@follow/components/icons/Language.jsx"
|
||||
|
||||
const LanguageAlias = {
|
||||
ts: "typescript",
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
import { MotionButtonBase } from "@follow/components/ui/button/index.js"
|
||||
import { cn } from "@follow/utils/utils"
|
||||
import type { Variants } from "framer-motion"
|
||||
import { AnimatePresence } from "framer-motion"
|
||||
import { useCallback, useRef, useState } from "react"
|
||||
|
||||
import { m } from "~/components/common/Motion"
|
||||
import { cn } from "~/lib/utils"
|
||||
|
||||
import { MotionButtonBase } from "../button"
|
||||
|
||||
const copyIconVariants: Variants = {
|
||||
initial: {
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { useIsDark } from "@follow/hooks"
|
||||
import { cn } from "@follow/utils/utils"
|
||||
import { useIsomorphicLayoutEffect } from "foxact/use-isomorphic-layout-effect"
|
||||
import type { FC } from "react"
|
||||
import { useInsertionEffect, useMemo, useRef, useState } from "react"
|
||||
@@ -10,9 +12,7 @@ import type {
|
||||
|
||||
import { useUISettingKey, useUISettingSelector } from "~/atoms/settings/ui"
|
||||
import { isElectronBuild } from "~/constants"
|
||||
import { useIsDark } from "~/hooks/common"
|
||||
import { tipcClient } from "~/lib/client"
|
||||
import { cn } from "~/lib/utils"
|
||||
|
||||
import { getLanguageColor, getLanguageIcon } from "../constants"
|
||||
import { CopyButton } from "../copy-button"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useIsDark } from "~/hooks/common"
|
||||
import { useIsDark } from "@follow/hooks"
|
||||
|
||||
export const useShikiDefaultTheme = () => {
|
||||
const isDark = useIsDark()
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import { cn } from "@follow/utils/utils"
|
||||
import type { Variants } from "framer-motion"
|
||||
import { AnimatePresence, m } from "framer-motion"
|
||||
import * as React from "react"
|
||||
|
||||
import { cn } from "~/lib/utils"
|
||||
|
||||
import {
|
||||
CollapseGroupItemStateProvider,
|
||||
CollapseStateProvider,
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
import { RootPortal } from "@follow/components/ui/portal/index.jsx"
|
||||
import { cn } from "@follow/utils/utils"
|
||||
import * as ContextMenuPrimitive from "@radix-ui/react-context-menu"
|
||||
import * as React from "react"
|
||||
|
||||
import { cn } from "~/lib/utils"
|
||||
|
||||
import { RootPortal } from "../portal"
|
||||
|
||||
const ContextMenu = ContextMenuPrimitive.Root
|
||||
|
||||
const ContextMenuTrigger = ContextMenuPrimitive.Trigger
|
||||
@@ -157,4 +155,4 @@ export {
|
||||
ContextMenuTrigger,
|
||||
}
|
||||
|
||||
export { RootPortal as ContextMenuPortal } from "../portal"
|
||||
export { RootPortal as ContextMenuPortal } from "@follow/components/ui/portal/index.jsx"
|
||||
|
||||
@@ -1,98 +1,20 @@
|
||||
import { getUpdateInterval } from "@follow/components/ui/datetime/index.js"
|
||||
import {
|
||||
Tooltip,
|
||||
TooltipContent,
|
||||
TooltipPortal,
|
||||
TooltipTrigger,
|
||||
} from "@follow/components/ui/tooltip/index.js"
|
||||
import { stopPropagation } from "@follow/utils/dom"
|
||||
import dayjs from "dayjs"
|
||||
import type { FC } from "react"
|
||||
import { useEffect, useRef, useState } from "react"
|
||||
import { useTranslation } from "react-i18next"
|
||||
|
||||
import { useGeneralSettingSelector } from "~/atoms/settings/general"
|
||||
import { stopPropagation } from "~/lib/dom"
|
||||
|
||||
import { Tooltip, TooltipContent, TooltipPortal, TooltipTrigger } from "../tooltip"
|
||||
|
||||
const formatTemplateString = "lll"
|
||||
export { RelativeTime } from "@follow/components/ui/datetime/index.js"
|
||||
const formatTemplateStringShort = "ll"
|
||||
|
||||
const formatTime = (
|
||||
date: string | Date,
|
||||
relativeBeforeDay?: number,
|
||||
template = formatTemplateString,
|
||||
) => {
|
||||
if (relativeBeforeDay && Math.abs(dayjs(date).diff(new Date(), "d")) > relativeBeforeDay) {
|
||||
return dayjs(date).format(template)
|
||||
}
|
||||
return dayjs.duration(dayjs(date).diff(dayjs(), "minute"), "minute").humanize()
|
||||
}
|
||||
|
||||
const getUpdateInterval = (date: string | Date, relativeBeforeDay?: number) => {
|
||||
if (!relativeBeforeDay) return null
|
||||
const diffInSeconds = Math.abs(dayjs(date).diff(new Date(), "second"))
|
||||
if (diffInSeconds <= 60) {
|
||||
return 1000 // Update every second
|
||||
}
|
||||
const diffInMinutes = Math.abs(dayjs(date).diff(new Date(), "minute"))
|
||||
if (diffInMinutes <= 60) {
|
||||
return 60000 // Update every minute
|
||||
}
|
||||
const diffInHours = Math.abs(dayjs(date).diff(new Date(), "hour"))
|
||||
if (diffInHours <= 24) {
|
||||
return 3600000 // Update every hour
|
||||
}
|
||||
const diffInDays = Math.abs(dayjs(date).diff(new Date(), "day"))
|
||||
if (diffInDays <= relativeBeforeDay) {
|
||||
return 86400000 // Update every day
|
||||
}
|
||||
return null // No need to update
|
||||
}
|
||||
|
||||
export const RelativeTime: FC<{
|
||||
date: string | Date
|
||||
displayAbsoluteTimeAfterDay?: number
|
||||
dateFormatTemplate?: string
|
||||
}> = (props) => {
|
||||
const { displayAbsoluteTimeAfterDay = 29, dateFormatTemplate = formatTemplateString } = props
|
||||
const [relative, setRelative] = useState<string>(() =>
|
||||
formatTime(props.date, displayAbsoluteTimeAfterDay, dateFormatTemplate),
|
||||
)
|
||||
|
||||
const timerRef = useRef<any>(null)
|
||||
|
||||
useEffect(() => {
|
||||
const updateRelativeTime = () => {
|
||||
setRelative(formatTime(props.date, displayAbsoluteTimeAfterDay, dateFormatTemplate))
|
||||
const updateInterval = getUpdateInterval(props.date, displayAbsoluteTimeAfterDay)
|
||||
|
||||
if (updateInterval !== null) {
|
||||
timerRef.current = setTimeout(updateRelativeTime, updateInterval)
|
||||
}
|
||||
}
|
||||
|
||||
updateRelativeTime()
|
||||
|
||||
return () => {
|
||||
clearTimeout(timerRef.current)
|
||||
}
|
||||
}, [props.date, displayAbsoluteTimeAfterDay, dateFormatTemplate])
|
||||
const formated = dayjs(props.date).format(dateFormatTemplate)
|
||||
|
||||
const { t } = useTranslation("common")
|
||||
if (formated === relative) {
|
||||
return <>{relative}</>
|
||||
}
|
||||
return (
|
||||
<Tooltip>
|
||||
{/* https://github.com/radix-ui/primitives/issues/2248#issuecomment-2147056904 */}
|
||||
<TooltipTrigger onFocusCapture={stopPropagation}>
|
||||
{relative}
|
||||
{t("space")}
|
||||
{t("words.ago")}
|
||||
</TooltipTrigger>
|
||||
|
||||
<TooltipPortal>
|
||||
<TooltipContent>{formated}</TooltipContent>
|
||||
</TooltipPortal>
|
||||
</Tooltip>
|
||||
)
|
||||
}
|
||||
|
||||
export const RelativeDay = ({ date }: { date: Date }) => {
|
||||
const { t } = useTranslation("common")
|
||||
const language = useGeneralSettingSelector((s) => s.language)
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
import type { DetailedHTMLProps, FC, HTMLAttributes } from "react"
|
||||
|
||||
import { cn } from "~/lib/utils"
|
||||
|
||||
export const Divider: FC<DetailedHTMLProps<HTMLAttributes<HTMLHRElement>, HTMLHRElement>> = (
|
||||
props,
|
||||
) => {
|
||||
const { className, ...rest } = props
|
||||
return (
|
||||
<hr
|
||||
className={cn("my-4 h-[0.5px] border-0 bg-black !bg-opacity-30 dark:bg-white", className)}
|
||||
{...rest}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
export const DividerVertical: FC<
|
||||
DetailedHTMLProps<HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>
|
||||
> = (props) => {
|
||||
const { className, ...rest } = props
|
||||
return (
|
||||
<span
|
||||
className={cn(
|
||||
"mx-4 inline-block h-full w-[0.5px] select-none bg-black text-transparent !opacity-20 dark:bg-white",
|
||||
className,
|
||||
)}
|
||||
{...rest}
|
||||
>
|
||||
w
|
||||
</span>
|
||||
)
|
||||
}
|
||||
|
||||
export const BreadcrumbDivider: Component = ({ className }) => (
|
||||
<svg
|
||||
width="24"
|
||||
height="24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
color="currentColor"
|
||||
shapeRendering="geometricPrecision"
|
||||
viewBox="0 0 24 24"
|
||||
className={className}
|
||||
>
|
||||
<path d="M16.88 3.549L7.12 20.451" />
|
||||
</svg>
|
||||
)
|
||||
@@ -1,60 +0,0 @@
|
||||
import * as React from "react"
|
||||
|
||||
import { useMeasure } from "~/hooks/common"
|
||||
import { cn } from "~/lib/utils"
|
||||
|
||||
import { Tooltip, TooltipContent, TooltipTrigger } from "../tooltip"
|
||||
|
||||
export const PanelSplitter = (
|
||||
props: React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement> & {
|
||||
isDragging?: boolean
|
||||
cursor?: string
|
||||
|
||||
tooltip?: React.ReactNode
|
||||
},
|
||||
) => {
|
||||
const { isDragging, cursor, tooltip, ...rest } = props
|
||||
|
||||
React.useEffect(() => {
|
||||
if (!isDragging) return
|
||||
const $css = document.createElement("style")
|
||||
|
||||
$css.innerHTML = `
|
||||
* {
|
||||
cursor: ${cursor} !important;
|
||||
}
|
||||
`
|
||||
|
||||
document.head.append($css)
|
||||
return () => {
|
||||
$css.remove()
|
||||
}
|
||||
}, [cursor, isDragging])
|
||||
|
||||
const [ref, { height }] = useMeasure()
|
||||
|
||||
const El = (
|
||||
<div
|
||||
tabIndex={-1}
|
||||
ref={ref}
|
||||
{...rest}
|
||||
className={cn(
|
||||
"absolute inset-0 z-[3] w-[2px] -translate-x-1/2 cursor-ew-resize bg-transparent hover:bg-gray-400 active:!bg-accent hover:dark:bg-neutral-500",
|
||||
isDragging ? "bg-accent" : "",
|
||||
)}
|
||||
/>
|
||||
)
|
||||
|
||||
return (
|
||||
<div className="relative h-full w-0 shrink-0">
|
||||
{tooltip ? (
|
||||
<Tooltip>
|
||||
<TooltipTrigger>{El}</TooltipTrigger>
|
||||
<TooltipContent sideOffset={height / 2}>{tooltip}</TooltipContent>
|
||||
</Tooltip>
|
||||
) : (
|
||||
El
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
export * from "./Divider"
|
||||
export * from "./PanelSpliter"
|
||||
@@ -1,10 +1,10 @@
|
||||
import { RootPortal } from "@follow/components/ui/portal/index.js"
|
||||
import { useTypeScriptHappyCallback } from "@follow/hooks"
|
||||
import { cn } from "@follow/utils/utils"
|
||||
import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu"
|
||||
import * as React from "react"
|
||||
|
||||
import { useHotkeyScope, useTypeScriptHappyCallback } from "~/hooks/common"
|
||||
import { cn } from "~/lib/utils"
|
||||
|
||||
import { RootPortal } from "../portal"
|
||||
import { useHotkeyScope } from "~/hooks/common"
|
||||
|
||||
const DropdownMenu: typeof DropdownMenuPrimitive.Root = (props) => {
|
||||
const [open, setOpen] = React.useState(!!props.open)
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
import { RootPortal } from "@follow/components/ui/portal/index.jsx"
|
||||
import { useTypeScriptHappyCallback } from "@follow/hooks"
|
||||
import { cn } from "@follow/utils/utils"
|
||||
import clsx from "clsx"
|
||||
import { typescriptHappyForwardRef } from "foxact/typescript-happy-forward-ref"
|
||||
import type { HTMLMotionProps } from "framer-motion"
|
||||
@@ -8,11 +11,7 @@ import type { JSX, PropsWithChildren, ReactNode } from "react"
|
||||
import { useId } from "react"
|
||||
|
||||
import { m } from "~/components/common/Motion"
|
||||
import { useTypeScriptHappyCallback } from "~/hooks/common"
|
||||
import { jotaiStore } from "~/lib/jotai"
|
||||
import { cn } from "~/lib/utils"
|
||||
|
||||
import { RootPortal } from "../portal"
|
||||
|
||||
const fabContainerElementAtom = atom(null as HTMLDivElement | null)
|
||||
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
import type { DetailedHTMLProps, InputHTMLAttributes } from "react"
|
||||
import { forwardRef } from "react"
|
||||
|
||||
import { useInputComposition } from "~/hooks/common"
|
||||
import { stopPropagation } from "~/lib/dom"
|
||||
import { cn } from "~/lib/utils"
|
||||
|
||||
// This composition handler is not perfect
|
||||
// @see https://foxact.skk.moe/use-composition-input
|
||||
export const Input = forwardRef<
|
||||
HTMLInputElement,
|
||||
Omit<DetailedHTMLProps<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "ref">
|
||||
>(({ className, ...props }, ref) => {
|
||||
const inputProps = useInputComposition(props)
|
||||
return (
|
||||
<input
|
||||
onContextMenu={stopPropagation}
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"min-w-0 flex-auto appearance-none rounded-lg text-sm",
|
||||
"bg-theme-background px-3 py-[calc(theme(spacing.2)-1px)]",
|
||||
"ring-accent/20 duration-200 focus:border-accent/80 focus:outline-none focus:ring-2",
|
||||
"focus:!bg-accent/5",
|
||||
"border border-border",
|
||||
"placeholder:text-theme-placeholder-text dark:bg-zinc-700/[0.15] dark:text-zinc-200",
|
||||
"hover:border-accent/60",
|
||||
"disabled:cursor-not-allowed disabled:opacity-50",
|
||||
props.type === "password" ? "font-mono placeholder:font-sans" : "font-sans",
|
||||
"w-full",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
{...inputProps}
|
||||
/>
|
||||
)
|
||||
})
|
||||
Input.displayName = "Input"
|
||||
@@ -1,111 +0,0 @@
|
||||
"use client"
|
||||
|
||||
import clsx from "clsx"
|
||||
import { useMotionValue } from "framer-motion"
|
||||
import type { DetailedHTMLProps, PropsWithChildren, TextareaHTMLAttributes } from "react"
|
||||
import { forwardRef, useCallback, useState } from "react"
|
||||
|
||||
import { useInputComposition } from "~/hooks/common"
|
||||
import { stopPropagation } from "~/lib/dom"
|
||||
import { cn } from "~/lib/utils"
|
||||
|
||||
const roundedMap = {
|
||||
sm: "rounded-sm",
|
||||
md: "rounded-md",
|
||||
lg: "rounded-lg",
|
||||
xl: "rounded-xl",
|
||||
"2xl": "rounded-2xl",
|
||||
"3xl": "rounded-3xl",
|
||||
default: "rounded",
|
||||
}
|
||||
export const TextArea = forwardRef<
|
||||
HTMLTextAreaElement,
|
||||
DetailedHTMLProps<TextareaHTMLAttributes<HTMLTextAreaElement>, HTMLTextAreaElement> &
|
||||
PropsWithChildren<{
|
||||
wrapperClassName?: string
|
||||
onCmdEnter?: (e: React.KeyboardEvent<HTMLTextAreaElement>) => void
|
||||
rounded?: "sm" | "md" | "lg" | "xl" | "2xl" | "3xl" | "default"
|
||||
bordered?: boolean
|
||||
}>
|
||||
>((props, ref) => {
|
||||
const {
|
||||
className,
|
||||
wrapperClassName,
|
||||
children,
|
||||
rounded = "xl",
|
||||
bordered = true,
|
||||
onCmdEnter,
|
||||
...rest
|
||||
} = props
|
||||
const mouseX = useMotionValue(0)
|
||||
const mouseY = useMotionValue(0)
|
||||
const handleMouseMove = useCallback(
|
||||
({ clientX, clientY, currentTarget }: React.MouseEvent) => {
|
||||
const bounds = currentTarget.getBoundingClientRect()
|
||||
mouseX.set(clientX - bounds.left)
|
||||
mouseY.set(clientY - bounds.top)
|
||||
},
|
||||
[mouseX, mouseY],
|
||||
)
|
||||
|
||||
const inputProps = useInputComposition<HTMLTextAreaElement>(props)
|
||||
const [isFocus, setIsFocus] = useState(false)
|
||||
return (
|
||||
<div
|
||||
className={cn(
|
||||
"group relative h-full border ring-0 ring-accent/20 duration-200",
|
||||
roundedMap[rounded],
|
||||
|
||||
"border-transparent",
|
||||
isFocus && "border-accent/80 ring-2",
|
||||
|
||||
"placeholder:text-theme-placeholder-text dark:text-zinc-200",
|
||||
wrapperClassName,
|
||||
)}
|
||||
onMouseMove={handleMouseMove}
|
||||
>
|
||||
{bordered && (
|
||||
<div
|
||||
className={clsx(
|
||||
"pointer-events-none absolute inset-0 z-0 border border-border",
|
||||
roundedMap[rounded],
|
||||
)}
|
||||
aria-hidden="true"
|
||||
/>
|
||||
)}
|
||||
<textarea
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"size-full resize-none bg-transparent",
|
||||
"overflow-auto px-3 py-4",
|
||||
"!outline-none",
|
||||
"text-neutral-900/80 dark:text-slate-100/80",
|
||||
"focus:!bg-accent/5",
|
||||
roundedMap[rounded],
|
||||
className,
|
||||
)}
|
||||
{...rest}
|
||||
onFocus={(e) => {
|
||||
setIsFocus(true)
|
||||
rest.onFocus?.(e)
|
||||
}}
|
||||
onBlur={(e) => {
|
||||
setIsFocus(false)
|
||||
rest.onBlur?.(e)
|
||||
}}
|
||||
onContextMenu={stopPropagation}
|
||||
{...inputProps}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === "Enter" && (e.metaKey || e.ctrlKey)) {
|
||||
onCmdEnter?.(e)
|
||||
}
|
||||
rest.onKeyDown?.(e)
|
||||
inputProps.onKeyDown?.(e)
|
||||
}}
|
||||
/>
|
||||
|
||||
{children}
|
||||
</div>
|
||||
)
|
||||
})
|
||||
TextArea.displayName = "TextArea"
|
||||
@@ -1,2 +0,0 @@
|
||||
export * from "./Input"
|
||||
export * from "./TextArea"
|
||||
@@ -1,10 +1,9 @@
|
||||
import { cn, getOS } from "@follow/utils/utils"
|
||||
import type { FC } from "react"
|
||||
import * as React from "react"
|
||||
import { Fragment, memo } from "react"
|
||||
import { isHotkeyPressed } from "react-hotkeys-hook"
|
||||
|
||||
import { cn, getOS } from "~/lib/utils"
|
||||
|
||||
const SharedKeys = {
|
||||
backspace: "⌫",
|
||||
space: "␣",
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
import { Tooltip, TooltipContent, TooltipPortal, TooltipTrigger } from "../tooltip"
|
||||
import {
|
||||
Tooltip,
|
||||
TooltipContent,
|
||||
TooltipPortal,
|
||||
TooltipTrigger,
|
||||
} from "@follow/components/ui/tooltip/index.jsx"
|
||||
|
||||
export interface LinkProps {
|
||||
href: string
|
||||
|
||||
@@ -1,89 +0,0 @@
|
||||
import clsx from "clsx"
|
||||
import { AnimatePresence } from "framer-motion"
|
||||
import { useEffect, useRef, useState } from "react"
|
||||
|
||||
import { m } from "~/components/common/Motion"
|
||||
import { views } from "~/constants"
|
||||
import { useRouteParamsSelector } from "~/hooks/biz/useRouteParams"
|
||||
import { FeedViewType } from "~/lib/enum"
|
||||
|
||||
export const ListItemHoverOverlay = ({
|
||||
className,
|
||||
children,
|
||||
isActive,
|
||||
}: {
|
||||
className?: string
|
||||
children?: React.ReactNode
|
||||
isActive?: boolean
|
||||
}) => {
|
||||
const [mouseEnter, setMouseEnter] = useState(false)
|
||||
const ref = useRef<HTMLDivElement>(null)
|
||||
useEffect(() => {
|
||||
const $ref = ref.current
|
||||
if (!$ref) return
|
||||
const $parent = $ref.parentElement
|
||||
if (!$parent) return
|
||||
$parent.onfocus = () => {
|
||||
setMouseEnter(true)
|
||||
}
|
||||
|
||||
$parent.onblur = () => {
|
||||
setMouseEnter(false)
|
||||
}
|
||||
|
||||
return () => {
|
||||
$parent.onfocus = null
|
||||
$parent.onblur = null
|
||||
}
|
||||
}, [])
|
||||
|
||||
const view = useRouteParamsSelector((s) => s.view)
|
||||
|
||||
const mClassName = clsx(
|
||||
"absolute z-[-1]",
|
||||
view !== FeedViewType.SocialMedia
|
||||
? "bg-zinc-200/80 dark:bg-neutral-800"
|
||||
: "bg-zinc-100 dark:bg-neutral-800/50",
|
||||
views[view].wideMode ? "inset-x-0 inset-y-1 rounded-xl" : "-inset-x-2 inset-y-0",
|
||||
className,
|
||||
)
|
||||
const motionConfig = {
|
||||
initial: {
|
||||
opacity: 0.2,
|
||||
},
|
||||
animate: {
|
||||
opacity: 1,
|
||||
},
|
||||
exit: {
|
||||
opacity: 0,
|
||||
},
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<AnimatePresence>
|
||||
{mouseEnter && !isActive && (
|
||||
<m.div
|
||||
layout
|
||||
{...motionConfig}
|
||||
layoutId="list-item-hover-overlay"
|
||||
className={mClassName}
|
||||
/>
|
||||
)}
|
||||
</AnimatePresence>
|
||||
{isActive && <m.div {...motionConfig} className={mClassName} />}
|
||||
<div
|
||||
ref={ref}
|
||||
className="relative"
|
||||
onMouseEnter={() => {
|
||||
setMouseEnter(true)
|
||||
}}
|
||||
onMouseLeave={() => {
|
||||
setMouseEnter(false)
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
}
|
||||
@@ -1,140 +0,0 @@
|
||||
import { m, useAnimation } from "framer-motion"
|
||||
import * as React from "react"
|
||||
import { cloneElement, useEffect } from "react"
|
||||
|
||||
import { cn } from "~/lib/utils"
|
||||
|
||||
interface LoadingCircleProps {
|
||||
size: "small" | "medium" | "large"
|
||||
}
|
||||
|
||||
const sizeMap = {
|
||||
small: 16,
|
||||
medium: 24,
|
||||
large: 30,
|
||||
}
|
||||
export const LoadingCircle: Component<LoadingCircleProps> = ({ className, size }) => (
|
||||
<div
|
||||
className={className}
|
||||
style={{
|
||||
fontSize: sizeMap[size],
|
||||
}}
|
||||
>
|
||||
<i className="i-mgc-loading-3-cute-re animate-spin" />
|
||||
</div>
|
||||
)
|
||||
|
||||
const sizeMap2 = {
|
||||
small: 30,
|
||||
medium: 40,
|
||||
large: 50,
|
||||
}
|
||||
|
||||
const smallIconSizeMap = {
|
||||
small: 16,
|
||||
medium: 18,
|
||||
large: 24,
|
||||
}
|
||||
export const LoadingWithIcon: Component<
|
||||
LoadingCircleProps & {
|
||||
icon: React.JSX.Element
|
||||
order?: "loading-first" | "icon-first"
|
||||
}
|
||||
> = ({ order = "loading-first", size, className, icon, children }) => {
|
||||
const rootStyle = { width: sizeMap2[size], height: sizeMap2[size] }
|
||||
|
||||
const smallIconStyle = {
|
||||
height: smallIconSizeMap[size],
|
||||
width: smallIconSizeMap[size],
|
||||
}
|
||||
|
||||
const Children = children && <div className="center flex">{children}</div>
|
||||
if (order === "icon-first") {
|
||||
return (
|
||||
<div className={className}>
|
||||
<div style={rootStyle} className="relative inline-block">
|
||||
<span className="block size-full">
|
||||
{cloneElement(icon, {
|
||||
style: {
|
||||
...icon.props.style,
|
||||
fontSize: sizeMap2[size],
|
||||
},
|
||||
className: cn(icon.props.className),
|
||||
})}
|
||||
</span>
|
||||
<span
|
||||
className="absolute bottom-1"
|
||||
style={{
|
||||
...smallIconStyle,
|
||||
right: -smallIconSizeMap[size] + 4,
|
||||
}}
|
||||
>
|
||||
<i
|
||||
className="i-mgc-loading-3-cute-re animate-spin"
|
||||
style={{ fontSize: smallIconSizeMap[size] }}
|
||||
/>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{Children}
|
||||
</div>
|
||||
)
|
||||
} else {
|
||||
return (
|
||||
<div className={className}>
|
||||
<div style={rootStyle} className="relative inline-block">
|
||||
<span
|
||||
className="block size-full"
|
||||
style={{
|
||||
clipPath: `polygon(0% 0%, 0% 100%, calc(100% - ${smallIconSizeMap[size]}px) 100%, ${smallIconSizeMap[size]}px ${smallIconSizeMap[size]}px, 100% calc(100% - ${smallIconSizeMap[size]}px), 100% 100%, 100% 100%, 100% 0%)`,
|
||||
}}
|
||||
>
|
||||
<i
|
||||
className="i-mgc-loading-3-cute-li animate-spin"
|
||||
style={{ fontSize: sizeMap2[size] }}
|
||||
/>
|
||||
</span>
|
||||
<span
|
||||
className={cn("absolute bottom-0 right-0", "animate-pulse duration-700")}
|
||||
style={smallIconStyle}
|
||||
>
|
||||
{cloneElement(icon, {
|
||||
style: {
|
||||
...icon.props.style,
|
||||
fontSize: smallIconSizeMap[size],
|
||||
width: smallIconSizeMap[size],
|
||||
height: smallIconSizeMap[size],
|
||||
},
|
||||
className: icon.props.className,
|
||||
})}
|
||||
</span>
|
||||
</div>
|
||||
{Children}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
export const RotatingRefreshIcon: React.FC<{
|
||||
isRefreshing: boolean
|
||||
className?: string
|
||||
}> = ({ isRefreshing, className }) => {
|
||||
const controls = useAnimation()
|
||||
|
||||
useEffect(() => {
|
||||
if (isRefreshing) {
|
||||
controls.set({ rotate: 0 })
|
||||
controls.start({
|
||||
rotate: 360,
|
||||
transition: { duration: 1, repeat: Infinity, ease: "linear" },
|
||||
})
|
||||
} else {
|
||||
controls.start({
|
||||
rotate: 360,
|
||||
transition: { type: "spring" },
|
||||
})
|
||||
}
|
||||
}, [isRefreshing, controls])
|
||||
|
||||
return <m.i className={cn("i-mgc-refresh-2-cute-re", className)} animate={controls} />
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
import { RootPortal } from "@follow/components/ui/portal/index.jsx"
|
||||
import type { DotLottie } from "@lottiefiles/dotlottie-react"
|
||||
import { DotLottieReact } from "@lottiefiles/dotlottie-react"
|
||||
import { atom, useAtomValue } from "jotai"
|
||||
@@ -6,8 +7,6 @@ import { useEffect, useState } from "react"
|
||||
|
||||
import { jotaiStore } from "~/lib/jotai"
|
||||
|
||||
import { RootPortal } from "../portal"
|
||||
|
||||
const portalElementsAtom = atom([] as ReactNode[])
|
||||
|
||||
export function LottieRenderContainer() {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { MemoedDangerousHTMLStyle } from "@follow/components/common/MemoedDangerousHTMLStyle.js"
|
||||
import katexStyle from "katex/dist/katex.min.css?raw"
|
||||
import { createElement, Fragment, memo, useEffect, useMemo, useRef, useState } from "react"
|
||||
|
||||
import { MemoedDangerousHTMLStyle } from "~/components/common/MemoedDangerousHTMLStyle"
|
||||
import { parseHtml } from "~/lib/parse-html"
|
||||
import { useWrappedElementSize } from "~/providers/wrapped-element-provider"
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { cn } from "@follow/utils/utils"
|
||||
import { useMemo, useState } from "react"
|
||||
|
||||
import type { RemarkOptions } from "~/lib/parse-markdown"
|
||||
import { parseMarkdown } from "~/lib/parse-markdown"
|
||||
import { cn } from "~/lib/utils"
|
||||
|
||||
import { MarkdownRenderContainerRefContext } from "./context"
|
||||
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
import { getViewport, useViewport } from "@follow/components/hooks/useViewport.js"
|
||||
import { useScrollViewElement } from "@follow/components/ui/scroll-area/hooks.js"
|
||||
import { getElementTop } from "@follow/utils/dom"
|
||||
import { springScrollToElement } from "@follow/utils/scroller"
|
||||
import { cn } from "@follow/utils/utils"
|
||||
import * as HoverCard from "@radix-ui/react-hover-card"
|
||||
import { AnimatePresence, m } from "framer-motion"
|
||||
import { throttle } from "lodash-es"
|
||||
@@ -13,18 +18,13 @@ import {
|
||||
} from "react"
|
||||
import { useEventCallback } from "usehooks-ts"
|
||||
|
||||
import { getViewport, useViewport } from "~/atoms/hooks/viewport"
|
||||
import { useUISettingKey } from "~/atoms/settings/ui"
|
||||
import { getElementTop } from "~/lib/dom"
|
||||
import { springScrollToElement } from "~/lib/scroller"
|
||||
import { cn } from "~/lib/utils"
|
||||
import {
|
||||
useGetWrappedElementPosition,
|
||||
useWrappedElementPosition,
|
||||
useWrappedElementSize,
|
||||
} from "~/providers/wrapped-element-provider"
|
||||
|
||||
import { useScrollViewElement } from "../../scroll-area/hooks"
|
||||
import { MarkdownRenderContainerRefContext } from "../context"
|
||||
import type { TocItemProps } from "./TocItem"
|
||||
import { TocItem } from "./TocItem"
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
import { EllipsisHorizontalTextWithTooltip } from "@follow/components/ui/typography/index.js"
|
||||
import { cn } from "@follow/utils/utils"
|
||||
import type { FC, MouseEvent } from "react"
|
||||
import { memo, useCallback, useRef } from "react"
|
||||
|
||||
import { cn } from "~/lib/utils"
|
||||
|
||||
import { EllipsisHorizontalTextWithTooltip } from "../../typography"
|
||||
|
||||
export interface ITocItem {
|
||||
depth: number
|
||||
title: string
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { cn } from "@follow/utils/utils"
|
||||
import { useContext } from "react"
|
||||
import { useContextSelector } from "use-context-selector"
|
||||
|
||||
import { cn } from "~/lib/utils"
|
||||
import { useWrappedElementSize } from "~/providers/wrapped-element-provider"
|
||||
|
||||
import { Media } from "../../media"
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import { useScrollViewElement } from "@follow/components/ui/scroll-area/hooks.js"
|
||||
import { springScrollToElement } from "@follow/utils/scroller"
|
||||
import { cn } from "@follow/utils/utils"
|
||||
import { useContext, useId, useRef } from "react"
|
||||
|
||||
import { springScrollToElement } from "~/lib/scroller"
|
||||
import { cn } from "~/lib/utils"
|
||||
|
||||
import { useScrollViewElement } from "../../scroll-area/hooks"
|
||||
import { MarkdownRenderContainerRefContext } from "../context"
|
||||
|
||||
export const createHeadingRenderer =
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { cn } from "@follow/utils/utils"
|
||||
import { useContext } from "react"
|
||||
|
||||
import { cn } from "~/lib/utils"
|
||||
|
||||
import { Media } from "../../media"
|
||||
import { MarkdownRenderActionContext } from "../context"
|
||||
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
import {
|
||||
Tooltip,
|
||||
TooltipContent,
|
||||
TooltipPortal,
|
||||
TooltipTrigger,
|
||||
} from "@follow/components/ui/tooltip/index.jsx"
|
||||
import { useContext } from "react"
|
||||
|
||||
import type { LinkProps } from "../../link"
|
||||
import { Tooltip, TooltipContent, TooltipPortal, TooltipTrigger } from "../../tooltip"
|
||||
import { MarkdownRenderActionContext } from "../context"
|
||||
|
||||
export const MarkdownLink = (props: LinkProps) => {
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
import type { PropsWithChildren } from "react"
|
||||
import { useCallback, useRef, useState } from "react"
|
||||
import type { MarqueeProps } from "react-fast-marquee"
|
||||
import Marquee from "react-fast-marquee"
|
||||
|
||||
export const TitleMarquee = ({
|
||||
children,
|
||||
speed = 30,
|
||||
play,
|
||||
className,
|
||||
...rest
|
||||
}: PropsWithChildren &
|
||||
MarqueeProps & {
|
||||
className?: string
|
||||
}) => {
|
||||
const [hovered, setHovered] = useState(false)
|
||||
const ref = useRef<HTMLDivElement>(null)
|
||||
|
||||
const $wrapper = useRef<HTMLDivElement>(null)
|
||||
return (
|
||||
<div
|
||||
className={className}
|
||||
ref={$wrapper}
|
||||
// className="[&_*]:scrollbar-none"
|
||||
onMouseEnter={useCallback(() => {
|
||||
const $container = ref.current
|
||||
|
||||
if (!$container) return
|
||||
|
||||
const $child = $container.querySelector(".rfm-child")
|
||||
if (!$child) return
|
||||
|
||||
const canScroll = $child.clientWidth > $container.clientWidth
|
||||
|
||||
if (!canScroll) return
|
||||
|
||||
setHovered(true)
|
||||
}, [])}
|
||||
onMouseLeave={useCallback(() => {
|
||||
setHovered(false)
|
||||
|
||||
const $container = ref.current
|
||||
if (!$container) return
|
||||
const marqueeContainer = $container
|
||||
const marqueeChildren = Array.from(marqueeContainer.children) as HTMLElement[]
|
||||
|
||||
// Force a reflow on marquee child nodes to reset animation
|
||||
marqueeChildren.forEach((marquee: HTMLElement) => {
|
||||
marquee.style.animation = "none"
|
||||
void marquee.offsetHeight
|
||||
marquee.style.animation = ""
|
||||
})
|
||||
}, [])}
|
||||
>
|
||||
<Marquee className="overflow-hidden" play={hovered} ref={ref} speed={speed} {...rest}>
|
||||
{children}
|
||||
</Marquee>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
import { nextFrame } from "@follow/utils/dom"
|
||||
import { cn } from "@follow/utils/utils"
|
||||
import { useForceUpdate } from "framer-motion"
|
||||
import type { FC, ImgHTMLAttributes, VideoHTMLAttributes } from "react"
|
||||
import { createContext, memo, useContext, useMemo, useState } from "react"
|
||||
import { Blurhash, BlurhashCanvas } from "react-blurhash"
|
||||
import { useEventCallback } from "usehooks-ts"
|
||||
|
||||
import { nextFrame } from "~/lib/dom"
|
||||
import { getImageProxyUrl } from "~/lib/img-proxy"
|
||||
import { cn } from "~/lib/utils"
|
||||
import { saveImageDimensionsToDb } from "~/store/image/db"
|
||||
|
||||
import { usePreviewMedia } from "./media/hooks"
|
||||
|
||||
@@ -3,6 +3,7 @@ import "swiper/css/navigation"
|
||||
import "swiper/css/scrollbar"
|
||||
|
||||
import type { MediaModel } from "@follow/shared/hono"
|
||||
import { cn } from "@follow/utils/utils"
|
||||
import { useHover } from "@use-gesture/react"
|
||||
import { uniqBy } from "lodash-es"
|
||||
import { useRef, useState } from "react"
|
||||
@@ -10,7 +11,6 @@ import { Mousewheel, Navigation, Scrollbar } from "swiper/modules"
|
||||
import { Swiper, SwiperSlide } from "swiper/react"
|
||||
|
||||
import { Media } from "~/components/ui/media"
|
||||
import { cn } from "~/lib/utils"
|
||||
|
||||
import styles from "./index.module.css"
|
||||
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
import { MotionButtonBase } from "@follow/components/ui/button/index.js"
|
||||
import type { HTMLMediaState } from "@follow/hooks"
|
||||
import { useRefValue, useVideo } from "@follow/hooks"
|
||||
import { nextFrame, stopPropagation } from "@follow/utils/dom"
|
||||
import { cn } from "@follow/utils/utils"
|
||||
import * as Slider from "@radix-ui/react-slider"
|
||||
import { useSingleton } from "foxact/use-singleton"
|
||||
import { m, useDragControls, useSpring } from "framer-motion"
|
||||
@@ -19,13 +24,7 @@ import { useEventCallback } from "usehooks-ts"
|
||||
|
||||
import { AudioPlayer } from "~/atoms/player"
|
||||
import { IconScaleTransition } from "~/components/ux/transition/icon"
|
||||
import { useRefValue } from "~/hooks/common"
|
||||
import type { HTMLMediaState } from "~/hooks/common/factory/createHTMLMediaHook"
|
||||
import { useVideo } from "~/hooks/common/useVideo"
|
||||
import { nextFrame, stopPropagation } from "~/lib/dom"
|
||||
import { cn } from "~/lib/utils"
|
||||
|
||||
import { MotionButtonBase } from "../button"
|
||||
import { softSpringPreset } from "../constants/spring"
|
||||
import { VolumeSlider } from "./VolumeSlider"
|
||||
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
import { ActionButton, MotionButtonBase } from "@follow/components/ui/button/index.js"
|
||||
import { RootPortal } from "@follow/components/ui/portal/index.js"
|
||||
import { IN_ELECTRON } from "@follow/shared/constants"
|
||||
import type { MediaModel } from "@follow/shared/hono"
|
||||
import { stopPropagation } from "@follow/utils/dom"
|
||||
import { cn } from "@follow/utils/utils"
|
||||
import type { FC } from "react"
|
||||
import { Fragment, useCallback, useEffect, useRef, useState } from "react"
|
||||
import { Blurhash } from "react-blurhash"
|
||||
@@ -12,15 +16,11 @@ import { useWindowSize } from "usehooks-ts"
|
||||
import { m } from "~/components/common/Motion"
|
||||
import { COPY_MAP } from "~/constants"
|
||||
import { tipcClient } from "~/lib/client"
|
||||
import { stopPropagation } from "~/lib/dom"
|
||||
import { replaceImgUrlIfNeed } from "~/lib/img-proxy"
|
||||
import { cn } from "~/lib/utils"
|
||||
import { EntryContent } from "~/modules/entry-content"
|
||||
|
||||
import { ActionButton, MotionButtonBase } from "../button"
|
||||
import { microReboundPreset } from "../constants/spring"
|
||||
import { useCurrentModal } from "../modal"
|
||||
import { RootPortal } from "../portal"
|
||||
import { VideoPlayer } from "./VideoPlayer"
|
||||
|
||||
const Wrapper: Component<{
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
import { Button } from "@follow/components/ui/button/index.js"
|
||||
import { LoadingCircle } from "@follow/components/ui/loading/index.jsx"
|
||||
import { Tooltip, TooltipContent, TooltipTrigger } from "@follow/components/ui/tooltip/index.jsx"
|
||||
import { stopPropagation } from "@follow/utils/dom"
|
||||
import { m } from "framer-motion"
|
||||
import * as React from "react"
|
||||
import { useTranslation } from "react-i18next"
|
||||
|
||||
import { Button } from "~/components/ui/button"
|
||||
import { LoadingCircle } from "~/components/ui/loading"
|
||||
import { useCurrentModal } from "~/components/ui/modal"
|
||||
import { stopPropagation } from "~/lib/dom"
|
||||
import { createErrorToaster } from "~/lib/error-parser"
|
||||
|
||||
import { Tooltip, TooltipContent, TooltipTrigger } from "../../tooltip"
|
||||
|
||||
export interface UseAsyncFetcher<T> {
|
||||
data: Nullable<T>
|
||||
error: Nullable<Error>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
/* eslint-disable react-refresh/only-export-components */
|
||||
import { useTypeScriptHappyCallback } from "@follow/hooks"
|
||||
import { useSingleton } from "foxact/use-singleton"
|
||||
import type { FC } from "react"
|
||||
import { createContext, createElement, useContext } from "react"
|
||||
@@ -9,7 +10,6 @@ import { useModalStack } from "~/components/ui/modal"
|
||||
import type { UseAsyncFetcher } from "~/components/ui/modal/helper/async-loading"
|
||||
import { AsyncModalContent } from "~/components/ui/modal/helper/async-loading"
|
||||
import { NoopChildren } from "~/components/ui/modal/stacked/custom-modal"
|
||||
import { useTypeScriptHappyCallback } from "~/hooks/common"
|
||||
|
||||
export type AsyncModalOptions<T> = {
|
||||
id: string
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { MotionButtonBase } from "@follow/components/ui/button/index.js"
|
||||
import { useTranslation } from "react-i18next"
|
||||
|
||||
import { MotionButtonBase } from "../../button"
|
||||
import { useCurrentModal } from "./hooks"
|
||||
|
||||
export const ModalClose = () => {
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import { nextFrame, stopPropagation } from "@follow/utils/dom"
|
||||
import { cn } from "@follow/utils/utils"
|
||||
import { m, useAnimationControls } from "framer-motion"
|
||||
import type { FC, PropsWithChildren } from "react"
|
||||
import { useEffect, useState } from "react"
|
||||
|
||||
import { nextFrame, stopPropagation } from "~/lib/dom"
|
||||
import { cn } from "~/lib/utils"
|
||||
|
||||
import { ModalClose } from "./components"
|
||||
import { useCurrentModal } from "./hooks"
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { cn } from "@follow/utils/utils"
|
||||
import { AnimatePresence } from "framer-motion"
|
||||
import type { FC, ReactNode } from "react"
|
||||
import { useId, useMemo } from "react"
|
||||
|
||||
import { jotaiStore } from "~/lib/jotai"
|
||||
import { cn } from "~/lib/utils"
|
||||
|
||||
import { modalStackAtom } from "./atom"
|
||||
import { ModalInternal } from "./modal"
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import { nextFrame } from "@follow/utils/dom"
|
||||
import { useAnimationControls } from "framer-motion"
|
||||
import { useCallback, useEffect } from "react"
|
||||
|
||||
import { nextFrame } from "~/lib/dom"
|
||||
|
||||
import { modalMontionConfig } from "../constants"
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { nextFrame } from "@follow/utils/dom"
|
||||
import { useCallback, useRef } from "react"
|
||||
|
||||
import { nextFrame } from "~/lib/dom"
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
import { Divider } from "@follow/components/ui/divider/index.js"
|
||||
import { RootPortalProvider } from "@follow/components/ui/portal/provider.js"
|
||||
import { EllipsisHorizontalTextWithTooltip } from "@follow/components/ui/typography/index.js"
|
||||
import { useRefValue } from "@follow/hooks"
|
||||
import { nextFrame, stopPropagation } from "@follow/utils/dom"
|
||||
import { cn, getOS } from "@follow/utils/utils"
|
||||
import * as Dialog from "@radix-ui/react-dialog"
|
||||
import type { BoundingBox } from "framer-motion"
|
||||
import { produce } from "immer"
|
||||
@@ -24,13 +30,8 @@ import { SafeFragment } from "~/components/common/Fragment"
|
||||
import { m } from "~/components/common/Motion"
|
||||
import { ErrorComponentType } from "~/components/errors/enum"
|
||||
import { ElECTRON_CUSTOM_TITLEBAR_HEIGHT, isElectronBuild } from "~/constants"
|
||||
import { useRefValue, useSwitchHotKeyScope } from "~/hooks/common"
|
||||
import { nextFrame, stopPropagation } from "~/lib/dom"
|
||||
import { cn, getOS } from "~/lib/utils"
|
||||
import { useSwitchHotKeyScope } from "~/hooks/common"
|
||||
|
||||
import { Divider } from "../../divider"
|
||||
import { RootPortalProvider } from "../../portal/provider"
|
||||
import { EllipsisHorizontalTextWithTooltip } from "../../typography"
|
||||
import { modalStackAtom } from "./atom"
|
||||
import { MODAL_STACK_Z_INDEX, modalMontionConfig } from "./constants"
|
||||
import type { CurrentModalContentProps, ModalActionsInternal } from "./context"
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { cn } from "@follow/utils/utils"
|
||||
import * as Dialog from "@radix-ui/react-dialog"
|
||||
import { AnimatePresence } from "framer-motion"
|
||||
import type { ForwardedRef } from "react"
|
||||
import { forwardRef } from "react"
|
||||
|
||||
import { m } from "~/components/common/Motion"
|
||||
import { cn } from "~/lib/utils"
|
||||
|
||||
export const ModalOverlay = forwardRef(
|
||||
(
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { cn } from "@follow/utils/utils"
|
||||
import type { JSX } from "react"
|
||||
|
||||
import { cn } from "~/lib/utils"
|
||||
|
||||
export const Paper: Component<{
|
||||
as?: keyof JSX.IntrinsicElements | Component
|
||||
}> = ({ children, className, as: As = "main" }) => (
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
import type { SVGProps } from "react"
|
||||
|
||||
export function SimpleIconsEagle(props: SVGProps<SVGSVGElement>) {
|
||||
return (
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24" {...props}>
|
||||
<path
|
||||
fill="currentColor"
|
||||
d="M12 0C5.373 0 0 5.373 0 12s5.373 12 12 12s12-5.373 12-12S18.627 0 12 0m.04 3.858c1.32.019 2.634.335 3.78.989c.549.31.957.642 1.238.895a6.9 6.9 0 0 0-2.25 3.04c-.06.165-.123.354-.183.546a7 7 0 0 0-.252 1.605c-.003.162.002.374.003.578c.012.242.05.519.08.789a7 7 0 0 0 1.753 3.586a6.9 6.9 0 0 0 1.87 1.42a7.8 7.8 0 0 1-2.629 2.166a7.7 7.7 0 0 1-3.846.808l-.22-.013a7.7 7.7 0 0 1-1.504-.247a8.2 8.2 0 0 1-2.83-1.354a7.1 7.1 0 0 1-1.894-2.1c-.22-.38-1.49-2.644-.769-5.452A7.26 7.26 0 0 1 5.93 8.18a5.5 5.5 0 0 0-2.105 1.082C4.12 8.573 5.306 6 8.217 4.66a8.9 8.9 0 0 1 3.823-.8zm5.702 2.508c.202.126.464.309.736.572c.108.103.478.468.82 1.054c.413.703.549 1.327.62 1.65a5.5 5.5 0 0 1 .013 2.302a7.1 7.1 0 0 0-2.044-1.688a7.2 7.2 0 0 0-1.551.3a7 7 0 0 0-1.05.422a6 6 0 0 1 .267-1.563a6 6 0 0 1 .806-1.643a6.3 6.3 0 0 1 1.383-1.406"
|
||||
/>
|
||||
</svg>
|
||||
)
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
import type { SVGProps } from "react"
|
||||
|
||||
export function SimpleIconsInstapaper(props: SVGProps<SVGSVGElement>) {
|
||||
return (
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 90 90" {...props}>
|
||||
<path
|
||||
d="M60.942 77.897c-4.244-.308-6.996-.946-8.251-1.923-1.255-.971-1.883-3.496-1.883-7.562V21.446c0-3.884.628-6.384 1.883-7.501 1.255-1.118 4.007-1.78 8.251-1.987V10H30.077v1.958c4.244.207 6.994.87 8.252 1.987 1.257 1.117 1.884 3.617 1.884 7.5v46.968c0 4.066-.627 6.59-1.884 7.562-1.258.976-4.008 1.614-8.252 1.922v1.96h30.865v-1.96Z"
|
||||
fill="currentColor"
|
||||
/>
|
||||
</svg>
|
||||
)
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
import type { SVGProps } from "react"
|
||||
|
||||
export function SimpleIconsOmnivore(props: SVGProps<SVGSVGElement>) {
|
||||
return (
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 16 16" {...props}>
|
||||
<path
|
||||
fill="#3D3D3D"
|
||||
d="M15.9 7.801c0 .507-.123 1.12-.248 1.656v.004l-.001.003a2.87 2.87 0 0 1-2.793 2.186h-.036c-1.625 0-2.649-1.334-2.649-2.828v-2.14l-1.21 1.794-.067.055a1.404 1.404 0 0 1-1.793 0l-.065-.053-1.248-1.82v4.414H4.6V6.268c0-.91 1.078-1.439 1.794-.802l.055.048 1.46 2.13a.21.21 0 0 0 .179 0l1.43-2.119.065-.054c.68-.567 1.78-.138 1.78.815v2.536c0 .971.619 1.638 1.46 1.638h.035c.78 0 1.45-.527 1.636-1.277.125-.534.216-1.026.216-1.378-.017-3.835-3.262-6.762-7.188-6.498-3.311.23-5.986 2.905-6.216 6.216A6.705 6.705 0 0 0 8 14.693v1.19a7.895 7.895 0 0 1-7.882-8.44C.39 3.536 3.536.39 7.44.118 12.017-.19 15.88 3.242 15.9 7.8z"
|
||||
/>
|
||||
</svg>
|
||||
)
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
import type { SVGProps } from "react"
|
||||
|
||||
export function SimpleIconsReadwise(props: SVGProps<SVGSVGElement>) {
|
||||
return (
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="1em"
|
||||
height="1em"
|
||||
viewBox="0 0 150 150"
|
||||
{...props}
|
||||
>
|
||||
<path d="M0,0H150V150H0V0Z" fill="none" />
|
||||
<path
|
||||
d="M121.74,120.25c4.48,7.45,8.13,9.92,15.6,10.81v7.45h-36.84l-34.51-57.6h-8.62v37.75c0,10.11,2.5,11.51,13.12,12.4v7.45H14.87v-7.45c10.62-.89,13.12-2.31,13.12-12.4V34.31c0-10.27-2.17-11.51-13.12-12.4v-7.45h57.24c34.51,0,52.54,7.26,52.54,32.78,0,19.31-9.39,28.53-28.3,31.71l25.39,41.3Z"
|
||||
fill="currentColor"
|
||||
/>
|
||||
<path
|
||||
d="M94.29,27.75c-2.93,5.38,1.59,30.76,1.59,30.76,.06,1.34-.85,2.52-2.17,2.81,0,0-27.66,.12-36.8,7.72L94.29,27.75Z"
|
||||
fill="white"
|
||||
/>
|
||||
</svg>
|
||||
)
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
import type { SVGProps } from "react"
|
||||
|
||||
export function TokenBrandedRss3(props: SVGProps<SVGSVGElement>) {
|
||||
return (
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24" {...props}>
|
||||
<path
|
||||
fill="#0B70FF"
|
||||
d="M7.833 10.884c-.004.737-.55 1.333-1.304 1.325l1.225 1.875h.496v.416H6.583v-.416h.542l-1.158-1.875h-1.05v1.875h.416v.416h-1.25v-.416H4.5V9.917h-.417V9.5H6.43c.792 0 1.396.58 1.404 1.384M6.4 9.917H4.917v1.875H6.5a.95.95 0 0 0 .917-.904c.02-.513-.5-.971-1.017-.971m4.308 1.738c.513.129 1.192.329 1.5.758q.128.18.167.4c.042.137.05.283.033.429q-.04.25-.166.462a1.4 1.4 0 0 1-.309.367a1.93 1.93 0 0 1-1.291.43h-.034a2.57 2.57 0 0 1-1.525-.563v.562h-.416v-1.666h.416v.408c.338.542 1.1.842 1.692.842c.55-.009 1.342-.471 1.225-1.109c-.117-.533-.937-.779-1.392-.887l-.241-.067l-.046-.012c-.675-.175-1.471-.38-1.446-1.25c-.017-.88.78-1.259 1.53-1.259c.5.013.778.171 1.178.463V9.5H12v1.667h-.417v-.542c-.358-.5-.696-.7-1.179-.708c-.467 0-1.07.296-1.112.842c.033.52.558.658 1.02.775c.146.041.284.075.396.12m8.459.166c.47.163.75.592.75 1.22c0 .897-.78 1.46-1.713 1.46a2.27 2.27 0 0 1-1.62-.696l.312-.396l.029.033a1.8 1.8 0 0 0 1.283.642c.684 0 1.267-.446 1.296-1.075c0-.563-.517-1.009-1.142-1.009h-.529v-.416h.496c.5 0 .963-.292.963-.792c0-.53-.467-.875-1.121-.875c-.53 0-.808.28-.996.542l-.375-.23a1.51 1.51 0 0 1 1.375-.729c.9 0 1.533.388 1.533 1.25c0 .396-.133.834-.541 1.067zm-2.792.592c-.308-.43-.988-.625-1.5-.758a3 3 0 0 0-.396-.121c-.458-.117-.987-.255-1.02-.775c.041-.542.645-.842 1.112-.842c.483.008.82.208 1.179.708v.542h.417V9.5h-.417v.463c-.4-.292-.68-.45-1.18-.463c-.75 0-1.54.375-1.528 1.259c-.025.87.77 1.075 1.446 1.25l.045.012l.242.067c.458.108 1.275.354 1.392.887c.116.638-.675 1.1-1.225 1.109c-.592 0-1.354-.304-1.692-.842v-.408h-.417V14.5h.417v-.562c.434.347.97.545 1.525.562h.033c.271 0 .85-.033 1.292-.429q.19-.155.308-.367c.084-.141.142-.3.167-.462a1.1 1.1 0 0 0-.033-.43a1 1 0 0 0-.167-.4M2 11.583h1.25v.834H2zm18.75 0H22v.834h-1.25z"
|
||||
/>
|
||||
</svg>
|
||||
)
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
export * from "./collections/eagle"
|
||||
export * from "./collections/instapaper"
|
||||
export * from "./collections/obsidian"
|
||||
export * from "./collections/omnivore"
|
||||
export * from "./collections/readwise"
|
||||
export * from "./collections/rss3"
|
||||
@@ -1,47 +0,0 @@
|
||||
import { Slot } from "@radix-ui/react-slot"
|
||||
import type { FC } from "react"
|
||||
|
||||
import * as LinkParsers from "~/lib/link-parser"
|
||||
import { cn } from "~/lib/utils"
|
||||
|
||||
import { getSupportedPlatformIconName } from "./utils"
|
||||
|
||||
const IconMap = Object.values(LinkParsers).reduce(
|
||||
(acc, parser) => {
|
||||
acc[parser.parserName] = parser.icon
|
||||
return acc
|
||||
},
|
||||
{} as Record<string, string>,
|
||||
)
|
||||
|
||||
const shouldAddWhiteBgUrls = ["1x.com"]
|
||||
export const PlatformIcon: FC<{
|
||||
url?: string
|
||||
children: React.JSX.Element
|
||||
className?: string
|
||||
style?: React.CSSProperties
|
||||
}> = ({ className, url, children, style, ...rest }) => {
|
||||
const iconName = url && getSupportedPlatformIconName(url)
|
||||
|
||||
if (!iconName || !IconMap[iconName] || !url) {
|
||||
return (
|
||||
<Slot
|
||||
className={`${url && shouldAddWhiteBgUrls.some((_) => url.includes(_)) ? "bg-white" : ""} ${className}`}
|
||||
style={style}
|
||||
{...rest}
|
||||
>
|
||||
{children}
|
||||
</Slot>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<i
|
||||
className={cn(`${IconMap[iconName]} ${className}`)}
|
||||
style={{
|
||||
...style,
|
||||
maskImage: "var(--svg)",
|
||||
}}
|
||||
/>
|
||||
)
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user