-
Notifications
You must be signed in to change notification settings - Fork 672
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(trending): implement trending feature and components (#820)
* init Signed-off-by: Innei <[email protected]> * update Signed-off-by: Innei <[email protected]> * fix: update styles Signed-off-by: Innei <[email protected]> * fix: hover Signed-off-by: Innei <[email protected]> * update scroll Signed-off-by: Innei <[email protected]> * update i18n Signed-off-by: Innei <[email protected]> * chore: auto-fix linting and formatting issues --------- Signed-off-by: Innei <[email protected]> Co-authored-by: Innei <[email protected]>
- Loading branch information
Showing
14 changed files
with
531 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import camelcaseKeys from "camelcase-keys" | ||
|
||
import { apiFetch } from "~/lib/api-fetch" | ||
import type { Models } from "~/models" | ||
|
||
const v1ApiPrefix = "/v1" | ||
export const getTrendingAggregates = () => { | ||
return apiFetch<Models.TrendingAggregates>(`${v1ApiPrefix}/trendings`).then((data) => | ||
camelcaseKeys(data as any, { deep: true }), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import type { SVGProps } from "react" | ||
import React from "react" | ||
|
||
export function IconoirBrightCrown(props: SVGProps<SVGSVGElement>) { | ||
return ( | ||
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24" {...props}> | ||
<path | ||
fill="none" | ||
stroke="currentColor" | ||
strokeLinecap="round" | ||
strokeLinejoin="round" | ||
strokeWidth="1.5" | ||
d="M22 12h1M12 2V1m0 22v-1m8-2l-1-1m1-15l-1 1M4 20l1-1M4 4l1 1m-4 7h1m14.8 3.5l1.2-7l-4.2 2.1L12 8.5l-1.8 2.1L6 8.5l1.2 7z" | ||
/> | ||
</svg> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import type { SVGProps } from "react" | ||
import React 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> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { t } from "i18next" | ||
import { useCallback } from "react" | ||
|
||
import { useModalStack } from "~/components/ui/modal/stacked" | ||
import { FeedForm } from "~/modules/discover/feed-form" | ||
import { ListForm } from "~/modules/discover/list-form" | ||
|
||
export const useFollow = () => { | ||
const { present } = useModalStack() | ||
|
||
return useCallback( | ||
(options?: { isList: boolean; id?: string; url?: string }) => { | ||
present({ | ||
title: options?.isList | ||
? t("sidebar.feed_actions.edit_list") | ||
: t("sidebar.feed_actions.edit_feed"), | ||
content: ({ dismiss }) => | ||
options?.isList ? ( | ||
<ListForm asWidget id={options?.id} onSuccess={dismiss} /> | ||
) : ( | ||
<FeedForm asWidget id={options?.id} url={options?.url} onSuccess={dismiss} /> | ||
), | ||
}) | ||
}, | ||
[present], | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,41 @@ | ||
import type { User } from "@auth/core/types" | ||
|
||
import type { FeedModel, ListModelPoplutedFeeds } from "./types" | ||
|
||
export * from "./types" | ||
|
||
/* eslint-disable @typescript-eslint/no-namespace */ | ||
export namespace Models { | ||
export interface TrendingList { | ||
id: string | ||
title: string | ||
description: string | ||
image: string | ||
view: number | ||
fee: number | ||
timelineUpdatedAt: string | ||
ownerUserId: string | ||
subscriberCount: number | ||
} | ||
|
||
export interface TrendingAggregates { | ||
trendingFeeds: FeedModel[] | ||
trendingLists: ListModelPoplutedFeeds[] | ||
trendingEntries: TrendingEntry[] | ||
trendingUsers: User[] | ||
} | ||
|
||
export interface TrendingEntry { | ||
id: string | ||
feedId: string | ||
title: string | ||
url: string | ||
content: string | ||
description: string | ||
guid: string | ||
author: string | ||
insertedAt: string | ||
publishedAt: string | ||
readCount: number | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.