diff --git a/src/app.d.ts b/src/app.d.ts index 2c93e142..a7591ab4 100644 --- a/src/app.d.ts +++ b/src/app.d.ts @@ -1,7 +1,5 @@ // See https://kit.svelte.dev/docs/types#app -import type { Action } from '$comp/ui/navbar/commands/actions.svelte' - // for information about these interfaces declare global { namespace App { diff --git a/src/lib/client/base.ts b/src/lib/api/base.ts similarity index 100% rename from src/lib/client/base.ts rename to src/lib/api/base.ts diff --git a/src/lib/client/lemmy.svelte.ts b/src/lib/api/client.svelte.ts similarity index 86% rename from src/lib/client/lemmy.svelte.ts rename to src/lib/api/client.svelte.ts index 17f83b5c..db9f26ce 100644 --- a/src/lib/client/lemmy.svelte.ts +++ b/src/lib/api/client.svelte.ts @@ -1,11 +1,11 @@ -import { profile } from '$lib/auth.svelte' -import { DEFAULT_INSTANCE_URL } from '$lib/instance.svelte.js' -import { instanceToURL } from '$lib/util.svelte' +import { profile } from '$lib/app/auth.svelte' +import { DEFAULT_INSTANCE_URL } from '$lib/app/instance.svelte' +import { instanceToURL } from '$lib/app/util.svelte' import { error } from '@sveltejs/kit' -import { type GetSiteResponse } from '$lib/client/types' -import { LemmyClient } from './lemmy/lemmy' -import { PiefedClient } from './piefed/piefed' -import { DEFAULT_CLIENT_TYPE, type ClientType, BaseClient } from './base' +import { BaseClient, DEFAULT_CLIENT_TYPE, type ClientType } from './base' +import { LemmyClient } from './lemmy/adapter' +import { PiefedClient } from './piefed/adapter' +import type { GetSiteResponse } from './types' class SiteData { #data = $state() diff --git a/src/lib/client/lemmy/lemmy.ts b/src/lib/api/lemmy/adapter.ts similarity index 100% rename from src/lib/client/lemmy/lemmy.ts rename to src/lib/api/lemmy/adapter.ts diff --git a/src/lib/client/lemmy/rewrite.ts b/src/lib/api/lemmy/rewrite.ts similarity index 90% rename from src/lib/client/lemmy/rewrite.ts rename to src/lib/api/lemmy/rewrite.ts index 5fdc5cb7..01137b25 100644 --- a/src/lib/client/lemmy/rewrite.ts +++ b/src/lib/api/lemmy/rewrite.ts @@ -1,5 +1,5 @@ -import * as lemmy from 'lemmy-js-client' import type { GetPosts, ListingType } from '../types' +import * as lemmy from '../types' export function fromGetPosts(getPosts: GetPosts): lemmy.GetPosts { return { diff --git a/src/lib/client/piefed/piefed.ts b/src/lib/api/piefed/adapter.ts similarity index 99% rename from src/lib/client/piefed/piefed.ts rename to src/lib/api/piefed/adapter.ts index e48dc163..ed793c0a 100644 --- a/src/lib/client/piefed/piefed.ts +++ b/src/lib/api/piefed/adapter.ts @@ -1,10 +1,11 @@ import createClient from 'openapi-fetch' -import type { +import { BaseClient, - ClientType, - NullableFnArg, - NullableFnReturn, + type ClientType, + type NullableFnArg, + type NullableFnReturn, } from '../base' +import type { SubscribedType } from '../types' import { fromCreateComment, fromCreatePost, @@ -33,7 +34,6 @@ import { toTopicView, } from './rewrite' import type { paths } from './schema' -import type { SubscribedType } from '../types' export class PiefedClient implements BaseClient { type: ClientType = { name: 'piefed', baseUrl: '/api/alpha' } diff --git a/src/lib/client/piefed/rewrite.ts b/src/lib/api/piefed/rewrite.ts similarity index 99% rename from src/lib/client/piefed/rewrite.ts rename to src/lib/api/piefed/rewrite.ts index 29a413a0..d662b7e7 100644 --- a/src/lib/client/piefed/rewrite.ts +++ b/src/lib/api/piefed/rewrite.ts @@ -1,5 +1,6 @@ +import { Post } from '$lib/feature/post' +import { Search } from 'mono-svelte' import type { - Comment, CommentReplyView, CommentSortType, CommentView, @@ -18,10 +19,8 @@ import type { Person, PersonMentionView, PersonView, - Post, PostView, PrivateMessageView, - Search, SortType, SubscribedType, TopicView, diff --git a/src/lib/client/piefed/schema.d.ts b/src/lib/api/piefed/schema.d.ts similarity index 100% rename from src/lib/client/piefed/schema.d.ts rename to src/lib/api/piefed/schema.d.ts diff --git a/src/lib/client/types/schemas/schemas.ts b/src/lib/api/types/generated.ts similarity index 84% rename from src/lib/client/types/schemas/schemas.ts rename to src/lib/api/types/generated.ts index 6a2bd996..74f8220d 100644 --- a/src/lib/client/types/schemas/schemas.ts +++ b/src/lib/api/types/generated.ts @@ -1,3 +1,334 @@ +export interface AddAdminResponse { + admins: Array +} + +export interface AddModToCommunityResponse { + moderators: Array +} + +export interface BanFromCommunityResponse { + person_view: PersonView + banned: boolean +} + +export interface BannedPersonsResponse { + banned: Array +} + +export interface BanPersonResponse { + person_view: PersonView + banned: boolean +} + +export interface BlockCommunityResponse { + community_view: CommunityView + blocked: boolean +} +export interface BlockInstanceResponse { + blocked: boolean +} + +export interface BlockPersonResponse { + person_view: PersonView + blocked: boolean +} +export interface CaptchaResponse { + png: string + wav: string + uuid: string +} + +export interface CommentReplyResponse { + comment_reply_view: CommentReplyView +} + +export interface CommentReportResponse { + comment_report_view: CommentReportView +} + +export interface CommentResponse { + comment_view: CommentView + recipient_ids: Array +} + +export interface CommunityResponse { + community_view: CommunityView + discussion_languages: Array +} + +export interface CustomEmojiResponse { + custom_emoji: CustomEmojiView +} +export interface GenerateTotpSecretResponse { + totp_secret_url: string +} + +export interface GetCaptchaResponse { + ok?: CaptchaResponse +} + +export interface GetComment { + id: CommentId +} + +export interface GetComments { + type_?: ListingType + sort?: CommentSortType + max_depth?: number + page?: number + limit?: number + community_id?: CommunityId + community_name?: string + post_id?: PostId + parent_id?: CommentId + saved_only?: boolean + liked_only?: boolean + disliked_only?: boolean +} + +export interface GetCommentsResponse { + comments: Array +} + +export interface GetCommunity { + id?: CommunityId + name?: string +} + +export interface GetCommunityResponse { + community_view: CommunityView + site?: Site + moderators: Array + discussion_languages: Array +} + +export interface GetFederatedInstancesResponse { + federated_instances?: FederatedInstances +} + +export interface GetModlog { + mod_person_id?: PersonId + community_id?: CommunityId + page?: number + limit?: number + type_?: ModlogActionType + other_person_id?: PersonId + post_id?: PostId + comment_id?: CommentId +} + +export interface GetModlogResponse { + removed_posts: Array + locked_posts: Array + featured_posts: Array + removed_comments: Array + removed_communities: Array + banned_from_community: Array + banned: Array + added_to_community: Array + transferred_to_community: Array + added: Array + admin_purged_persons: Array + admin_purged_communities: Array + admin_purged_posts: Array + admin_purged_comments: Array + hidden_communities: Array +} + +export interface GetPersonDetails { + person_id?: PersonId + username?: string + sort?: SortType + page?: number + limit?: number + community_id?: CommunityId + saved_only?: boolean +} + +export interface GetPersonDetailsResponse { + person_view: PersonView + site?: Site + comments: Array + posts: Array + moderates: Array +} + +export interface GetPersonMentions { + sort?: CommentSortType + page?: number + limit?: number + unread_only?: boolean +} + +export interface GetPersonMentionsResponse { + mentions: Array +} + +export interface GetPost { + id?: PostId + comment_id?: CommentId +} + +export interface GetPostResponse { + post_view: PostView + community_view: CommunityView + moderators: Array + cross_posts: Array +} + +export interface GetPosts { + type_?: ListingType + sort?: SortType + page?: number + limit?: number + community_id?: CommunityId + community_name?: string + saved_only?: boolean + liked_only?: boolean + disliked_only?: boolean + show_hidden?: boolean + show_read?: boolean + show_nsfw?: boolean + page_cursor?: PaginationCursor + feed_id?: string + topic_id?: string +} + +export interface GetPostsResponse { + posts: Array + next_page: PaginationCursor +} + +export interface GetPrivateMessages { + unread_only?: boolean + page?: number + limit?: number + creator_id?: PersonId +} + +export interface GetRegistrationApplication { + person_id: PersonId +} + +export interface GetReplies { + sort?: CommentSortType + page?: number + limit?: number + unread_only?: boolean +} + +export interface GetRepliesResponse { + replies: Array +} + +export interface GetReportCount { + community_id?: CommunityId +} + +export interface GetReportCountResponse { + community_id?: CommunityId + comment_reports: number + post_reports: number + private_message_reports?: number +} +export interface GetSiteMetadata { + url: string +} + +export interface GetSiteMetadataResponse { + metadata: LinkMetadata +} + +export interface GetSiteResponse { + site_view: SiteView + admins: Array + version: string + my_user?: MyUserInfo + all_languages: Array + discussion_languages: Array + taglines: Array + custom_emojis: Array + blocked_urls: Array +} +export interface GetUnreadCountResponse { + replies: number + mentions: number + private_messages: number +} +export interface GetUnreadRegistrationApplicationCountResponse { + registration_applications: number +} + +export interface ListCommentLikesResponse { + comment_likes: Array +} + +export interface ListCommentReportsResponse { + comment_reports: Array +} + +export interface ListCommunitiesResponse { + communities: Array +} + +export interface ListMediaResponse { + images: Array +} + +export interface ListPostLikesResponse { + post_likes: Array +} + +export interface ListPostReportsResponse { + post_reports: Array +} + +export interface ListPrivateMessageReportsResponse { + private_message_reports: Array +} + +export interface ListRegistrationApplicationsResponse { + registration_applications: Array +} +export interface LoginResponse { + jwt?: string + registration_created: boolean + verify_email_sent: boolean +} + +export interface PersonMentionResponse { + person_mention_view: PersonMentionView +} + +export interface PostReportResponse { + post_report_view: PostReportView +} + +export interface PostResponse { + post_view: PostView +} + +export interface PrivateMessageReportResponse { + private_message_report_view: PrivateMessageReportView +} + +export interface PrivateMessageResponse { + private_message_view: PrivateMessageView +} + +export interface PrivateMessagesResponse { + private_messages: Array +} + +export interface RegistrationApplicationResponse { + registration_application: RegistrationApplicationView +} +export interface ResolveObjectResponse { + comment?: CommentView + post?: PostView + community?: CommunityView + person?: PersonView +} // TODO fix type ActivityId = any @@ -2063,3 +2394,22 @@ export interface AssignFlair { post_id: number flair_id_list: number[] } + +export interface SearchResponse { + type_: SearchType + comments: Array + posts: Array + communities: Array + users: Array +} + +export interface SiteResponse { + site_view: SiteView + taglines: Array +} +export interface SuccessResponse { + success: boolean +} +export interface UpdateTotpResponse { + enabled: boolean +} diff --git a/src/lib/api/types/index.ts b/src/lib/api/types/index.ts new file mode 100644 index 00000000..99735f64 --- /dev/null +++ b/src/lib/api/types/index.ts @@ -0,0 +1 @@ +export * from './generated' diff --git a/src/lib/auth.svelte.ts b/src/lib/app/auth.svelte.ts similarity index 94% rename from src/lib/auth.svelte.ts rename to src/lib/app/auth.svelte.ts index b1d160bb..4595ab4d 100644 --- a/src/lib/auth.svelte.ts +++ b/src/lib/app/auth.svelte.ts @@ -1,16 +1,16 @@ import { browser } from '$app/environment' import { env } from '$env/dynamic/public' -import { amModOfAny, isAdmin } from '$comp/lemmy/moderation/moderation.js' -import { DEFAULT_INSTANCE_URL } from '$lib/instance.svelte.js' -import { client, getClient, site } from '$lib/client/lemmy.svelte' -import { instanceToURL, moveItem } from '$lib/util.svelte' +import { DEFAULT_CLIENT_TYPE, type ClientType } from '$lib/api/base' +import { client, getClient, site } from '$lib/api/client.svelte' +import type { Community, GetSiteResponse, MyUserInfo } from '$lib/api/types' +import { amModOfAny, isAdmin } from '$lib/feature/moderation/moderation' +import { publishedToDate } from '$lib/ui/util/date' import { toast } from 'mono-svelte' import { writable } from 'svelte/store' -import { t } from './i18n/translations' -import { errorMessage } from './lemmy/error' -import { publishedToDate } from './components/util/date' -import type { Community, GetSiteResponse, MyUserInfo } from './client/types' -import { DEFAULT_CLIENT_TYPE, type ClientType } from './client/base' +import { errorMessage } from './error' +import { t } from './i18n' +import { DEFAULT_INSTANCE_URL } from './instance.svelte' +import { instanceToURL, moveItem } from './util.svelte' function getFromStorage(key: string): T | undefined { if (typeof localStorage == 'undefined') return undefined diff --git a/src/lib/lemmy/error.ts b/src/lib/app/error.ts similarity index 91% rename from src/lib/lemmy/error.ts rename to src/lib/app/error.ts index c970a569..8a682e8c 100644 --- a/src/lib/lemmy/error.ts +++ b/src/lib/app/error.ts @@ -1,5 +1,3 @@ -import { t } from '$lib/i18n/translations' - // eslint-disable-next-line export function errorMessage(error: any, instance?: string): string { try { diff --git a/src/lib/i18n/ar.json b/src/lib/app/i18n/ar.json similarity index 100% rename from src/lib/i18n/ar.json rename to src/lib/app/i18n/ar.json diff --git a/src/lib/i18n/bg.json b/src/lib/app/i18n/bg.json similarity index 100% rename from src/lib/i18n/bg.json rename to src/lib/app/i18n/bg.json diff --git a/src/lib/i18n/de.json b/src/lib/app/i18n/de.json similarity index 100% rename from src/lib/i18n/de.json rename to src/lib/app/i18n/de.json diff --git a/src/lib/i18n/en.json b/src/lib/app/i18n/en.json similarity index 100% rename from src/lib/i18n/en.json rename to src/lib/app/i18n/en.json diff --git a/src/lib/i18n/es.json b/src/lib/app/i18n/es.json similarity index 100% rename from src/lib/i18n/es.json rename to src/lib/app/i18n/es.json diff --git a/src/lib/i18n/et.json b/src/lib/app/i18n/et.json similarity index 100% rename from src/lib/i18n/et.json rename to src/lib/app/i18n/et.json diff --git a/src/lib/i18n/fi.json b/src/lib/app/i18n/fi.json similarity index 100% rename from src/lib/i18n/fi.json rename to src/lib/app/i18n/fi.json diff --git a/src/lib/i18n/fr.json b/src/lib/app/i18n/fr.json similarity index 100% rename from src/lib/i18n/fr.json rename to src/lib/app/i18n/fr.json diff --git a/src/lib/i18n/he.json b/src/lib/app/i18n/he.json similarity index 100% rename from src/lib/i18n/he.json rename to src/lib/app/i18n/he.json diff --git a/src/lib/i18n/hu.json b/src/lib/app/i18n/hu.json similarity index 100% rename from src/lib/i18n/hu.json rename to src/lib/app/i18n/hu.json diff --git a/src/lib/i18n/translations.ts b/src/lib/app/i18n/index.ts similarity index 97% rename from src/lib/i18n/translations.ts rename to src/lib/app/i18n/index.ts index dacf4204..4b80dba8 100644 --- a/src/lib/i18n/translations.ts +++ b/src/lib/app/i18n/index.ts @@ -1,4 +1,4 @@ -import i18n, { type Config, type Parser } from 'sveltekit-i18n' +import { default as i18n, type Config, type Parser } from 'sveltekit-i18n' const config: Config = { loaders: [ diff --git a/src/lib/i18n/ja.json b/src/lib/app/i18n/ja.json similarity index 100% rename from src/lib/i18n/ja.json rename to src/lib/app/i18n/ja.json diff --git a/src/lib/i18n/nl.json b/src/lib/app/i18n/nl.json similarity index 100% rename from src/lib/i18n/nl.json rename to src/lib/app/i18n/nl.json diff --git a/src/lib/i18n/pl.json b/src/lib/app/i18n/pl.json similarity index 100% rename from src/lib/i18n/pl.json rename to src/lib/app/i18n/pl.json diff --git a/src/lib/i18n/pt-BR.json b/src/lib/app/i18n/pt-BR.json similarity index 100% rename from src/lib/i18n/pt-BR.json rename to src/lib/app/i18n/pt-BR.json diff --git a/src/lib/i18n/pt.json b/src/lib/app/i18n/pt.json similarity index 100% rename from src/lib/i18n/pt.json rename to src/lib/app/i18n/pt.json diff --git a/src/lib/i18n/ru.json b/src/lib/app/i18n/ru.json similarity index 100% rename from src/lib/i18n/ru.json rename to src/lib/app/i18n/ru.json diff --git a/src/lib/i18n/tok.json b/src/lib/app/i18n/tok.json similarity index 100% rename from src/lib/i18n/tok.json rename to src/lib/app/i18n/tok.json diff --git a/src/lib/i18n/tr.json b/src/lib/app/i18n/tr.json similarity index 100% rename from src/lib/i18n/tr.json rename to src/lib/app/i18n/tr.json diff --git a/src/lib/i18n/zh-Hans.json b/src/lib/app/i18n/zh-Hans.json similarity index 100% rename from src/lib/i18n/zh-Hans.json rename to src/lib/app/i18n/zh-Hans.json diff --git a/src/lib/i18n/zh-Hant.json b/src/lib/app/i18n/zh-Hant.json similarity index 100% rename from src/lib/i18n/zh-Hant.json rename to src/lib/app/i18n/zh-Hant.json diff --git a/src/lib/instance.svelte.ts b/src/lib/app/instance.svelte.ts similarity index 100% rename from src/lib/instance.svelte.ts rename to src/lib/app/instance.svelte.ts diff --git a/src/lib/components/markdown/Markdown.svelte b/src/lib/app/markdown/Markdown.svelte similarity index 96% rename from src/lib/components/markdown/Markdown.svelte rename to src/lib/app/markdown/Markdown.svelte index 1c6a6356..739806af 100644 --- a/src/lib/components/markdown/Markdown.svelte +++ b/src/lib/app/markdown/Markdown.svelte @@ -1,7 +1,33 @@ - -
- {#each options as option, index} - {@const slctd = selected == option} - (selected = option)} - disabled={disabled[index]} - type="button" - > - {optionNames[index] || option} - - {/each} -
-{@render children?.({ selected })} diff --git a/src/lib/components/ui/navbar/link.ts b/src/lib/components/ui/navbar/link.ts deleted file mode 100644 index c6d2dff8..00000000 --- a/src/lib/components/ui/navbar/link.ts +++ /dev/null @@ -1,115 +0,0 @@ -import { t } from '$lib/i18n/translations' -import { - type IconSource, - Home, - ChartBar, - Cog6Tooth, - Newspaper, - GlobeAmericas, - GlobeAlt, - MagnifyingGlass, - ShieldCheck, - ServerStack, - PencilSquare, - MapPin, - Fire, - ArrowTrendingUp, - Star, -} from 'svelte-hero-icons' - -export interface Link { - url: string - label?: string -} - -export const getDefaultLinks = (): Link[] => [ - { - url: '/', - label: t.get('nav.home'), - }, - { - url: '/?type=All', - label: t.get('filter.location.all'), - }, - { - url: '/?type=Local', - label: t.get('filter.location.local'), - }, - { - url: '/?type=Subscribed', - label: t.get('filter.location.subscribed'), - }, - { - url: '/?type=All&sort=Hot', - label: t.get('filter.sort.hot'), - }, - { - url: '/?type=All&sort=Active', - label: t.get('filter.sort.active'), - }, - { - url: '/?type=All&sort=TopDay', - label: t.get('filter.sort.top.time.day'), - }, - { - url: '/?type=All&sort=New', - label: t.get('filter.sort.new'), - }, - { - url: '/communities', - label: t.get('nav.communities'), - }, - { - url: '/search', - label: t.get('nav.search'), - }, - { - url: '/moderation', - label: t.get('moderation.label'), - }, - { - url: '/admin', - label: t.get('admin.label'), - }, - { - url: '/settings', - label: t.get('nav.menu.settings'), - }, - { - url: '/create/post', - label: t.get('form.post.create'), - }, -] - -export const iconOfLink = (url: string): IconSource => { - switch (url) { - case '/': - return Home - case '/?type=All': - return GlobeAmericas - case '/?type=Subscribed': - return Newspaper - case '/?type=Local': - return MapPin - case '/?type=All&sort=Hot': - return Fire - case '/?type=All&sort=Active': - return ArrowTrendingUp - case '/?type=All&sort=TopDay': - return ChartBar - case '/?type=All&sort=New': - return Star - case '/communities': - return GlobeAlt - case '/search': - return MagnifyingGlass - case '/moderation': - return ShieldCheck - case '/admin': - return ServerStack - case '/settings': - return Cog6Tooth - case '/create/post': - return PencilSquare - } -} diff --git a/src/lib/components/ui/sidebar/CommunityList.svelte b/src/lib/components/ui/sidebar/CommunityList.svelte deleted file mode 100644 index ad8cb7f1..00000000 --- a/src/lib/components/ui/sidebar/CommunityList.svelte +++ /dev/null @@ -1,79 +0,0 @@ - - -{#each items.toSorted( (a, b) => a.title.localeCompare(b.title), ) as follow (follow.id)} -
-
- {#if profile && !hasFavorite(profile.current, follow.id)} - - {:else if isFavorites && profile && hasFavorite(profile.current, follow.id)} - - {/if} - -
- - {#snippet label()} -
- {follow.title} - - {new URL(follow.actor_id).hostname} - -
- {/snippet} -
-
-{/each} diff --git a/src/lib/components/lemmy/comment/Comment.svelte b/src/lib/feature/comment/Comment.svelte similarity index 94% rename from src/lib/components/lemmy/comment/Comment.svelte rename to src/lib/feature/comment/Comment.svelte index eb4d1bd9..9f3f6ab3 100644 --- a/src/lib/components/lemmy/comment/Comment.svelte +++ b/src/lib/feature/comment/Comment.svelte @@ -1,17 +1,16 @@ {#if $modals.reporting.open} - {#await import('$comp/lemmy/moderation/ReportModal.svelte') then { default: ReportModal }} + {#await import('./ReportModal.svelte') then { default: ReportModal }} {/await} {/if} diff --git a/src/lib/components/lemmy/moderation/ModerationMenu.svelte b/src/lib/feature/moderation/ModerationMenu.svelte similarity index 93% rename from src/lib/components/lemmy/moderation/ModerationMenu.svelte rename to src/lib/feature/moderation/ModerationMenu.svelte index b7af1959..5fe4e975 100644 --- a/src/lib/components/lemmy/moderation/ModerationMenu.svelte +++ b/src/lib/feature/moderation/ModerationMenu.svelte @@ -1,10 +1,9 @@ {#if uploadingImage} - {#await import('$comp/form/ImageInputModal.svelte') then { default: UploadModal }} + {#await import('$lib/ui/form/ImageInputModal.svelte') then { default: UploadModal }} '', (v) => (data.url = v)} @@ -506,9 +502,7 @@ toast({ content: $t('toast.restoredFromDraft') }) const draft = getSessionStorage('postDraft') if (draft && !edit) { - // @ts-expect-error TODO get rid of session storage draft.loading = false - // @ts-expect-error TODO get rid of session storage data = draft } }} diff --git a/src/lib/components/lemmy/post/PostItem.svelte b/src/lib/feature/post/PostItem.svelte similarity index 74% rename from src/lib/components/lemmy/post/PostItem.svelte rename to src/lib/feature/post/PostItem.svelte index 1c723446..a06d4f4d 100644 --- a/src/lib/components/lemmy/post/PostItem.svelte +++ b/src/lib/feature/post/PostItem.svelte @@ -1,5 +1,5 @@ + +
+ {#each options as option, index} + + {/each} +
+{@render children?.({ selected })} diff --git a/src/lib/components/input/switch/TabButton.svelte b/src/lib/ui/form/TabButton.svelte similarity index 92% rename from src/lib/components/input/switch/TabButton.svelte rename to src/lib/ui/form/TabButton.svelte index baa772a0..7f5ea976 100644 --- a/src/lib/components/input/switch/TabButton.svelte +++ b/src/lib/ui/form/TabButton.svelte @@ -11,6 +11,7 @@ selected?: boolean children: Snippet size?: keyof typeof sizes + element?: 'div' | 'a' | 'button' [key: string]: any } @@ -21,12 +22,13 @@ children, href, size = 'sm', + element = href ? 'a' : 'button', ...rest }: Props = $props() - import { findClosestNumber } from '$lib/util.svelte.js' + import { findClosestNumber } from '$lib/app/util.svelte' import { createAvatar } from '@dicebear/core' import * as initials from '@dicebear/initials' import type { ClassValue } from 'svelte/elements' diff --git a/src/lib/components/ui/Entity.svelte b/src/lib/ui/generic/Entity.svelte similarity index 100% rename from src/lib/components/ui/Entity.svelte rename to src/lib/ui/generic/Entity.svelte diff --git a/src/lib/components/ui/EntityHeader.svelte b/src/lib/ui/generic/EntityHeader.svelte similarity index 96% rename from src/lib/components/ui/EntityHeader.svelte rename to src/lib/ui/generic/EntityHeader.svelte index 72029454..94a214f4 100644 --- a/src/lib/components/ui/EntityHeader.svelte +++ b/src/lib/ui/generic/EntityHeader.svelte @@ -1,10 +1,10 @@ {#snippet siteSnippet()} {#if site.data} - + import Avatar from '$lib/ui/generic/Avatar.svelte' import { Button } from 'mono-svelte' - import { ArrowUturnDown, Icon, QuestionMarkCircle } from 'svelte-hero-icons' - import type { HTMLButtonAttributes } from 'svelte/elements' - import Avatar from '../../Avatar.svelte' - import type { Action } from './actions.svelte' import type { Snippet } from 'svelte' + import { + ArrowUturnDown, + Icon, + QuestionMarkCircle, + } from 'svelte-hero-icons/dist' + import type { HTMLButtonAttributes } from 'svelte/elements' + import type { Action } from './actions.svelte' interface Props { action: Action diff --git a/src/lib/components/ui/navbar/commands/Commands.svelte b/src/lib/ui/navbar/commands/Commands.svelte similarity index 94% rename from src/lib/components/ui/navbar/commands/Commands.svelte rename to src/lib/ui/navbar/commands/Commands.svelte index 585aa556..4bdeda05 100644 --- a/src/lib/components/ui/navbar/commands/Commands.svelte +++ b/src/lib/ui/navbar/commands/Commands.svelte @@ -2,17 +2,17 @@ import { browser } from '$app/environment' import { goto } from '$app/navigation' import { page } from '$app/state' - import { profile } from '$lib/auth.svelte' - import { t } from '$lib/i18n/translations' - import { resumables } from '$lib/lemmy/item' - import { theme } from '$lib/ui/theme/theme.svelte' - import { fuzzySearch } from '$lib/util.svelte' + import { profile } from '$lib/app/auth.svelte' + import { t } from '$lib/app/i18n' + import { theme } from '$lib/app/theme/theme.svelte' + import { fuzzySearch } from '$lib/app/util.svelte' + import { resumables } from '$lib/feature/legacy/item' + import { CommonList } from '$lib/ui/layout' + import EndPlaceholder from '$lib/ui/layout/EndPlaceholder.svelte' import { TextInput } from 'mono-svelte' import { createEventDispatcher, onMount } from 'svelte' - import { Home, Icon, MagnifyingGlass } from 'svelte-hero-icons' - import EndPlaceholder from '../../EndPlaceholder.svelte' - import CommonList from '../../layout/CommonList.svelte' - import { getGroups, type Action, type Group } from './actions.svelte' + import { Home, Icon, MagnifyingGlass } from 'svelte-hero-icons/dist' + import { type Action, type Group, getGroups } from './actions.svelte' import CommandItem from './CommandItem.svelte' interface Props { diff --git a/src/lib/components/ui/navbar/commands/CommandsWrapper.svelte b/src/lib/ui/navbar/commands/CommandsWrapper.svelte similarity index 94% rename from src/lib/components/ui/navbar/commands/CommandsWrapper.svelte rename to src/lib/ui/navbar/commands/CommandsWrapper.svelte index eb8a16de..44d59abe 100644 --- a/src/lib/components/ui/navbar/commands/CommandsWrapper.svelte +++ b/src/lib/ui/navbar/commands/CommandsWrapper.svelte @@ -1,5 +1,5 @@ {#if $shownModal} @@ -19,7 +9,7 @@ title={$shownModal.title} dismissable={$shownModal.dismissable} ondismissed={() => shownModal.set(undefined)} - bind:open + bind:open={$shownModal} > {#if $shownModal.snippet} {@render $shownModal.snippet()} diff --git a/src/lib/mono/modal/modal.ts b/src/lib/ui/shared/modal/modal.ts similarity index 91% rename from src/lib/mono/modal/modal.ts rename to src/lib/ui/shared/modal/modal.ts index e301c1b9..b70e2004 100644 --- a/src/lib/mono/modal/modal.ts +++ b/src/lib/ui/shared/modal/modal.ts @@ -1,6 +1,6 @@ -import { t } from '$lib/i18n/translations' -import { type Snippet } from 'svelte' -import type { IconSource } from 'svelte-hero-icons' +import { t } from '$lib/app/i18n' +import type { IconSource } from '@xylightdev/svelte-hero-icons' +import type { Snippet } from 'svelte' import { writable } from 'svelte/store' export const shownModal = writable() diff --git a/src/lib/mono/note/Note.svelte b/src/lib/ui/shared/note/Note.svelte similarity index 87% rename from src/lib/mono/note/Note.svelte rename to src/lib/ui/shared/note/Note.svelte index b17d877c..d4a46149 100644 --- a/src/lib/mono/note/Note.svelte +++ b/src/lib/ui/shared/note/Note.svelte @@ -1,7 +1,7 @@
+ import { locale } from '$lib/app/i18n' + import { settings } from '$lib/app/settings.svelte' + export function formatRelativeDate( date: Date, options: Intl.RelativeTimeFormatOptions, @@ -47,9 +50,6 @@ + + + + diff --git a/src/lib/components/util/date.ts b/src/lib/ui/util/date.ts similarity index 100% rename from src/lib/components/util/date.ts rename to src/lib/ui/util/date.ts diff --git a/src/lib/components/util/debug/DebugObject.svelte b/src/lib/ui/util/debug/DebugObject.svelte similarity index 87% rename from src/lib/components/util/debug/DebugObject.svelte rename to src/lib/ui/util/debug/DebugObject.svelte index a4c7c78d..6e5b11bd 100644 --- a/src/lib/components/util/debug/DebugObject.svelte +++ b/src/lib/ui/util/debug/DebugObject.svelte @@ -1,6 +1,6 @@ - -
-
- - Photon -
-

About

-

- Photon - is a replacement user interface for Lemmy, with more features and modern design. -

-

Links

-
    -
  • - Github -
  • -
  • - - Community - -
  • -
  • - Xylight's portfolio -
  • -
  • - Donate -
  • -
-

Credits

-
- - - - - - - - - - - - - - - - - - - ...and you, for using this app! -
-
diff --git a/src/routes/about/Profile.svelte b/src/routes/about/Profile.svelte deleted file mode 100644 index 23390dc4..00000000 --- a/src/routes/about/Profile.svelte +++ /dev/null @@ -1,34 +0,0 @@ - - - diff --git a/src/routes/accounts/+page.svelte b/src/routes/accounts/+page.svelte index ef43ebfe..6a0439ce 100644 --- a/src/routes/accounts/+page.svelte +++ b/src/routes/accounts/+page.svelte @@ -1,17 +1,16 @@ diff --git a/src/routes/accounts/login/guest/+page.svelte b/src/routes/accounts/login/guest/+page.svelte index 97c36cce..78f81665 100644 --- a/src/routes/accounts/login/guest/+page.svelte +++ b/src/routes/accounts/login/guest/+page.svelte @@ -1,8 +1,8 @@ diff --git a/src/routes/activitypub/externalInteraction/+page.svelte b/src/routes/activitypub/externalInteraction/+page.svelte index 7728c981..d3966621 100644 --- a/src/routes/activitypub/externalInteraction/+page.svelte +++ b/src/routes/activitypub/externalInteraction/+page.svelte @@ -1,11 +1,11 @@ diff --git a/src/routes/c/[name]/settings/team/+page.svelte b/src/routes/c/[name]/settings/team/+page.svelte index fad1b673..2680c918 100644 --- a/src/routes/c/[name]/settings/team/+page.svelte +++ b/src/routes/c/[name]/settings/team/+page.svelte @@ -1,15 +1,14 @@ diff --git a/src/routes/create/community/+page.svelte b/src/routes/create/community/+page.svelte index fee47082..c4ea9bd4 100644 --- a/src/routes/create/community/+page.svelte +++ b/src/routes/create/community/+page.svelte @@ -1,5 +1,5 @@ diff --git a/src/routes/create/post/+page.svelte b/src/routes/create/post/+page.svelte index 4a3469ee..6b8a3aed 100644 --- a/src/routes/create/post/+page.svelte +++ b/src/routes/create/post/+page.svelte @@ -1,8 +1,8 @@ diff --git a/src/routes/inbox/+page.svelte b/src/routes/inbox/+page.svelte index 34340614..dd6327c6 100644 --- a/src/routes/inbox/+page.svelte +++ b/src/routes/inbox/+page.svelte @@ -1,18 +1,16 @@ diff --git a/src/routes/instances/+layout.ts b/src/routes/instances/+layout.ts index 5cab2741..8a5fd2a1 100644 --- a/src/routes/instances/+layout.ts +++ b/src/routes/instances/+layout.ts @@ -1,4 +1,4 @@ -import { getClient } from '$lib/client/lemmy.svelte' +import { getClient } from '$lib/api/client.svelte' export async function load({ fetch }) { return (await getClient(undefined, fetch).getFederatedInstances()) diff --git a/src/routes/instances/[instance]/+page.svelte b/src/routes/instances/[instance]/+page.svelte deleted file mode 100644 index e69de29b..00000000 diff --git a/src/routes/instances/blocked/+page.svelte b/src/routes/instances/blocked/+page.svelte index 6d3c6b22..34ae3966 100644 --- a/src/routes/instances/blocked/+page.svelte +++ b/src/routes/instances/blocked/+page.svelte @@ -1,11 +1,11 @@ diff --git a/src/routes/login/+page.svelte b/src/routes/login/+page.svelte index a2b8a851..4ca3ec6f 100644 --- a/src/routes/login/+page.svelte +++ b/src/routes/login/+page.svelte @@ -1,28 +1,28 @@ diff --git a/src/routes/moderation/+layout.ts b/src/routes/moderation/+layout.ts index 5b3f1567..8121ad92 100644 --- a/src/routes/moderation/+layout.ts +++ b/src/routes/moderation/+layout.ts @@ -1,4 +1,4 @@ -import { profile } from '$lib/auth.svelte' +import { profile } from '$lib/app/auth.svelte' import { error } from '@sveltejs/kit' export function load() { diff --git a/src/routes/moderation/+page.svelte b/src/routes/moderation/+page.svelte index 28520aa8..7907b2ad 100644 --- a/src/routes/moderation/+page.svelte +++ b/src/routes/moderation/+page.svelte @@ -1,21 +1,24 @@
@@ -38,7 +37,6 @@ }, subscribed: 'NotSubscribed', }} - class="py-1 -mx-4 px-4" >