Skip to content

Commit

Permalink
feat: update import opml style
Browse files Browse the repository at this point in the history
Signed-off-by: Innei <i@innei.in>
  • Loading branch information
Innei committed Jul 28, 2024
1 parent fbbf4e4 commit 58c1577
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 10 deletions.
1 change: 1 addition & 0 deletions icons/mgc/file_import_cute_re.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions icons/mgc/file_upload_cute_re.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
52 changes: 42 additions & 10 deletions src/renderer/src/modules/discover/import.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { cn } from "@renderer/lib/utils"
import type { FeedResponse } from "@renderer/models"
import { Queries } from "@renderer/queries"
import { useMutation } from "@tanstack/react-query"
import { Fragment } from "react/jsx-runtime"
import { useForm } from "react-hook-form"
import { z } from "zod"

Expand Down Expand Up @@ -97,21 +98,48 @@ export function DiscoverImport() {
<FormItem>
<FormLabel>OPML file</FormLabel>
<FormControl>
<Input
{...fieldProps}
placeholder="Picture"
type="file"
accept=".opml"
onChange={(event) =>
onChange(event.target.files && event.target.files[0])}
/>
<label
className="center flex h-[100px] w-full rounded-md border border-dashed"
htmlFor="upload-file"
>
{form.formState.dirtyFields.file ? (
<Fragment>
<i className="i-mgc-file-upload-cute-re size-5" />

<span className="ml-2 text-sm font-semibold opacity-80">
{value.name}
</span>
</Fragment>
) : (
<Fragment>
<i className="i-mgc-file-upload-cute-re size-5" />

<span className="ml-2 text-sm opacity-80">
Click to upload OPML file
</span>
</Fragment>
)}
</label>
</FormControl>
<Input
{...fieldProps}
id="upload-file"
type="file"
accept=".opml"
className="hidden"
onChange={(event) =>
onChange(event.target.files && event.target.files[0])}
/>
<FormMessage />
</FormItem>
)}
/>
<div className="center flex">
<StyledButton type="submit" isLoading={mutation.isPending}>
<StyledButton
type="submit"
disabled={!form.formState.dirtyFields.file}
isLoading={mutation.isPending}
>
Import
</StyledButton>
</div>
Expand Down Expand Up @@ -152,7 +180,11 @@ export function DiscoverImport() {
<div className="text-zinc-500">No items</div>
)}
{mutation.data?.[item.key].map((feed: FeedResponse) => (
<FollowSummary className="max-w-[462px]" key={feed.id} feed={feed} />
<FollowSummary
className="max-w-[462px]"
key={feed.id}
feed={feed}
/>
))}
</div>
</div>
Expand Down

0 comments on commit 58c1577

Please sign in to comment.