⚡️⚡️⚡️ Self-hosted collaborative bookmark manager to collect, read, annotate, and fully preserve what matters, all in one place.
TypeScript bookmarkbookmark-managercollaborationnextjsreact-nativeread-it-laterself-hostedtypescript
move cancel icon to a X button at the top right side of the action sheets + more consistent action sheet layouts
daniel31x13ec0c9b64ccb3
diff --git a/apps/mobile/components/ActionSheets/AddLinkSheet.tsx b/apps/mobile/components/ActionSheets/AddLinkSheet.tsxindex 6a3829b4..a51d03ef 100644--- a/apps/mobile/components/ActionSheets/AddLinkSheet.tsx+++ b/apps/mobile/components/ActionSheets/AddLinkSheet.tsx@@ -8,6 +8,7 @@ import useAuthStore from "@/store/auth";import { rawTheme, ThemeName } from "@/lib/colors";import { useColorScheme } from "nativewind";import { useSafeAreaInsets } from "react-native-safe-area-context";+import SheetHeader from "./SheetHeader";export default function AddLinkSheet() {const actionSheetRef = useRef<ActionSheetRef>(null);@@ -18,6 +19,11 @@ export default function AddLinkSheet() {const insets = useSafeAreaInsets();+ const closeSheet = () => {+ actionSheetRef.current?.hide();+ setLink("");+ };+return (<ActionSheetref={actionSheetRef}@@ -29,12 +35,13 @@ export default function AddLinkSheet() {backgroundColor: rawTheme[colorScheme as ThemeName]["base-200"],}}safeAreaInsets={insets}+ onClose={() => {+ setLink("");+ }}>- <View className="px-8 py-5">- <Text className="font-semibold text-lg mx-auto mb-5 text-base-content">- New Link- </Text>+ <SheetHeader title="New Link" onClose={closeSheet} />+ <View className="px-8 pb-5"><Inputplaceholder="e.g. https://example.com"className="mb-4 bg-base-100"@@ -51,21 +58,9 @@ export default function AddLinkSheet() {}}isLoading={addLink.isPending}variant="accent"- className="mb-2"><Text className="text-white">Save to Linkwarden</Text></Button>-- <Button- onPress={() => {- actionSheetRef.current?.hide();- setLink("");- }}- variant="outline"- className="mb-2"- >- <Text className="text-base-content">Cancel</Text>- </Button></View></ActionSheet>);diff --git a/apps/mobile/components/ActionSheets/EditLinkSheet.tsx b/apps/mobile/components/ActionSheets/EditLinkSheet.tsxindex 06ecc41f..1168b32a 100644--- a/apps/mobile/components/ActionSheets/EditLinkSheet.tsx+++ b/apps/mobile/components/ActionSheets/EditLinkSheet.tsx@@ -10,7 +10,7 @@ import ActionSheet, {} from "react-native-actions-sheet";import Input from "@/components/ui/Input";import { Button } from "@/components/ui/Button";-import { useAddLink, useUpdateLink } from "@linkwarden/router/links";+import { useUpdateLink } from "@linkwarden/router/links";import useAuthStore from "@/store/auth";import {CollectionIncludingMembersAndLinkCount,@@ -32,6 +32,7 @@ import useTmpStore from "@/store/tmp";import { useSafeAreaInsets } from "react-native-safe-area-context";import { useTags } from "@linkwarden/router/tags";import { isAtLeastInstanceVersion, useConfig } from "@linkwarden/router/config";+import SheetHeader from "./SheetHeader";const MIN_TAG_SEARCH_VERSION = "2.14.1";@@ -56,115 +57,108 @@ const Main = (props: SheetProps<"edit-link-sheet">) => {const { tmp, updateTmp } = useTmpStore();return (- <View className="px-8 py-5">- <Text className="font-semibold text-lg mx-auto mb-5 text-base-content">- Edit Link- </Text>-- <Input- placeholder="Name"- className="mb-4 bg-base-100"- value={link?.name || ""}- onChangeText={(text) => link?.id && setLink({ ...link, name: text })}+ <>+ <SheetHeader+ title="Edit Link"+ onClose={() => {+ void SheetManager.hide("edit-link-sheet");+ }}/>- {props.payload?.link?.url && (+ <View className="px-8 pb-5"><Input- placeholder="URL"+ placeholder="Name"className="mb-4 bg-base-100"- value={link?.url || ""}- onChangeText={(text) => link?.id && setLink({ ...link, url: text })}+ value={link?.name || ""}+ onChangeText={(text) => link?.id && setLink({ ...link, name: text })}/>- )}-- <Button- variant="input"- className="mb-4"- onPress={() => router?.navigate("collections", { link })}- >- <View className="flex-row items-center gap-2 w-[90%]">- <Folder- size={20}- fill={link?.collection.color || "gray"}- color={link?.collection.color || "gray"}++ {props.payload?.link?.url && (+ <Input+ placeholder="URL"+ className="mb-4 bg-base-100"+ value={link?.url || ""}+ onChangeText={(text) => link?.id && setLink({ ...link, url: text })}/>- <Text numberOfLines={1} className="w-[90%] text-base-content">- {link?.collection.name}- </Text>- </View>- <ChevronRight- size={16}- color={rawTheme[colorScheme as ThemeName]["neutral"]}- />- </Button>-- <Button- variant="input"- className="mb-4 h-auto"- onPress={() => router?.navigate("tags", { link })}- >- {link?.tags && link?.tags.length > 0 ? (- <View className="flex-row flex-wrap items-center gap-2 w-[90%]">- {link.tags.map((tag) => (- <View- key={tag.id}- className="bg-neutral rounded-md h-7 px-2 py-1"- >- <Text numberOfLines={1} className="text-base-100">- {tag.name}- </Text>- </View>- ))}- </View>- ) : (- <Text className="text-neutral">No tags</Text>)}- <ChevronRight size={16} color={"gray"} />- </Button>- <Input- multiline- textAlignVertical="top"- placeholder="Description"- className="mb-4 h-28 bg-base-100"- value={link?.description || ""}- onChangeText={(text) =>- link?.id && setLink({ ...link, description: text })- }- />+ <Button+ variant="input"+ className="mb-4"+ onPress={() => router?.navigate("collections", { link })}+ >+ <View className="flex-row items-center gap-2 w-[90%]">+ <Folder+ size={20}+ fill={link?.collection.color || "gray"}+ color={link?.collection.color || "gray"}+ />+ <Text numberOfLines={1} className="w-[90%] text-base-content">+ {link?.collection.name}+ </Text>+ </View>+ <ChevronRight+ size={16}+ color={rawTheme[colorScheme as ThemeName]["neutral"]}+ />+ </Button>- <Button- onPress={() => {- updateLink.mutate(link as LinkIncludingShortenedCollectionAndTags);- if (link && tmp.link)- updateTmp({- link,- });- SheetManager.hide("edit-link-sheet");- }}- isLoading={updateLink.isPending}- variant="accent"- className="mb-2"- >- <Text className="text-white">Save</Text>- </Button>-- <Button- onPress={() => {- SheetManager.hide("edit-link-sheet");- }}- variant="outline"- className="mb-2"- >- <Text className="text-base-content">Cancel</Text>- </Button>- </View>+ <Button+ variant="input"+ className="mb-4 h-auto"+ onPress={() => router?.navigate("tags", { link })}+ >+ {link?.tags && link?.tags.length > 0 ? (+ <View className="flex-row flex-wrap items-center gap-2 w-[90%]">+ {link.tags.map((tag) => (+ <View+ key={tag.id}+ className="bg-neutral rounded-md h-7 px-2 py-1"+ >+ <Text numberOfLines={1} className="text-base-100">+ {tag.name}+ </Text>+ </View>+ ))}+ </View>+ ) : (+ <Text className="text-neutral">No tags</Text>+ )}+ <ChevronRight size={16} color={"gray"} />+ </Button>++ <Input+ multiline+ textAlignVertical="top"+ placeholder="Description"+ className="mb-4 h-28 bg-base-100"+ value={link?.description || ""}+ onChangeText={(text) =>+ link?.id && setLink({ ...link, description: text })+ }+ />++ <Button+ onPress={() => {+ updateLink.mutate(link as LinkIncludingShortenedCollectionAndTags);+ if (link && tmp.link)+ updateTmp({+ link,+ });+ SheetManager.hide("edit-link-sheet");+ }}+ isLoading={updateLink.isPending}+ variant="accent"+ >+ <Text className="text-white">Save</Text>+ </Button>+ </View>+ </>);};const Collections = () => {const { auth } = useAuthStore();- const addLink = useAddLink({ auth });const [searchQuery, setSearchQuery] = useState("");const router = useSheetRouter("edit-link-sheet");const { link: currentLink } = useSheetRouteParams<@@ -224,27 +218,32 @@ const Collections = () => {</Button>);},- [addLink, params.link, router]+ [colorScheme, currentLink, params.link, router]);return (- <View className="py-5 max-h-[80vh]">- <TouchableOpacity- className="flex-row items-center gap-1 top-6 left-8 absolute"- onPress={() => {- router?.popToTop();- router?.navigate("main", { link: currentLink });+ <View className="max-h-[80vh]">+ <SheetHeader+ title="Collection"+ onClose={() => {+ void SheetManager.hide("edit-link-sheet");}}- >- <ChevronLeft- size={18}- color={rawTheme[colorScheme as ThemeName]["primary"]}- />- <Text className="text-primary">Back</Text>- </TouchableOpacity>- <Text className="font-semibold text-lg mx-auto mb-5 text-base-content">- Collection- </Text>+ leftSlot={+ <TouchableOpacity+ className="flex-row items-center gap-1"+ onPress={() => {+ router?.popToTop();+ router?.navigate("main", { link: currentLink });+ }}+ >+ <ChevronLeft+ size={18}+ color={rawTheme[colorScheme as ThemeName]["primary"]}+ />+ <Text className="text-primary">Back</Text>+ </TouchableOpacity>+ }+ /><Inputplaceholder="Search collections"className="mb-4 bg-base-100 mx-8"@@ -272,7 +271,6 @@ const Collections = () => {const Tags = () => {const { auth } = useAuthStore();- const addLink = useAddLink({ auth });const [searchQuery, setSearchQuery] = useState("");const router = useSheetRouter("edit-link-sheet");const params = useSheetRouteParams("edit-link-sheet", "tags");@@ -373,27 +371,32 @@ const Tags = () => {</Button>);},- [addLink, params.link, router]+ [colorScheme, updatedLink]);return (- <View className="py-5 max-h-[80vh]">- <TouchableOpacity- className="flex-row items-center gap-1 top-6 left-8 absolute"- onPress={() => {- router?.popToTop();- router?.navigate("main", { link: updatedLink });+ <View className="max-h-[80vh]">+ <SheetHeader+ title="Tags"+ onClose={() => {+ void SheetManager.hide("edit-link-sheet");}}- >- <ChevronLeft- size={18}- color={rawTheme[colorScheme as ThemeName]["primary"]}- />- <Text className="text-primary">Back</Text>- </TouchableOpacity>- <Text className="font-semibold text-lg mx-auto mb-5 text-base-content">- Tags- </Text>+ leftSlot={+ <TouchableOpacity+ className="flex-row items-center gap-1"+ onPress={() => {+ router?.popToTop();+ router?.navigate("main", { link: updatedLink });+ }}+ >+ <ChevronLeft+ size={18}+ color={rawTheme[colorScheme as ThemeName]["primary"]}+ />+ <Text className="text-primary">Back</Text>+ </TouchableOpacity>+ }+ /><Inputplaceholder="Search tags"className="mb-4 bg-base-100 mx-8"@@ -414,7 +417,7 @@ const Tags = () => {color={rawTheme[colorScheme as ThemeName].primary}/><Text className="text-base-content">- Add tag "{normalizedSearchQuery}"+ {`Add tag "${normalizedSearchQuery}"`}</Text></View></Button>diff --git a/apps/mobile/components/ActionSheets/NewCollectionSheet.tsx b/apps/mobile/components/ActionSheets/NewCollectionSheet.tsxindex 7e5e4082..8b64a801 100644--- a/apps/mobile/components/ActionSheets/NewCollectionSheet.tsx+++ b/apps/mobile/components/ActionSheets/NewCollectionSheet.tsx@@ -8,6 +8,7 @@ import { rawTheme, ThemeName } from "@/lib/colors";import { useColorScheme } from "nativewind";import { useCreateCollection } from "@linkwarden/router/collections";import { useSafeAreaInsets } from "react-native-safe-area-context";+import SheetHeader from "./SheetHeader";export default function NewCollectionSheet() {const actionSheetRef = useRef<ActionSheetRef>(null);@@ -21,6 +22,14 @@ export default function NewCollectionSheet() {const insets = useSafeAreaInsets();+ const closeSheet = () => {+ actionSheetRef.current?.hide();+ setCollection({+ name: "",+ description: "",+ });+ };+return (<ActionSheetref={actionSheetRef}@@ -32,12 +41,16 @@ export default function NewCollectionSheet() {backgroundColor: rawTheme[colorScheme as ThemeName]["base-200"],}}safeAreaInsets={insets}+ onClose={() => {+ setCollection({+ name: "",+ description: "",+ });+ }}>- <View className="px-8 py-5">- <Text className="font-semibold text-lg mx-auto mb-5 text-base-content">- New Collection- </Text>+ <SheetHeader title="New Collection" onClose={closeSheet} />+ <View className="px-8 pb-5"><Inputplaceholder="Name"className="mb-4 bg-base-100"@@ -75,21 +88,9 @@ export default function NewCollectionSheet() {}isLoading={createCollection.isPending}variant="accent"- className="mb-2"><Text className="text-white">Save Collection</Text></Button>-- <Button- onPress={() => {- actionSheetRef.current?.hide();- setCollection({ name: "", description: "" });- }}- variant="outline"- className="mb-2"- >- <Text className="text-base-content">Cancel</Text>- </Button></View></ActionSheet>);diff --git a/apps/mobile/components/ActionSheets/ReadableHighlightSheet.tsx b/apps/mobile/components/ActionSheets/ReadableHighlightSheet.tsxindex 707da683..ae2e2a51 100644--- a/apps/mobile/components/ActionSheets/ReadableHighlightSheet.tsx+++ b/apps/mobile/components/ActionSheets/ReadableHighlightSheet.tsx@@ -15,6 +15,7 @@ import {usePostHighlight,useRemoveHighlight,} from "@linkwarden/router/highlights";+import SheetHeader from "./SheetHeader";export const HIGHLIGHT_COLORS = [{@@ -142,11 +143,9 @@ export default function ReadableHighlightSheet(setDraft(null);}}>- <View className="px-8 py-5">- <Text className="font-semibold text-lg mx-auto mb-5 text-base-content">- Highlight- </Text>+ <SheetHeader title="Highlight" onClose={closeSheet} />+ <View className="px-8 pb-5"><View className="flex-row items-center justify-center gap-4 mb-4">{HIGHLIGHT_COLORS.map((colorOption) => {const isSelected = draft?.color === colorOption.name;@@ -233,15 +232,11 @@ export default function ReadableHighlightSheet(color: theme["error"],}}>- Remove Highlight+ Clear</Text></View></Button>) : null}-- <Button onPress={closeSheet} variant="outline" className="mb-2">- <Text className="text-base-content">Cancel</Text>- </Button></View></ActionSheet>);diff --git a/apps/mobile/components/ActionSheets/ReadableHighlightsSheet.tsx b/apps/mobile/components/ActionSheets/ReadableHighlightsSheet.tsxindex 01cef933..1b12a8c7 100644--- a/apps/mobile/components/ActionSheets/ReadableHighlightsSheet.tsx+++ b/apps/mobile/components/ActionSheets/ReadableHighlightsSheet.tsx@@ -21,8 +21,8 @@ import {} from "@linkwarden/router/highlights";import { rawTheme, ThemeName } from "@/lib/colors";import useAuthStore from "@/store/auth";-import { Button } from "@/components/ui/Button";import { HIGHLIGHT_COLORS } from "./ReadableHighlightSheet";+import SheetHeader from "./SheetHeader";const highlightColorMap = Object.fromEntries(HIGHLIGHT_COLORS.map((colorOption) => [colorOption.name, colorOption])@@ -102,11 +102,7 @@ export default function ReadableHighlightsSheet(}}safeAreaInsets={insets}>- <View className="px-6 pt-5 pb-3">- <Text className="font-semibold text-lg text-center text-base-content">- Notes & Highlights- </Text>- </View>+ <SheetHeader title="Notes & Highlights" onClose={closeSheet} />{isLoading ? (<View className="px-6 py-10 items-center">@@ -195,12 +191,6 @@ export default function ReadableHighlightsSheet(}}/>)}-- <View className="px-6 pb-4">- <Button onPress={closeSheet} variant="outline">- <Text className="text-base-content">Close</Text>- </Button>- </View></ActionSheet>);}diff --git a/apps/mobile/components/ActionSheets/ReaderSettingsSheet.tsx b/apps/mobile/components/ActionSheets/ReaderSettingsSheet.tsxindex 484f3a4a..fe0be537 100644--- a/apps/mobile/components/ActionSheets/ReaderSettingsSheet.tsx+++ b/apps/mobile/components/ActionSheets/ReaderSettingsSheet.tsx@@ -17,6 +17,7 @@ import useReaderStore, {READER_FONT_SIZES,READER_LINE_HEIGHTS,} from "@/store/reader";+import SheetHeader from "./SheetHeader";const FONT_LABELS = {"sans-serif": "Sans Serif",@@ -143,11 +144,7 @@ export default function ReaderSettingsSheet(}}safeAreaInsets={insets}>- <View className="px-6 pt-5 pb-3">- <Text className="font-semibold text-lg text-center text-base-content">- Display Settings- </Text>- </View>+ <SheetHeader title="Display Settings" onClose={closeSheet} /><ScrollViewstyle={{@@ -267,14 +264,10 @@ export default function ReaderSettingsSheet(void resetReader();}}variant="outline"- className="mb-2"disabled={JSON.stringify(reader) === JSON.stringify(READER_DEFAULTS)}><Text className="text-base-content">Reset to Defaults</Text></Button>- <Button onPress={closeSheet} variant="outline">- <Text className="text-base-content">Close</Text>- </Button></View></ActionSheet>);diff --git a/apps/mobile/components/ActionSheets/SheetHeader.tsx b/apps/mobile/components/ActionSheets/SheetHeader.tsxnew file mode 100644index 00000000..c24bd564--- /dev/null+++ b/apps/mobile/components/ActionSheets/SheetHeader.tsx@@ -0,0 +1,68 @@+import type { ReactNode } from "react";+import { Text, TouchableOpacity, View } from "react-native";+import { X } from "lucide-react-native";+import { useColorScheme } from "nativewind";+import { cn } from "@linkwarden/lib/utils";+import { rawTheme, ThemeName } from "@/lib/colors";++type SheetHeaderProps = {+ title: string;+ onClose: () => void;+ leftSlot?: ReactNode;+ align?: "center" | "left";+ className?: string;+ titleClassName?: string;+};++export default function SheetHeader({+ title,+ onClose,+ leftSlot,+ align = "center",+ className,+ titleClassName,+}: SheetHeaderProps) {+ const { colorScheme } = useColorScheme();+ const theme = rawTheme[colorScheme as ThemeName];++ return (+ <View+ className={cn(+ "relative min-h-10 justify-center px-8 pt-5 pb-5",+ className+ )}+ >+ {leftSlot ? (+ <View className="absolute left-5 top-0 bottom-0 justify-center z-10">+ {leftSlot}+ </View>+ ) : null}++ <Text+ className={cn(+ "font-semibold text-lg text-base-content",+ align === "center"+ ? "text-center px-12"+ : leftSlot+ ? "text-left pl-12 pr-12"+ : "text-left pr-12",+ titleClassName+ )}+ >+ {title}+ </Text>++ <View className="absolute right-5 top-0 bottom-0 justify-center z-10">+ <TouchableOpacity+ activeOpacity={0.5}+ accessibilityRole="button"+ accessibilityLabel={`Close ${title}`}+ className="h-10 w-10 items-center justify-center rounded-full bg-base-100"+ onPress={onClose}+ >+ <X size={18} color={theme["base-content"]} />+ </TouchableOpacity>+ </View>+ </View>+ );+}diff --git a/apps/mobile/components/ActionSheets/SupportSheet.tsx b/apps/mobile/components/ActionSheets/SupportSheet.tsxindex 0487565d..eaa96cbd 100644--- a/apps/mobile/components/ActionSheets/SupportSheet.tsx+++ b/apps/mobile/components/ActionSheets/SupportSheet.tsx@@ -1,11 +1,12 @@import { Text, View } from "react-native";import { useState } from "react";-import ActionSheet from "react-native-actions-sheet";+import ActionSheet, { SheetManager } from "react-native-actions-sheet";import { rawTheme, ThemeName } from "@/lib/colors";import { useColorScheme } from "nativewind";import * as Clipboard from "expo-clipboard";import { Button } from "../ui/Button";import { useSafeAreaInsets } from "react-native-safe-area-context";+import SheetHeader from "./SheetHeader";export default function SupportSheet() {const { colorScheme } = useColorScheme();@@ -19,6 +20,10 @@ export default function SupportSheet() {const insets = useSafeAreaInsets();+ const closeSheet = () => {+ void SheetManager.hide("support-sheet");+ };+return (<ActionSheetgestureEnabled@@ -30,8 +35,14 @@ export default function SupportSheet() {}}safeAreaInsets={insets}>- <View className="px-8 py-5 flex-col gap-4">- <Text className="text-2xl font-bold text-base-content">Need help?</Text>+ <SheetHeader+ title="Need help?"+ onClose={closeSheet}+ align="left"+ titleClassName="text-2xl font-bold"+ />++ <View className="px-8 pb-5 flex-col gap-4"><Text className="text-base-content">Whether you have a question or need assistance, feel free to reach outto us at [email protected]