Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/@/components/BookmarkForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,13 @@ import { Label } from './ui/Label.tsx';

let configured = false;
let duplicated = false;

let keepOptionsDetailsOpen = false;

const BookmarkForm = () => {
const [openOptions, setOpenOptions] = useState<boolean>(false);
const [openOptions, setOpenOptions] = useState<boolean>(
keepOptionsDetailsOpen
);
const [openCollections, setOpenCollections] = useState<boolean>(false);
const [uploadImage, setUploadImage] = useState<boolean>(false);
const [state, setState] = useState<'capturing' | 'uploading' | null>(null);
Expand Down Expand Up @@ -124,6 +129,10 @@ const BookmarkForm = () => {
form.setValue('collection', {
name: config.defaultCollection,
});
if (openOptions !== config.keepOptionsDetailsOpen) {
keepOptionsDetailsOpen = config.keepOptionsDetailsOpen;
setOpenOptions(config.keepOptionsDetailsOpen);
}
});
});
const getConfigUse = async () => {
Expand Down
20 changes: 20 additions & 0 deletions src/@/components/OptionsForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ import {
SelectTrigger,
SelectValue,
} from './ui/Select.tsx'; // Import the Select component
import { Checkbox } from './ui/CheckBox.tsx';
import { Label } from './ui/Label.tsx';

const OptionsForm = () => {
const form = useForm<optionsFormValues>({
Expand All @@ -47,6 +49,7 @@ const OptionsForm = () => {
username: '',
password: '',
apiKey: '',
keepOptionsDetailsOpen: false,
syncBookmarks: false,
defaultCollection: 'Unorganized',
},
Expand Down Expand Up @@ -79,6 +82,7 @@ const OptionsForm = () => {
username: '',
password: '',
apiKey: '',
keepOptionsDetailsOpen: false,
syncBookmarks: false,
defaultCollection: 'Unorganized',
});
Expand Down Expand Up @@ -157,6 +161,7 @@ const OptionsForm = () => {
baseUrl: values.baseUrl,
defaultCollection: values.defaultCollection,
syncBookmarks: values.syncBookmarks,
keepOptionsDetailsOpen: values.keepOptionsDetailsOpen,
apiKey:
values.method === 'apiKey' && values.apiKey
? values.apiKey
Expand Down Expand Up @@ -303,6 +308,21 @@ const OptionsForm = () => {
</>
)}

<FormField
control={control}
name="keepOptionsDetailsOpen"
render={({ field }) => (
<FormItem>
<Label className="flex items-center gap-2 w-fit cursor-pointer">
<Checkbox
checked={field.value}
onCheckedChange={field.onChange}
/>
Show more options by default
</Label>
</FormItem>
)}
/>
{/* Commented out fields */}
{/*
<FormField
Expand Down
16 changes: 8 additions & 8 deletions src/@/components/ui/CheckBox.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from "react"
import * as CheckboxPrimitive from "@radix-ui/react-checkbox"
import { CheckIcon } from "@radix-ui/react-icons"
import * as React from 'react';
import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
import { CheckIcon } from '@radix-ui/react-icons';

import { cn } from '../../lib/utils.ts';

Expand All @@ -11,18 +11,18 @@ const Checkbox = React.forwardRef<
<CheckboxPrimitive.Root
ref={ref}
className={cn(
"peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",
'peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground',
className
)}
{...props}
>
<CheckboxPrimitive.Indicator
className={cn("flex items-center justify-center text-current")}
className={cn('flex items-center justify-center text-current')}
>
<CheckIcon className="h-4 w-4" />
</CheckboxPrimitive.Indicator>
</CheckboxPrimitive.Root>
))
Checkbox.displayName = CheckboxPrimitive.Root.displayName
));
Checkbox.displayName = CheckboxPrimitive.Root.displayName;

export { Checkbox }
export { Checkbox };
2 changes: 2 additions & 0 deletions src/@/lib/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const DEFAULTS: configType = {
baseUrl: '',
apiKey: '',
defaultCollection: 'Unorganized',
keepOptionsDetailsOpen: false,
syncBookmarks: false,
};

Expand Down Expand Up @@ -36,6 +37,7 @@ export async function clearConfig() {
baseUrl: '',
apiKey: '',
defaultCollection: 'Unorganized',
keepOptionsDetailsOpen: false,
syncBookmarks: false,
})
);
Expand Down
1 change: 1 addition & 0 deletions src/@/lib/validators/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export const configSchema = z.object({
defaultCollection: z.string().optional().default('Unorganized'),
apiKey: z.string(),
syncBookmarks: z.boolean().optional().default(false),
keepOptionsDetailsOpen: z.boolean().optional().default(false),
});

export type configType = z.infer<typeof configSchema>;
1 change: 1 addition & 0 deletions src/@/lib/validators/optionsForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export const optionsFormSchema = z.object({
username: z.string(),
password: z.string(),
syncBookmarks: z.boolean().default(false),
keepOptionsDetailsOpen: z.boolean().default(false),
defaultCollection: z.string().optional().default('Unorganized'),
useApiKey: z.boolean().default(false),
apiKey: z.string().optional(),
Expand Down