From e14328447eeee198a943d4b0d53b70a1f9ef4275 Mon Sep 17 00:00:00 2001 From: celine Date: Wed, 7 Jan 2026 13:51:37 -0500 Subject: [PATCH] updates to toggle, added post options to pub settings, updates build script so lexgen works on mac --- .../dashboard/settings/PostOptions.tsx | 93 +++++++++++++++++-- .../ThemeManager/Pickers/PageThemePickers.tsx | 30 +++--- .../PubPickers/PubBackgroundPickers.tsx | 21 ++--- components/ThemeManager/ThemeSetter.tsx | 14 +-- components/Toggle.tsx | 52 +++++++---- lexicons/fix-extensions.ts | 44 +++++++++ package.json | 2 +- 7 files changed, 185 insertions(+), 71 deletions(-) create mode 100644 lexicons/fix-extensions.ts diff --git a/app/lish/[did]/[publication]/dashboard/settings/PostOptions.tsx b/app/lish/[did]/[publication]/dashboard/settings/PostOptions.tsx index ad10c9bf..56f6106c 100644 --- a/app/lish/[did]/[publication]/dashboard/settings/PostOptions.tsx +++ b/app/lish/[did]/[publication]/dashboard/settings/PostOptions.tsx @@ -1,12 +1,53 @@ +import { PubLeafletPublication } from "lexicons/api"; +import { usePublicationData } from "../PublicationSWRProvider"; import { PubSettingsHeader } from "./PublicationSettings"; +import { useState } from "react"; +import { Toggle } from "components/Toggle"; +import { updatePublication } from "app/lish/createPub/updatePublication"; +import { useToaster } from "components/Toast"; +import { mutate } from "swr"; export const PostOptions = (props: { backToMenu: () => void; loading: boolean; setLoading: (l: boolean) => void; }) => { + let { data } = usePublicationData(); + + let { publication: pubData } = data || {}; + let record = pubData?.record as PubLeafletPublication.Record; + + let [showComments, setShowComments] = useState( + record?.preferences?.showComments === undefined + ? true + : record.preferences.showComments, + ); + let [showMentions, setShowMentions] = useState(true); + let [showPrevNext, setShowPrevNext] = useState(true); + + let toast = useToaster(); return ( -
+
{ + if (!pubData) return; + e.preventDefault(); + props.setLoading(true); + let data = await updatePublication({ + uri: pubData.uri, + name: nameValue, + description: descriptionValue, + iconFile: iconFile, + preferences: { + showInDiscover: showInDiscover, + showComments: showComments, + }, + }); + toast({ type: "success", content: "Posts Updated!" }); + props.setLoading(false); + mutate("publication-data"); + }} + className="text-primary flex flex-col" + > Post Options -

Layout

-
Post Width
-
Show Prev Next Buttons
-
-

Interactions

-
Show Comments
-
Show Mentions
-
+

Layout

+
Max Post Width
+ { + setShowPrevNext(!showPrevNext); + }} + > +
+
Show Prev/Next Buttons
+
+ Show buttons that navigate to the previous and next posts +
+
+
+
+

Interactions

+
+ { + setShowComments(!showComments); + }} + > +
Show Comments
+
+ + { + setShowMentions(!showMentions); + }} + > +
+
Show Mentions
+
+ Display a list of posts on Bluesky that mention your post +
+
+
+
+ ); }; diff --git a/components/ThemeManager/Pickers/PageThemePickers.tsx b/components/ThemeManager/Pickers/PageThemePickers.tsx index 5238caa8..7c730731 100644 --- a/components/ThemeManager/Pickers/PageThemePickers.tsx +++ b/components/ThemeManager/Pickers/PageThemePickers.tsx @@ -394,27 +394,21 @@ export const PageBorderHider = (props: { return ( <> -
- { - handleToggle(); - }} - disabledColor1="#8C8C8C" - disabledColor2="#DBDBDB" - /> - -
+ + ); }; diff --git a/components/ThemeManager/PubPickers/PubBackgroundPickers.tsx b/components/ThemeManager/PubPickers/PubBackgroundPickers.tsx index d3272d66..cfdb932f 100644 --- a/components/ThemeManager/PubPickers/PubBackgroundPickers.tsx +++ b/components/ThemeManager/PubPickers/PubBackgroundPickers.tsx @@ -95,8 +95,8 @@ export const BackgroundPicker = (props: {
{ + toggle={props.hasPageBackground} + onToggle={() => { props.setHasPageBackground(!props.hasPageBackground); props.hasPageBackground && props.openPicker === "page" && @@ -104,19 +104,14 @@ export const BackgroundPicker = (props: { }} disabledColor1="#8C8C8C" disabledColor2="#DBDBDB" - /> - +
); diff --git a/components/ThemeManager/ThemeSetter.tsx b/components/ThemeManager/ThemeSetter.tsx index 3de590a3..8039301b 100644 --- a/components/ThemeManager/ThemeSetter.tsx +++ b/components/ThemeManager/ThemeSetter.tsx @@ -220,24 +220,18 @@ function WatermarkSetter(props: { entityID: string }) { return (
{ + toggle={!!checked?.data.value} + onToggle={() => { handleToggle(); }} disabledColor1="#8C8C8C" disabledColor2="#DBDBDB" - /> - +
); } diff --git a/components/Toggle.tsx b/components/Toggle.tsx index 36056507..831adf08 100644 --- a/components/Toggle.tsx +++ b/components/Toggle.tsx @@ -1,33 +1,45 @@ import { theme } from "tailwind.config"; export const Toggle = (props: { - toggleOn: boolean; - setToggleOn: (s: boolean) => void; + toggle: boolean; + onToggle: () => void; disabledColor1?: string; disabledColor2?: string; + children: React.ReactNode; }) => { return ( ); }; diff --git a/lexicons/fix-extensions.ts b/lexicons/fix-extensions.ts new file mode 100644 index 00000000..32148a9a --- /dev/null +++ b/lexicons/fix-extensions.ts @@ -0,0 +1,44 @@ +import * as fs from "fs"; +import * as path from "path"; + +/** + * Recursively processes all files in a directory and removes .js extensions from imports + */ +function fixExtensionsInDirectory(dir: string): void { + const entries = fs.readdirSync(dir, { withFileTypes: true }); + + for (const entry of entries) { + const fullPath = path.join(dir, entry.name); + + if (entry.isDirectory()) { + fixExtensionsInDirectory(fullPath); + } else if (entry.isFile() && (entry.name.endsWith(".ts") || entry.name.endsWith(".js"))) { + fixExtensionsInFile(fullPath); + } + } +} + +/** + * Removes .js extensions from import/export statements in a file + */ +function fixExtensionsInFile(filePath: string): void { + const content = fs.readFileSync(filePath, "utf-8"); + const fixedContent = content.replace(/\.js'/g, "'"); + + if (content !== fixedContent) { + fs.writeFileSync(filePath, fixedContent, "utf-8"); + console.log(`Fixed: ${filePath}`); + } +} + +// Get the directory to process from command line arguments +const targetDir = process.argv[2] || "./lexicons/api"; + +if (!fs.existsSync(targetDir)) { + console.error(`Directory not found: ${targetDir}`); + process.exit(1); +} + +console.log(`Fixing extensions in: ${targetDir}`); +fixExtensionsInDirectory(targetDir); +console.log("Done!"); diff --git a/package.json b/package.json index 7cafd51c..01dba955 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "dev": "TZ=UTC next dev --turbo", "publish-lexicons": "tsx lexicons/publish.ts", "generate-db-types": "supabase gen types --local > supabase/database.types.ts && drizzle-kit introspect && rm -rf ./drizzle/*.sql ./drizzle/meta", - "lexgen": "tsx ./lexicons/build.ts && lex gen-api ./lexicons/api ./lexicons/pub/leaflet/document.json ./lexicons/pub/leaflet/comment.json ./lexicons/pub/leaflet/publication.json ./lexicons/pub/leaflet/*/* ./lexicons/com/atproto/*/* ./lexicons/app/bsky/*/* --yes && find './lexicons/api' -type f -exec sed -i 's/\\.js'/'/g' {} \\;", + "lexgen": "tsx ./lexicons/build.ts && lex gen-api ./lexicons/api ./lexicons/pub/leaflet/document.json ./lexicons/pub/leaflet/comment.json ./lexicons/pub/leaflet/publication.json ./lexicons/pub/leaflet/*/* ./lexicons/com/atproto/*/* ./lexicons/app/bsky/*/* --yes && tsx ./lexicons/fix-extensions.ts ./lexicons/api", "wrangler-dev": "wrangler dev", "build-appview": "esbuild appview/index.ts --outfile=appview/dist/index.js --bundle --platform=node", "build-feed-service": "esbuild feeds/index.ts --outfile=feeds/dist/index.js --bundle --platform=node", -- 2.51.2