Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port frontend to Svelte 5 and SvelteKit #524

Merged
merged 41 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
cca4338
begin port
aumetra Apr 29, 2024
611cacb
rewrite frontpage
aumetra May 1, 2024
195cf61
add graphql client
aumetra May 1, 2024
b96d25a
add unplugin-icons
aumetra May 1, 2024
995884f
frontpage overhaul
aumetra May 1, 2024
b6db85b
add register functionality
aumetra May 1, 2024
b12dc7d
new layout
vesdev May 5, 2024
8f0d232
format codebase
aumetra May 5, 2024
b83c519
delete old frontend
aumetra Aug 1, 2024
175c4ee
add secondary button style
aumetra Aug 1, 2024
e7c4f76
update deps
aumetra Aug 1, 2024
c0de7bb
fix page builds
aumetra Aug 1, 2024
a4d53e5
migrate eslint
aumetra Aug 1, 2024
603c083
update action
aumetra Aug 1, 2024
52b1988
fix overlay
aumetra Aug 1, 2024
7c964ee
fix colour accessibility in button
aumetra Aug 2, 2024
31dcb92
fix static builds and warnings
aumetra Aug 2, 2024
aba4f9f
Add banner, use svg
aumetra Aug 5, 2024
3a0d845
add graphql interactions
aumetra Aug 5, 2024
1b94892
properly embed version
aumetra Aug 5, 2024
01f4be9
fix some styles
aumetra Aug 6, 2024
fed8602
up
aumetra Aug 6, 2024
0e4e2d3
rm border radius
aumetra Aug 6, 2024
8893335
fix cargo features
aumetra Aug 6, 2024
4752845
add queries
aumetra Aug 6, 2024
b393456
add dialog, finish register
aumetra Aug 7, 2024
797d0ce
add mutation for oauth app register
aumetra Aug 7, 2024
b85579b
rm unused asset
aumetra Aug 7, 2024
0bf5b5a
reformat codebase
aumetra Aug 7, 2024
1adf539
add loading indicator
aumetra Aug 8, 2024
4fdb37d
restructure
aumetra Aug 8, 2024
e4b93cc
add form validation via zod
aumetra Aug 8, 2024
a7fec70
update media query
aumetra Aug 8, 2024
0e5a1db
allow lint
aumetra Aug 9, 2024
fa42aee
up
aumetra Aug 11, 2024
5500f03
oauth progress
aumetra Aug 12, 2024
c20f5d4
Fix warnings
aumetra Aug 28, 2024
d319c23
Merge branch 'main' into svelte5-frontend
aumetra Sep 2, 2024
1c342ac
up
aumetra Sep 2, 2024
be29670
Merge branch 'main' into svelte5-frontend
aumetra Sep 4, 2024
eccb742
fix lints
aumetra Sep 4, 2024
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
Prev Previous commit
Next Next commit
add queries
  • Loading branch information
aumetra committed Aug 28, 2024
commit 4752845ad60c8b9b6c775e02e2da652ff9a8bdad
3 changes: 3 additions & 0 deletions kitsune-fe/houdini.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ const config = {
scalars: {
DateTime: {
type: 'Date'
},
UUID: {
type: 'string'
}
}
};
Expand Down
226 changes: 130 additions & 96 deletions kitsune-fe/schema.graphql
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
schema {
query: RootQuery
mutation: RootMutation
query: RootQuery
mutation: RootMutation
}

"""
Expand All @@ -10,27 +10,27 @@ Indicates that an Input Object is a OneOf Input Object (and thus requires
directive @oneOf on INPUT_OBJECT

type Account {
avatar: MediaAttachment
createdAt: DateTime!
displayName: String
header: MediaAttachment
id: UUID!
locked: Boolean!
note: String
posts(after: String, before: String, first: Int, last: Int): PostConnection!
updatedAt: DateTime!
url: String!
username: String!
avatar: MediaAttachment
createdAt: DateTime!
displayName: String
header: MediaAttachment
id: UUID!
locked: Boolean!
note: String
posts(after: String, before: String, first: Int, last: Int): PostConnection!
updatedAt: DateTime!
url: String!
username: String!
}

enum CaptchaBackend {
H_CAPTCHA
M_CAPTCHA
H_CAPTCHA
M_CAPTCHA
}

type CaptchaInfo {
backend: CaptchaBackend!
key: String!
backend: CaptchaBackend!
key: String!
}

"""
Expand All @@ -44,99 +44,133 @@ format, but it is always normalized to the UTC (Z) offset, e.g.
scalar DateTime

type Instance {
captcha: CaptchaInfo
characterLimit: Int!
description: String!
domain: String!
localPostCount: Int!
name: String!
registrationsOpen: Boolean!
userCount: Int!
version: String!
captcha: CaptchaInfo
characterLimit: Int!
description: String!
domain: String!
localPostCount: Int!
name: String!
registrationsOpen: Boolean!
userCount: Int!
version: String!
}

type MediaAttachment {
blurhash: String
contentType: String!
createdAt: DateTime!
description: String
id: UUID!
uploader: Account!
url: String!
blurhash: String
contentType: String!
createdAt: DateTime!
description: String
id: UUID!
uploader: Account!
url: String!
}

type OAuth2Application {
createdAt: DateTime!
id: UUID!
name: String!
redirectUri: String!
secret: String!
updatedAt: DateTime!
createdAt: DateTime!
id: UUID!
name: String!
redirectUri: String!
secret: String!
updatedAt: DateTime!
}

"""Information about pagination in a connection"""
"""
Information about pagination in a connection
"""
type PageInfo {
"""When paginating forwards, the cursor to continue."""
endCursor: String

"""When paginating forwards, are there more items?"""
hasNextPage: Boolean!

"""When paginating backwards, are there more items?"""
hasPreviousPage: Boolean!

"""When paginating backwards, the cursor to continue."""
startCursor: String
"""
When paginating forwards, the cursor to continue.
"""
endCursor: String

"""
When paginating forwards, are there more items?
"""
hasNextPage: Boolean!

"""
When paginating backwards, are there more items?
"""
hasPreviousPage: Boolean!

"""
When paginating backwards, the cursor to continue.
"""
startCursor: String
}

type Post {
account: Account!
attachments: [MediaAttachment!]!
content: String!
createdAt: DateTime!
id: UUID!
isSensitive: Boolean!
subject: String
updatedAt: DateTime!
url: String!
visibility: Visibility!
account: Account!
attachments: [MediaAttachment!]!
content: String!
createdAt: DateTime!
id: UUID!
isSensitive: Boolean!
subject: String
updatedAt: DateTime!
url: String!
visibility: Visibility!
}

type PostConnection {
"""A list of edges."""
edges: [PostEdge!]!

"""A list of nodes."""
nodes: [Post!]!

"""Information to aid in pagination."""
pageInfo: PageInfo!
"""
A list of edges.
"""
edges: [PostEdge!]!

"""
A list of nodes.
"""
nodes: [Post!]!

"""
Information to aid in pagination.
"""
pageInfo: PageInfo!
}

"""An edge in a connection."""
"""
An edge in a connection.
"""
type PostEdge {
"""A cursor for use in pagination"""
cursor: String!

"""The item at the end of the edge"""
node: Post!
"""
A cursor for use in pagination
"""
cursor: String!

"""
The item at the end of the edge
"""
node: Post!
}

type RootMutation {
createPost(content: String!, isSensitive: Boolean!, visibility: Visibility!): Post!
deletePost(id: UUID!): UUID!
registerOauthApplication(name: String!, redirectUri: String!): OAuth2Application!
registerUser(captchaToken: String, email: String!, password: String!, username: String!): User!
updateUser(avatar: Upload, displayName: String, header: Upload, locked: Boolean, note: String): Account!
createPost(content: String!, isSensitive: Boolean!, visibility: Visibility!): Post!
deletePost(id: UUID!): UUID!
registerOauthApplication(name: String!, redirectUri: String!): OAuth2Application!
registerUser(captchaToken: String, email: String!, password: String!, username: String!): User!
updateUser(
avatar: Upload
displayName: String
header: Upload
locked: Boolean
note: String
): Account!
}

type RootQuery {
getAccountById(id: UUID!): Account
getPostById(id: UUID!): Post!
homeTimeline(after: String, before: String, first: Int, last: Int): PostConnection!
instance: Instance!
myAccount: Account!
publicTimeline(after: String, before: String, first: Int, last: Int, onlyLocal: Boolean! = true): PostConnection!
getAccountById(id: UUID!): Account
getPostById(id: UUID!): Post!
homeTimeline(after: String, before: String, first: Int, last: Int): PostConnection!
instance: Instance!
myAccount: Account!
publicTimeline(
after: String
before: String
first: Int
last: Int
onlyLocal: Boolean! = true
): PostConnection!
}

"""
Expand All @@ -154,17 +188,17 @@ scalar UUID
scalar Upload

type User {
account: Account!
createdAt: DateTime!
email: String!
id: UUID!
updatedAt: DateTime!
username: String!
account: Account!
createdAt: DateTime!
email: String!
id: UUID!
updatedAt: DateTime!
username: String!
}

enum Visibility {
FOLLOWER_ONLY
MENTION_ONLY
PUBLIC
UNLISTED
FOLLOWER_ONLY
MENTION_ONLY
PUBLIC
UNLISTED
}
5 changes: 5 additions & 0 deletions kitsune-fe/src/lib/graphql/RegisterUser.gql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
mutation RegisterUser($username: String!, $email: String!, $password: String!) {
registerUser(username: $username, email: $email, password: $password) {
id
}
}
16 changes: 12 additions & 4 deletions kitsune-fe/src/routes/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
<script lang="ts">
import { RegisterUserStore } from '$houdini';
import Button from '$lib/components/Button.svelte';
import type { PageData } from './$houdini';

const { data }: { data: PageData } = $props();

let statsStore = $derived(data.stats);
let stats = $derived({
const registerButtonDisabled = $state(false);
const statsStore = $derived(data.stats);
const stats = $derived({
postCount: $statsStore.data?.instance.localPostCount ?? 0,
registeredUsers: $statsStore.data?.instance.userCount ?? 0
});

let registerButtonDisabled = $state(false);
const register = new RegisterUserStore();

function doRegister(event: SubmitEvent) {
event.preventDefault();

alert('registering');
}

function initiateLogin() {
alert('logging in wwowowowowowo');
Expand Down Expand Up @@ -39,7 +47,7 @@

<div class="section-right">
<div class="section-right-content">
<form class="register-form" method="post">
<form class="register-form" onsubmit={doRegister}>
<label for="username">Username</label>
<input placeholder="hangaku" type="text" name="username" />

Expand Down