[FA-misc] Astro migration works, probably want to touchup the frontend but that can be in Phase 4
@@ -12,28 +12,30 @@ public class Program
|
|||||||
|
|
||||||
#region Fusion Gateway
|
#region Fusion Gateway
|
||||||
|
|
||||||
|
// Register header propagation service to forward Authorization header to subgraphs
|
||||||
builder.Services.AddHttpClient("Fusion")
|
builder.Services.AddHttpClient("Fusion")
|
||||||
.AddHeaderPropagation(opt =>
|
.AddHeaderPropagation();
|
||||||
{
|
builder.Services.AddHeaderPropagation(opt =>
|
||||||
opt.Headers.Add("Authorization");
|
{
|
||||||
});
|
opt.Headers.Add("Authorization");
|
||||||
|
});
|
||||||
|
|
||||||
builder.Services
|
builder.Services
|
||||||
.AddFusionGatewayServer()
|
.AddFusionGatewayServer()
|
||||||
.ConfigureFromFile("gateway.fgp")
|
.ConfigureFromFile("gateway.fgp")
|
||||||
.CoreBuilder.ApplySaneDefaults();
|
.CoreBuilder.ApplySaneDefaults();
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
// Add authentication
|
|
||||||
builder.Services.AddOidcAuthentication(builder.Configuration);
|
builder.Services.AddOidcAuthentication(builder.Configuration);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
var allowedOrigin = builder.Configuration["Cors:AllowedOrigin"] ?? "http://localhost:4321";
|
||||||
builder.Services.AddCors(options =>
|
builder.Services.AddCors(options =>
|
||||||
{
|
{
|
||||||
options.AddPolicy("AllowFictionArchiveOrigins",
|
options.AddPolicy("AllowFictionArchiveOrigins",
|
||||||
policyBuilder =>
|
policyBuilder =>
|
||||||
{
|
{
|
||||||
policyBuilder.WithOrigins("https://fictionarchive.orfl.xyz", "http://localhost:5173")
|
policyBuilder.WithOrigins(allowedOrigin)
|
||||||
.AllowAnyMethod()
|
.AllowAnyMethod()
|
||||||
.AllowAnyHeader()
|
.AllowAnyHeader()
|
||||||
.AllowCredentials();
|
.AllowCredentials();
|
||||||
|
|||||||
@@ -6,10 +6,13 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"AllowedHosts": "*",
|
"AllowedHosts": "*",
|
||||||
|
"Cors": {
|
||||||
|
"AllowedOrigin": "http://localhost:4321"
|
||||||
|
},
|
||||||
"OIDC": {
|
"OIDC": {
|
||||||
"Authority": "https://auth.orfl.xyz/application/o/fiction-archive/",
|
"Authority": "https://auth.orfl.xyz/application/o/fiction-archive/",
|
||||||
"ClientId": "fictionarchive-api",
|
"ClientId": "ldi5IpEidq2WW0Ka1lehVskb2SOBjnYRaZCpEyBh",
|
||||||
"Audience": "fictionarchive-api",
|
"Audience": "ldi5IpEidq2WW0Ka1lehVskb2SOBjnYRaZCpEyBh",
|
||||||
"ValidIssuer": "https://auth.orfl.xyz/application/o/fiction-archive/",
|
"ValidIssuer": "https://auth.orfl.xyz/application/o/fiction-archive/",
|
||||||
"ValidateIssuer": true,
|
"ValidateIssuer": true,
|
||||||
"ValidateAudience": true,
|
"ValidateAudience": true,
|
||||||
|
|||||||
@@ -20,8 +20,8 @@
|
|||||||
},
|
},
|
||||||
"OIDC": {
|
"OIDC": {
|
||||||
"Authority": "https://auth.orfl.xyz/application/o/fiction-archive/",
|
"Authority": "https://auth.orfl.xyz/application/o/fiction-archive/",
|
||||||
"ClientId": "fictionarchive-files",
|
"ClientId": "ldi5IpEidq2WW0Ka1lehVskb2SOBjnYRaZCpEyBh",
|
||||||
"Audience": "fictionarchive-api",
|
"Audience": "ldi5IpEidq2WW0Ka1lehVskb2SOBjnYRaZCpEyBh",
|
||||||
"ValidIssuer": "https://auth.orfl.xyz/application/o/fiction-archive/",
|
"ValidIssuer": "https://auth.orfl.xyz/application/o/fiction-archive/",
|
||||||
"ValidateIssuer": true,
|
"ValidateIssuer": true,
|
||||||
"ValidateAudience": true,
|
"ValidateAudience": true,
|
||||||
|
|||||||
@@ -15,8 +15,8 @@
|
|||||||
"AllowedHosts": "*",
|
"AllowedHosts": "*",
|
||||||
"OIDC": {
|
"OIDC": {
|
||||||
"Authority": "https://auth.orfl.xyz/application/o/fiction-archive/",
|
"Authority": "https://auth.orfl.xyz/application/o/fiction-archive/",
|
||||||
"ClientId": "fictionarchive-api",
|
"ClientId": "ldi5IpEidq2WW0Ka1lehVskb2SOBjnYRaZCpEyBh",
|
||||||
"Audience": "fictionarchive-api",
|
"Audience": "ldi5IpEidq2WW0Ka1lehVskb2SOBjnYRaZCpEyBh",
|
||||||
"ValidIssuer": "https://auth.orfl.xyz/application/o/fiction-archive/",
|
"ValidIssuer": "https://auth.orfl.xyz/application/o/fiction-archive/",
|
||||||
"ValidateIssuer": true,
|
"ValidateIssuer": true,
|
||||||
"ValidateAudience": true,
|
"ValidateAudience": true,
|
||||||
|
|||||||
@@ -18,8 +18,8 @@
|
|||||||
"AllowedHosts": "*",
|
"AllowedHosts": "*",
|
||||||
"OIDC": {
|
"OIDC": {
|
||||||
"Authority": "https://auth.orfl.xyz/application/o/fiction-archive/",
|
"Authority": "https://auth.orfl.xyz/application/o/fiction-archive/",
|
||||||
"ClientId": "fictionarchive-api",
|
"ClientId": "ldi5IpEidq2WW0Ka1lehVskb2SOBjnYRaZCpEyBh",
|
||||||
"Audience": "fictionarchive-api",
|
"Audience": "ldi5IpEidq2WW0Ka1lehVskb2SOBjnYRaZCpEyBh",
|
||||||
"ValidIssuer": "https://auth.orfl.xyz/application/o/fiction-archive/",
|
"ValidIssuer": "https://auth.orfl.xyz/application/o/fiction-archive/",
|
||||||
"ValidateIssuer": true,
|
"ValidateIssuer": true,
|
||||||
"ValidateAudience": true,
|
"ValidateAudience": true,
|
||||||
|
|||||||
@@ -15,8 +15,8 @@
|
|||||||
"AllowedHosts": "*",
|
"AllowedHosts": "*",
|
||||||
"OIDC": {
|
"OIDC": {
|
||||||
"Authority": "https://auth.orfl.xyz/application/o/fiction-archive/",
|
"Authority": "https://auth.orfl.xyz/application/o/fiction-archive/",
|
||||||
"ClientId": "fictionarchive-api",
|
"ClientId": "ldi5IpEidq2WW0Ka1lehVskb2SOBjnYRaZCpEyBh",
|
||||||
"Audience": "fictionarchive-api",
|
"Audience": "ldi5IpEidq2WW0Ka1lehVskb2SOBjnYRaZCpEyBh",
|
||||||
"ValidIssuer": "https://auth.orfl.xyz/application/o/fiction-archive/",
|
"ValidIssuer": "https://auth.orfl.xyz/application/o/fiction-archive/",
|
||||||
"ValidateIssuer": true,
|
"ValidateIssuer": true,
|
||||||
"ValidateAudience": true,
|
"ValidateAudience": true,
|
||||||
|
|||||||
@@ -157,6 +157,7 @@ services:
|
|||||||
OIDC__Authority: https://auth.orfl.xyz/application/o/fictionarchive/
|
OIDC__Authority: https://auth.orfl.xyz/application/o/fictionarchive/
|
||||||
OIDC__ClientId: fictionarchive-api
|
OIDC__ClientId: fictionarchive-api
|
||||||
OIDC__Audience: fictionarchive-api
|
OIDC__Audience: fictionarchive-api
|
||||||
|
Cors__AllowedOrigin: https://fictionarchive.orfl.xyz
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:8080/healthz"]
|
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:8080/healthz"]
|
||||||
interval: 30s
|
interval: 30s
|
||||||
|
|||||||
@@ -4,37 +4,35 @@ node_modules
|
|||||||
# Build output
|
# Build output
|
||||||
dist
|
dist
|
||||||
|
|
||||||
# Environment files
|
# Development files
|
||||||
.env
|
.env
|
||||||
.env.local
|
.env.local
|
||||||
.env.*.local
|
.env.*.local
|
||||||
|
|
||||||
# IDE and editor
|
# IDE
|
||||||
.vscode
|
.vscode
|
||||||
.idea
|
.idea
|
||||||
*.swp
|
*.swp
|
||||||
*.swo
|
*.swo
|
||||||
|
|
||||||
|
# OS
|
||||||
|
.DS_Store
|
||||||
|
Thumbs.db
|
||||||
|
|
||||||
# Git
|
# Git
|
||||||
.git
|
.git
|
||||||
.gitignore
|
.gitignore
|
||||||
|
|
||||||
# Logs
|
# Logs
|
||||||
|
*.log
|
||||||
npm-debug.log*
|
npm-debug.log*
|
||||||
yarn-debug.log*
|
|
||||||
yarn-error.log*
|
|
||||||
|
|
||||||
# Test coverage
|
# Test files
|
||||||
|
*.test.*
|
||||||
|
*.spec.*
|
||||||
|
__tests__
|
||||||
coverage
|
coverage
|
||||||
|
|
||||||
# Docker
|
|
||||||
Dockerfile
|
|
||||||
.dockerignore
|
|
||||||
docker-compose*
|
|
||||||
|
|
||||||
# Documentation
|
# Documentation
|
||||||
README.md
|
README.md
|
||||||
*.md
|
CHANGELOG.md
|
||||||
|
|
||||||
# TypeScript build info
|
|
||||||
*.tsbuildinfo
|
|
||||||
12
fictionarchive-web-astro/.env.example
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
# GraphQL endpoint
|
||||||
|
PUBLIC_GRAPHQL_URI=https://localhost:7063/graphql/
|
||||||
|
|
||||||
|
# OIDC Configuration
|
||||||
|
PUBLIC_OIDC_AUTHORITY=https://auth.orfl.xyz/application/o/fiction-archive/
|
||||||
|
PUBLIC_OIDC_CLIENT_ID=ldi5IpEidq2WW0Ka1lehVskb2SOBjnYRaZCpEyBh
|
||||||
|
PUBLIC_OIDC_REDIRECT_URI=http://localhost:4321/
|
||||||
|
PUBLIC_OIDC_POST_LOGOUT_REDIRECT_URI=http://localhost:4321/
|
||||||
|
PUBLIC_OIDC_SCOPE=openid profile email
|
||||||
|
|
||||||
|
# Optional: Token for GraphQL codegen (for authenticated schema introspection)
|
||||||
|
# CODEGEN_TOKEN=your_token_here
|
||||||
24
fictionarchive-web-astro/.gitignore
vendored
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
# build output
|
||||||
|
dist/
|
||||||
|
# generated types
|
||||||
|
.astro/
|
||||||
|
|
||||||
|
# dependencies
|
||||||
|
node_modules/
|
||||||
|
|
||||||
|
# logs
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
pnpm-debug.log*
|
||||||
|
|
||||||
|
|
||||||
|
# environment variables
|
||||||
|
.env
|
||||||
|
.env.production
|
||||||
|
|
||||||
|
# macOS-specific files
|
||||||
|
.DS_Store
|
||||||
|
|
||||||
|
# jetbrains setting folder
|
||||||
|
.idea/
|
||||||
4
fictionarchive-web-astro/.vscode/extensions.json
vendored
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"recommendations": ["astro-build.astro-vscode"],
|
||||||
|
"unwantedRecommendations": []
|
||||||
|
}
|
||||||
11
fictionarchive-web-astro/.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"command": "./node_modules/.bin/astro dev",
|
||||||
|
"name": "Development server",
|
||||||
|
"request": "launch",
|
||||||
|
"type": "node-terminal"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
45
fictionarchive-web-astro/Dockerfile
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
FROM node:20-alpine AS build
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Build arguments for environment variables
|
||||||
|
ARG PUBLIC_GRAPHQL_URI
|
||||||
|
ARG PUBLIC_OIDC_AUTHORITY
|
||||||
|
ARG PUBLIC_OIDC_CLIENT_ID
|
||||||
|
ARG PUBLIC_OIDC_REDIRECT_URI
|
||||||
|
ARG PUBLIC_OIDC_POST_LOGOUT_REDIRECT_URI
|
||||||
|
ARG PUBLIC_OIDC_SCOPE
|
||||||
|
|
||||||
|
# Set environment variables for build
|
||||||
|
ENV PUBLIC_GRAPHQL_URI=$PUBLIC_GRAPHQL_URI
|
||||||
|
ENV PUBLIC_OIDC_AUTHORITY=$PUBLIC_OIDC_AUTHORITY
|
||||||
|
ENV PUBLIC_OIDC_CLIENT_ID=$PUBLIC_OIDC_CLIENT_ID
|
||||||
|
ENV PUBLIC_OIDC_REDIRECT_URI=$PUBLIC_OIDC_REDIRECT_URI
|
||||||
|
ENV PUBLIC_OIDC_POST_LOGOUT_REDIRECT_URI=$PUBLIC_OIDC_POST_LOGOUT_REDIRECT_URI
|
||||||
|
ENV PUBLIC_OIDC_SCOPE=$PUBLIC_OIDC_SCOPE
|
||||||
|
|
||||||
|
# Install dependencies
|
||||||
|
COPY package*.json ./
|
||||||
|
RUN npm ci
|
||||||
|
|
||||||
|
# Copy source and build
|
||||||
|
COPY . .
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
|
# Production runtime
|
||||||
|
FROM node:20-alpine AS runtime
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Copy built output and production dependencies
|
||||||
|
COPY --from=build /app/dist ./dist
|
||||||
|
COPY --from=build /app/node_modules ./node_modules
|
||||||
|
COPY --from=build /app/package.json ./
|
||||||
|
|
||||||
|
# Runtime configuration
|
||||||
|
ENV HOST=0.0.0.0
|
||||||
|
ENV PORT=80
|
||||||
|
EXPOSE 80
|
||||||
|
|
||||||
|
# Start the Node.js server
|
||||||
|
CMD ["node", "./dist/server/entry.mjs"]
|
||||||
43
fictionarchive-web-astro/README.md
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
# Astro Starter Kit: Minimal
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm create astro@latest -- --template minimal
|
||||||
|
```
|
||||||
|
|
||||||
|
> 🧑🚀 **Seasoned astronaut?** Delete this file. Have fun!
|
||||||
|
|
||||||
|
## 🚀 Project Structure
|
||||||
|
|
||||||
|
Inside of your Astro project, you'll see the following folders and files:
|
||||||
|
|
||||||
|
```text
|
||||||
|
/
|
||||||
|
├── public/
|
||||||
|
├── src/
|
||||||
|
│ └── pages/
|
||||||
|
│ └── index.astro
|
||||||
|
└── package.json
|
||||||
|
```
|
||||||
|
|
||||||
|
Astro looks for `.astro` or `.md` files in the `src/pages/` directory. Each page is exposed as a route based on its file name.
|
||||||
|
|
||||||
|
There's nothing special about `src/components/`, but that's where we like to put any Astro/React/Vue/Svelte/Preact components.
|
||||||
|
|
||||||
|
Any static assets, like images, can be placed in the `public/` directory.
|
||||||
|
|
||||||
|
## 🧞 Commands
|
||||||
|
|
||||||
|
All commands are run from the root of the project, from a terminal:
|
||||||
|
|
||||||
|
| Command | Action |
|
||||||
|
| :------------------------ | :----------------------------------------------- |
|
||||||
|
| `npm install` | Installs dependencies |
|
||||||
|
| `npm run dev` | Starts local dev server at `localhost:4321` |
|
||||||
|
| `npm run build` | Build your production site to `./dist/` |
|
||||||
|
| `npm run preview` | Preview your build locally, before deploying |
|
||||||
|
| `npm run astro ...` | Run CLI commands like `astro add`, `astro check` |
|
||||||
|
| `npm run astro -- --help` | Get help using the Astro CLI |
|
||||||
|
|
||||||
|
## 👀 Want to learn more?
|
||||||
|
|
||||||
|
Feel free to check [our documentation](https://docs.astro.build) or jump into our [Discord server](https://astro.build/chat).
|
||||||
17
fictionarchive-web-astro/astro.config.mjs
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import { defineConfig } from 'astro/config';
|
||||||
|
import svelte from '@astrojs/svelte';
|
||||||
|
import tailwindcss from '@tailwindcss/vite';
|
||||||
|
import node from '@astrojs/node';
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
output: 'server', // SSR mode - use prerender = true for static pages
|
||||||
|
adapter: node({
|
||||||
|
mode: 'standalone',
|
||||||
|
}),
|
||||||
|
integrations: [
|
||||||
|
svelte(),
|
||||||
|
],
|
||||||
|
vite: {
|
||||||
|
plugins: [tailwindcss()],
|
||||||
|
},
|
||||||
|
});
|
||||||
28
fictionarchive-web-astro/codegen.ts
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
import type { CodegenConfig } from '@graphql-codegen/cli';
|
||||||
|
import * as dotenv from 'dotenv';
|
||||||
|
|
||||||
|
dotenv.config({ path: '.env.local' });
|
||||||
|
dotenv.config();
|
||||||
|
|
||||||
|
const schema = process.env.PUBLIC_GRAPHQL_URI ?? 'https://localhost:7063/graphql/';
|
||||||
|
const authToken = process.env.CODEGEN_TOKEN;
|
||||||
|
|
||||||
|
const config: CodegenConfig = {
|
||||||
|
schema: {
|
||||||
|
[schema]: authToken ? { headers: { Authorization: `Bearer ${authToken}` } } : {},
|
||||||
|
},
|
||||||
|
documents: 'src/**/*.graphql',
|
||||||
|
generates: {
|
||||||
|
'src/lib/graphql/__generated__/graphql.ts': {
|
||||||
|
plugins: ['typescript', 'typescript-operations', 'typed-document-node'],
|
||||||
|
config: {
|
||||||
|
avoidOptionals: { field: true },
|
||||||
|
enumsAsConst: true,
|
||||||
|
skipTypename: true,
|
||||||
|
useTypeImports: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export default config;
|
||||||
16
fictionarchive-web-astro/components.json
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://shadcn-svelte.com/schema.json",
|
||||||
|
"tailwind": {
|
||||||
|
"css": "src\\styles\\global.css",
|
||||||
|
"baseColor": "gray"
|
||||||
|
},
|
||||||
|
"aliases": {
|
||||||
|
"components": "$lib/components",
|
||||||
|
"utils": "$lib/utils",
|
||||||
|
"ui": "$lib/components/ui",
|
||||||
|
"hooks": "$lib/hooks",
|
||||||
|
"lib": "$lib"
|
||||||
|
},
|
||||||
|
"typescript": true,
|
||||||
|
"registry": "https://shadcn-svelte.com/registry"
|
||||||
|
}
|
||||||
10562
fictionarchive-web-astro/package-lock.json
generated
Normal file
38
fictionarchive-web-astro/package.json
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
{
|
||||||
|
"name": "fictionarchive-web-astro",
|
||||||
|
"type": "module",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"scripts": {
|
||||||
|
"dev": "astro dev",
|
||||||
|
"build": "astro build",
|
||||||
|
"preview": "astro preview",
|
||||||
|
"astro": "astro",
|
||||||
|
"codegen": "graphql-codegen --config codegen.ts -r dotenv/config --use-system-ca"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@astrojs/node": "^9.5.1",
|
||||||
|
"@astrojs/svelte": "^7.2.2",
|
||||||
|
"@tailwindcss/vite": "^4.1.17",
|
||||||
|
"@urql/core": "^6.0.1",
|
||||||
|
"@urql/svelte": "^5.0.0",
|
||||||
|
"astro": "^5.16.2",
|
||||||
|
"class-variance-authority": "^0.7.1",
|
||||||
|
"clsx": "^2.1.1",
|
||||||
|
"graphql": "^16.12.0",
|
||||||
|
"oidc-client-ts": "^3.4.1",
|
||||||
|
"svelte": "^5.45.2",
|
||||||
|
"tailwind-merge": "^3.4.0",
|
||||||
|
"tailwindcss": "^4.1.17",
|
||||||
|
"typescript": "^5.9.3"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@graphql-codegen/cli": "^6.1.0",
|
||||||
|
"@graphql-codegen/typed-document-node": "^6.1.3",
|
||||||
|
"@graphql-codegen/typescript": "^5.0.5",
|
||||||
|
"@graphql-codegen/typescript-operations": "^5.0.5",
|
||||||
|
"@lucide/svelte": "^0.555.0",
|
||||||
|
"dotenv": "^16.6.1",
|
||||||
|
"tailwind-variants": "^3.2.2",
|
||||||
|
"tw-animate-css": "^1.4.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
9
fictionarchive-web-astro/public/favicon.svg
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 128 128">
|
||||||
|
<path d="M50.4 78.5a75.1 75.1 0 0 0-28.5 6.9l24.2-65.7c.7-2 1.9-3.2 3.4-3.2h29c1.5 0 2.7 1.2 3.4 3.2l24.2 65.7s-11.6-7-28.5-7L67 45.5c-.4-1.7-1.6-2.8-2.9-2.8-1.3 0-2.5 1.1-2.9 2.7L50.4 78.5Zm-1.1 28.2Zm-4.2-20.2c-2 6.6-.6 15.8 4.2 20.2a17.5 17.5 0 0 1 .2-.7 5.5 5.5 0 0 1 5.7-4.5c2.8.1 4.3 1.5 4.7 4.7.2 1.1.2 2.3.2 3.5v.4c0 2.7.7 5.2 2.2 7.4a13 13 0 0 0 5.7 4.9v-.3l-.2-.3c-1.8-5.6-.5-9.5 4.4-12.8l1.5-1a73 73 0 0 0 3.2-2.2 16 16 0 0 0 6.8-11.4c.3-2 .1-4-.6-6l-.8.6-1.6 1a37 37 0 0 1-22.4 2.7c-5-.7-9.7-2-13.2-6.2Z" />
|
||||||
|
<style>
|
||||||
|
path { fill: #000; }
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
path { fill: #FFF; }
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 749 B |
29
fictionarchive-web-astro/src/layouts/AppLayout.astro
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
---
|
||||||
|
import Navbar from '../lib/components/Navbar.svelte';
|
||||||
|
import AuthInit from '../lib/components/AuthInit.svelte';
|
||||||
|
import '../styles/global.css';
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
title?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const { title = 'FictionArchive' } = Astro.props;
|
||||||
|
---
|
||||||
|
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
||||||
|
<meta name="generator" content={Astro.generator} />
|
||||||
|
<title>{title}</title>
|
||||||
|
</head>
|
||||||
|
<body class="min-h-screen bg-background">
|
||||||
|
<AuthInit client:load />
|
||||||
|
<Navbar client:load />
|
||||||
|
<main class="mx-auto flex max-w-6xl flex-col gap-6 px-4 py-8 sm:px-6 lg:px-8">
|
||||||
|
<slot />
|
||||||
|
</main>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
115
fictionarchive-web-astro/src/lib/auth/authStore.ts
Normal file
@@ -0,0 +1,115 @@
|
|||||||
|
import { writable, derived } from 'svelte/store';
|
||||||
|
import type { User } from 'oidc-client-ts';
|
||||||
|
import { userManager, isOidcConfigured } from './oidcConfig';
|
||||||
|
|
||||||
|
// Stores
|
||||||
|
export const user = writable<User | null>(null);
|
||||||
|
export const isLoading = writable(true);
|
||||||
|
export const isAuthenticated = derived(user, ($user) => $user !== null);
|
||||||
|
export const isConfigured = isOidcConfigured;
|
||||||
|
|
||||||
|
// Cookie management
|
||||||
|
function setCookieFromUser(u: User) {
|
||||||
|
if (!u?.access_token) return;
|
||||||
|
|
||||||
|
const isProduction = window.location.hostname !== 'localhost';
|
||||||
|
const domain = isProduction ? '.orfl.xyz' : undefined;
|
||||||
|
const secure = isProduction;
|
||||||
|
const sameSite = isProduction ? 'None' : 'Lax';
|
||||||
|
|
||||||
|
const cookieValue = `fa_session=${u.access_token}; path=/; ${secure ? 'secure; ' : ''}samesite=${sameSite}${domain ? `; domain=${domain}` : ''}`;
|
||||||
|
document.cookie = cookieValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
function clearFaSessionCookie() {
|
||||||
|
const isProduction = window.location.hostname !== 'localhost';
|
||||||
|
const domain = isProduction ? '.orfl.xyz' : undefined;
|
||||||
|
|
||||||
|
const cookieValue = `fa_session=; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT${domain ? `; domain=${domain}` : ''}`;
|
||||||
|
document.cookie = cookieValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Track if callback has been handled to prevent double processing
|
||||||
|
let callbackHandled = false;
|
||||||
|
|
||||||
|
export async function initAuth() {
|
||||||
|
if (!userManager) {
|
||||||
|
isLoading.set(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle callback if auth params are present
|
||||||
|
const url = new URL(window.location.href);
|
||||||
|
const hasAuthParams =
|
||||||
|
url.searchParams.has('code') ||
|
||||||
|
url.searchParams.has('id_token') ||
|
||||||
|
url.searchParams.has('error');
|
||||||
|
|
||||||
|
if (hasAuthParams && !callbackHandled) {
|
||||||
|
callbackHandled = true;
|
||||||
|
try {
|
||||||
|
const result = await userManager.signinRedirectCallback();
|
||||||
|
user.set(result ?? null);
|
||||||
|
if (result) {
|
||||||
|
setCookieFromUser(result);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Failed to complete sign-in redirect', e);
|
||||||
|
} finally {
|
||||||
|
const cleanUrl = `${url.origin}${url.pathname}`;
|
||||||
|
window.history.replaceState({}, document.title, cleanUrl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Load existing user
|
||||||
|
try {
|
||||||
|
const loadedUser = await userManager.getUser();
|
||||||
|
user.set(loadedUser ?? null);
|
||||||
|
if (loadedUser) {
|
||||||
|
setCookieFromUser(loadedUser);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Failed to load user', e);
|
||||||
|
}
|
||||||
|
|
||||||
|
isLoading.set(false);
|
||||||
|
|
||||||
|
// Event listeners
|
||||||
|
userManager.events.addUserLoaded((u) => {
|
||||||
|
user.set(u);
|
||||||
|
setCookieFromUser(u);
|
||||||
|
});
|
||||||
|
|
||||||
|
userManager.events.addUserUnloaded(() => {
|
||||||
|
user.set(null);
|
||||||
|
clearFaSessionCookie();
|
||||||
|
});
|
||||||
|
|
||||||
|
userManager.events.addUserSignedOut(() => {
|
||||||
|
user.set(null);
|
||||||
|
clearFaSessionCookie();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function login() {
|
||||||
|
if (!userManager) {
|
||||||
|
console.warn('OIDC is not configured; set PUBLIC_OIDC_* environment variables.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await userManager.signinRedirect();
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function logout() {
|
||||||
|
if (!userManager) {
|
||||||
|
console.warn('OIDC is not configured; set PUBLIC_OIDC_* environment variables.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
clearFaSessionCookie();
|
||||||
|
await userManager.signoutRedirect();
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Failed to sign out via redirect, clearing local session instead.', error);
|
||||||
|
await userManager.removeUser();
|
||||||
|
user.set(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,17 +1,16 @@
|
|||||||
import { UserManager, WebStorageStateStore, type UserManagerSettings } from 'oidc-client-ts'
|
import { UserManager, WebStorageStateStore, type UserManagerSettings } from 'oidc-client-ts';
|
||||||
|
|
||||||
const authority = import.meta.env.VITE_OIDC_AUTHORITY
|
const authority = import.meta.env.PUBLIC_OIDC_AUTHORITY;
|
||||||
const clientId = import.meta.env.VITE_OIDC_CLIENT_ID
|
const clientId = import.meta.env.PUBLIC_OIDC_CLIENT_ID;
|
||||||
const redirectUri = import.meta.env.VITE_OIDC_REDIRECT_URI
|
const redirectUri = import.meta.env.PUBLIC_OIDC_REDIRECT_URI;
|
||||||
const postLogoutRedirectUri =
|
const postLogoutRedirectUri = import.meta.env.PUBLIC_OIDC_POST_LOGOUT_REDIRECT_URI ?? redirectUri;
|
||||||
import.meta.env.VITE_OIDC_POST_LOGOUT_REDIRECT_URI ?? redirectUri
|
const scope = import.meta.env.PUBLIC_OIDC_SCOPE ?? 'openid profile email';
|
||||||
const scope = import.meta.env.VITE_OIDC_SCOPE ?? 'openid profile email'
|
|
||||||
|
|
||||||
export const isOidcConfigured =
|
export const isOidcConfigured =
|
||||||
Boolean(authority) && Boolean(clientId) && Boolean(redirectUri)
|
Boolean(authority) && Boolean(clientId) && Boolean(redirectUri);
|
||||||
|
|
||||||
function buildSettings(): UserManagerSettings | null {
|
function buildSettings(): UserManagerSettings | null {
|
||||||
if (!isOidcConfigured) return null
|
if (!isOidcConfigured) return null;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
authority: authority!,
|
authority: authority!,
|
||||||
@@ -26,11 +25,11 @@ function buildSettings(): UserManagerSettings | null {
|
|||||||
typeof window !== 'undefined'
|
typeof window !== 'undefined'
|
||||||
? new WebStorageStateStore({ store: window.localStorage })
|
? new WebStorageStateStore({ store: window.localStorage })
|
||||||
: undefined,
|
: undefined,
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export const userManager = (() => {
|
export const userManager = (() => {
|
||||||
const settings = buildSettings()
|
const settings = buildSettings();
|
||||||
if (!settings) return null
|
if (!settings) return null;
|
||||||
return new UserManager(settings)
|
return new UserManager(settings);
|
||||||
})()
|
})();
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { onMount } from 'svelte';
|
||||||
|
import { initAuth } from '$lib/auth/authStore';
|
||||||
|
|
||||||
|
onMount(() => {
|
||||||
|
initAuth();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { user, isLoading, isConfigured, login, logout } from '$lib/auth/authStore';
|
||||||
|
import { Button } from '$lib/components/ui/button';
|
||||||
|
|
||||||
|
let isOpen = $state(false);
|
||||||
|
|
||||||
|
const email = $derived(
|
||||||
|
$user?.profile?.email ??
|
||||||
|
$user?.profile?.preferred_username ??
|
||||||
|
$user?.profile?.name ??
|
||||||
|
$user?.profile?.sub ??
|
||||||
|
'User'
|
||||||
|
);
|
||||||
|
|
||||||
|
function handleClickOutside(event: MouseEvent) {
|
||||||
|
const target = event.target as HTMLElement;
|
||||||
|
if (!target.closest('.auth-dropdown')) {
|
||||||
|
isOpen = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleDropdown() {
|
||||||
|
isOpen = !isOpen;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleLogout() {
|
||||||
|
isOpen = false;
|
||||||
|
await logout();
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<svelte:window onclick={handleClickOutside} />
|
||||||
|
|
||||||
|
{#if $isLoading}
|
||||||
|
<Button variant="outline" disabled>Loading...</Button>
|
||||||
|
{:else if !isConfigured}
|
||||||
|
<span class="text-sm text-yellow-600">Auth not configured</span>
|
||||||
|
{:else if $user}
|
||||||
|
<div class="auth-dropdown relative">
|
||||||
|
<Button variant="outline" onclick={toggleDropdown}>
|
||||||
|
{email}
|
||||||
|
</Button>
|
||||||
|
{#if isOpen}
|
||||||
|
<div
|
||||||
|
class="absolute right-0 z-50 mt-2 w-48 rounded-md bg-white p-2 shadow-lg dark:bg-gray-800"
|
||||||
|
>
|
||||||
|
<Button variant="ghost" class="w-full justify-start" onclick={handleLogout}>
|
||||||
|
Sign out
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
{:else}
|
||||||
|
<Button onclick={login}>Sign in</Button>
|
||||||
|
{/if}
|
||||||
21
fictionarchive-web-astro/src/lib/components/Navbar.svelte
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { Button } from '$lib/components/ui/button';
|
||||||
|
import { Input } from '$lib/components/ui/input';
|
||||||
|
import AuthenticationDisplay from './AuthenticationDisplay.svelte';
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<header class="sticky top-0 z-10 border-b bg-white/80 backdrop-blur dark:bg-gray-900/80">
|
||||||
|
<nav class="mx-auto flex max-w-6xl items-center gap-4 px-4 py-3">
|
||||||
|
<a href="/" class="flex items-center gap-2">
|
||||||
|
<span class="rounded bg-primary px-2 py-1 font-bold text-white">FA</span>
|
||||||
|
<span class="font-semibold">FictionArchive</span>
|
||||||
|
</a>
|
||||||
|
<a href="/">
|
||||||
|
<Button variant="ghost">Novels</Button>
|
||||||
|
</a>
|
||||||
|
<div class="flex-1">
|
||||||
|
<Input type="search" placeholder="Search..." class="max-w-xs" />
|
||||||
|
</div>
|
||||||
|
<AuthenticationDisplay />
|
||||||
|
</nav>
|
||||||
|
</header>
|
||||||
45
fictionarchive-web-astro/src/lib/components/NovelCard.svelte
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
<script lang="ts" module>
|
||||||
|
import type { NovelsQuery } from '$lib/graphql/__generated__/graphql';
|
||||||
|
|
||||||
|
export type NovelNode = NonNullable<NonNullable<NovelsQuery['novels']>['edges']>[number]['node'];
|
||||||
|
|
||||||
|
export interface NovelCardProps {
|
||||||
|
novel: NovelNode;
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script lang="ts">
|
||||||
|
import { Card, CardContent, CardHeader, CardTitle } from '$lib/components/ui/card';
|
||||||
|
|
||||||
|
let { novel }: NovelCardProps = $props();
|
||||||
|
|
||||||
|
function pickText(novelText?: NovelNode['name'] | NovelNode['description']) {
|
||||||
|
const texts = novelText?.texts ?? [];
|
||||||
|
const english = texts.find((t) => t.language === 'EN');
|
||||||
|
return (english ?? texts[0])?.text ?? 'No description available.';
|
||||||
|
}
|
||||||
|
|
||||||
|
const title = $derived(pickText(novel.name));
|
||||||
|
const description = $derived(pickText(novel.description));
|
||||||
|
const coverSrc = $derived(novel.coverImage?.newPath ?? novel.coverImage?.originalPath);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<Card class="overflow-hidden border shadow-sm transition-shadow hover:shadow-md">
|
||||||
|
{#if coverSrc}
|
||||||
|
<div class="aspect-[3/4] w-full overflow-hidden bg-muted/50">
|
||||||
|
<img src={coverSrc} alt={title} class="h-full w-full object-cover" loading="lazy" />
|
||||||
|
</div>
|
||||||
|
{:else}
|
||||||
|
<div class="aspect-[3/4] w-full bg-muted/50"></div>
|
||||||
|
{/if}
|
||||||
|
<CardHeader class="space-y-2">
|
||||||
|
<CardTitle class="line-clamp-2 text-lg leading-tight">
|
||||||
|
{title}
|
||||||
|
</CardTitle>
|
||||||
|
</CardHeader>
|
||||||
|
<CardContent class="pt-0">
|
||||||
|
<p class="line-clamp-3 text-sm text-muted-foreground">
|
||||||
|
{description}
|
||||||
|
</p>
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { Card, CardContent, CardHeader, CardTitle } from '$lib/components/ui/card';
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
novelId?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
let { novelId }: Props = $props();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<Card class="shadow-md shadow-primary/10">
|
||||||
|
<CardHeader>
|
||||||
|
<CardTitle>Novel Details</CardTitle>
|
||||||
|
</CardHeader>
|
||||||
|
<CardContent>
|
||||||
|
<p class="text-sm text-muted-foreground">
|
||||||
|
{#if novelId}
|
||||||
|
Viewing novel ID: <code class="rounded bg-muted px-1 py-0.5">{novelId}</code>
|
||||||
|
{/if}
|
||||||
|
</p>
|
||||||
|
<p class="mt-2 text-sm text-muted-foreground">
|
||||||
|
Detail view coming soon. Select a novel to explore chapters and metadata once implemented.
|
||||||
|
</p>
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
117
fictionarchive-web-astro/src/lib/components/NovelsPage.svelte
Normal file
@@ -0,0 +1,117 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { onMount } from 'svelte';
|
||||||
|
import { client } from '$lib/graphql/client';
|
||||||
|
import { NovelsDocument, type NovelsQuery } from '$lib/graphql/__generated__/graphql';
|
||||||
|
import NovelCard from './NovelCard.svelte';
|
||||||
|
import { Button } from '$lib/components/ui/button';
|
||||||
|
import { Card, CardContent, CardHeader, CardTitle } from '$lib/components/ui/card';
|
||||||
|
|
||||||
|
const PAGE_SIZE = 12;
|
||||||
|
|
||||||
|
type NovelEdge = NonNullable<NovelsQuery['novels']>['edges'][number];
|
||||||
|
|
||||||
|
let edges: NovelEdge[] = $state([]);
|
||||||
|
let pageInfo: NonNullable<NovelsQuery['novels']>['pageInfo'] | null = $state(null);
|
||||||
|
let fetching = $state(false);
|
||||||
|
let error: string | null = $state(null);
|
||||||
|
let initialLoad = $state(true);
|
||||||
|
|
||||||
|
const hasNextPage = $derived(pageInfo?.hasNextPage ?? false);
|
||||||
|
const novels = $derived(edges.map((edge) => edge.node).filter(Boolean));
|
||||||
|
|
||||||
|
async function fetchNovels(after: string | null = null) {
|
||||||
|
fetching = true;
|
||||||
|
error = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const result = await client.query(NovelsDocument, { first: PAGE_SIZE, after }).toPromise();
|
||||||
|
|
||||||
|
if (result.error) {
|
||||||
|
error = result.error.message;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result.data?.novels) {
|
||||||
|
if (after) {
|
||||||
|
// Append for pagination
|
||||||
|
edges = [...edges, ...result.data.novels.edges];
|
||||||
|
} else {
|
||||||
|
// Initial load
|
||||||
|
edges = result.data.novels.edges;
|
||||||
|
}
|
||||||
|
pageInfo = result.data.novels.pageInfo;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
error = e instanceof Error ? e.message : 'Unknown error';
|
||||||
|
} finally {
|
||||||
|
fetching = false;
|
||||||
|
initialLoad = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function loadMore() {
|
||||||
|
if (pageInfo?.endCursor) {
|
||||||
|
fetchNovels(pageInfo.endCursor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onMount(() => {
|
||||||
|
fetchNovels();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="space-y-4">
|
||||||
|
<Card class="shadow-md shadow-primary/10">
|
||||||
|
<CardHeader>
|
||||||
|
<CardTitle>Latest Novels</CardTitle>
|
||||||
|
<p class="text-sm text-muted-foreground">Novels that have recently been updated.</p>
|
||||||
|
</CardHeader>
|
||||||
|
</Card>
|
||||||
|
|
||||||
|
{#if fetching && initialLoad}
|
||||||
|
<Card>
|
||||||
|
<CardContent>
|
||||||
|
<div class="flex items-center justify-center py-8">
|
||||||
|
<div
|
||||||
|
class="h-10 w-10 animate-spin rounded-full border-2 border-primary border-t-transparent"
|
||||||
|
aria-label="Loading novels"
|
||||||
|
></div>
|
||||||
|
</div>
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
{#if error}
|
||||||
|
<Card class="border-destructive/40 bg-destructive/5">
|
||||||
|
<CardContent>
|
||||||
|
<p class="py-4 text-sm text-destructive">Could not load novels: {error}</p>
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
{#if !fetching && novels.length === 0 && !error && !initialLoad}
|
||||||
|
<Card>
|
||||||
|
<CardContent>
|
||||||
|
<p class="py-4 text-sm text-muted-foreground">
|
||||||
|
No novels found yet. Try adding content to the gateway.
|
||||||
|
</p>
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
{#if novels.length > 0}
|
||||||
|
<div class="grid gap-4 sm:grid-cols-2 lg:grid-cols-3">
|
||||||
|
{#each novels as novel (novel.id)}
|
||||||
|
<NovelCard {novel} />
|
||||||
|
{/each}
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
{#if hasNextPage}
|
||||||
|
<div class="flex justify-center">
|
||||||
|
<Button onclick={loadMore} variant="outline" disabled={fetching} class="min-w-[160px]">
|
||||||
|
{fetching ? 'Loading...' : 'Load more'}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
<script lang="ts" module>
|
||||||
|
import { type VariantProps, tv } from "tailwind-variants";
|
||||||
|
|
||||||
|
export const badgeVariants = tv({
|
||||||
|
base: "focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive inline-flex w-fit shrink-0 items-center justify-center gap-1 overflow-hidden whitespace-nowrap rounded-full border px-2 py-0.5 text-xs font-medium transition-[color,box-shadow] focus-visible:ring-[3px] [&>svg]:pointer-events-none [&>svg]:size-3",
|
||||||
|
variants: {
|
||||||
|
variant: {
|
||||||
|
default:
|
||||||
|
"bg-primary text-primary-foreground [a&]:hover:bg-primary/90 border-transparent",
|
||||||
|
secondary:
|
||||||
|
"bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90 border-transparent",
|
||||||
|
destructive:
|
||||||
|
"bg-destructive [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/70 border-transparent text-white",
|
||||||
|
outline: "text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
defaultVariants: {
|
||||||
|
variant: "default",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export type BadgeVariant = VariantProps<typeof badgeVariants>["variant"];
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script lang="ts">
|
||||||
|
import type { HTMLAnchorAttributes } from "svelte/elements";
|
||||||
|
import { cn, type WithElementRef } from "$lib/utils.js";
|
||||||
|
|
||||||
|
let {
|
||||||
|
ref = $bindable(null),
|
||||||
|
href,
|
||||||
|
class: className,
|
||||||
|
variant = "default",
|
||||||
|
children,
|
||||||
|
...restProps
|
||||||
|
}: WithElementRef<HTMLAnchorAttributes> & {
|
||||||
|
variant?: BadgeVariant;
|
||||||
|
} = $props();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<svelte:element
|
||||||
|
this={href ? "a" : "span"}
|
||||||
|
bind:this={ref}
|
||||||
|
data-slot="badge"
|
||||||
|
{href}
|
||||||
|
class={cn(badgeVariants({ variant }), className)}
|
||||||
|
{...restProps}
|
||||||
|
>
|
||||||
|
{@render children?.()}
|
||||||
|
</svelte:element>
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
export { default as Badge } from "./badge.svelte";
|
||||||
|
export { badgeVariants, type BadgeVariant } from "./badge.svelte";
|
||||||
@@ -0,0 +1,82 @@
|
|||||||
|
<script lang="ts" module>
|
||||||
|
import { cn, type WithElementRef } from "$lib/utils.js";
|
||||||
|
import type { HTMLAnchorAttributes, HTMLButtonAttributes } from "svelte/elements";
|
||||||
|
import { type VariantProps, tv } from "tailwind-variants";
|
||||||
|
|
||||||
|
export const buttonVariants = tv({
|
||||||
|
base: "focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive inline-flex shrink-0 items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium outline-none transition-all focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0",
|
||||||
|
variants: {
|
||||||
|
variant: {
|
||||||
|
default: "bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",
|
||||||
|
destructive:
|
||||||
|
"bg-destructive shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60 text-white",
|
||||||
|
outline:
|
||||||
|
"bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50 border",
|
||||||
|
secondary: "bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",
|
||||||
|
ghost: "hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",
|
||||||
|
link: "text-primary underline-offset-4 hover:underline",
|
||||||
|
},
|
||||||
|
size: {
|
||||||
|
default: "h-9 px-4 py-2 has-[>svg]:px-3",
|
||||||
|
sm: "h-8 gap-1.5 rounded-md px-3 has-[>svg]:px-2.5",
|
||||||
|
lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
|
||||||
|
icon: "size-9",
|
||||||
|
"icon-sm": "size-8",
|
||||||
|
"icon-lg": "size-10",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
defaultVariants: {
|
||||||
|
variant: "default",
|
||||||
|
size: "default",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export type ButtonVariant = VariantProps<typeof buttonVariants>["variant"];
|
||||||
|
export type ButtonSize = VariantProps<typeof buttonVariants>["size"];
|
||||||
|
|
||||||
|
export type ButtonProps = WithElementRef<HTMLButtonAttributes> &
|
||||||
|
WithElementRef<HTMLAnchorAttributes> & {
|
||||||
|
variant?: ButtonVariant;
|
||||||
|
size?: ButtonSize;
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script lang="ts">
|
||||||
|
let {
|
||||||
|
class: className,
|
||||||
|
variant = "default",
|
||||||
|
size = "default",
|
||||||
|
ref = $bindable(null),
|
||||||
|
href = undefined,
|
||||||
|
type = "button",
|
||||||
|
disabled,
|
||||||
|
children,
|
||||||
|
...restProps
|
||||||
|
}: ButtonProps = $props();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{#if href}
|
||||||
|
<a
|
||||||
|
bind:this={ref}
|
||||||
|
data-slot="button"
|
||||||
|
class={cn(buttonVariants({ variant, size }), className)}
|
||||||
|
href={disabled ? undefined : href}
|
||||||
|
aria-disabled={disabled}
|
||||||
|
role={disabled ? "link" : undefined}
|
||||||
|
tabindex={disabled ? -1 : undefined}
|
||||||
|
{...restProps}
|
||||||
|
>
|
||||||
|
{@render children?.()}
|
||||||
|
</a>
|
||||||
|
{:else}
|
||||||
|
<button
|
||||||
|
bind:this={ref}
|
||||||
|
data-slot="button"
|
||||||
|
class={cn(buttonVariants({ variant, size }), className)}
|
||||||
|
{type}
|
||||||
|
{disabled}
|
||||||
|
{...restProps}
|
||||||
|
>
|
||||||
|
{@render children?.()}
|
||||||
|
</button>
|
||||||
|
{/if}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
import Root, {
|
||||||
|
type ButtonProps,
|
||||||
|
type ButtonSize,
|
||||||
|
type ButtonVariant,
|
||||||
|
buttonVariants,
|
||||||
|
} from "./button.svelte";
|
||||||
|
|
||||||
|
export {
|
||||||
|
Root,
|
||||||
|
type ButtonProps as Props,
|
||||||
|
//
|
||||||
|
Root as Button,
|
||||||
|
buttonVariants,
|
||||||
|
type ButtonProps,
|
||||||
|
type ButtonSize,
|
||||||
|
type ButtonVariant,
|
||||||
|
};
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { cn, type WithElementRef } from "$lib/utils.js";
|
||||||
|
import type { HTMLAttributes } from "svelte/elements";
|
||||||
|
|
||||||
|
let {
|
||||||
|
ref = $bindable(null),
|
||||||
|
class: className,
|
||||||
|
children,
|
||||||
|
...restProps
|
||||||
|
}: WithElementRef<HTMLAttributes<HTMLDivElement>> = $props();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div
|
||||||
|
bind:this={ref}
|
||||||
|
data-slot="card-action"
|
||||||
|
class={cn("col-start-2 row-span-2 row-start-1 self-start justify-self-end", className)}
|
||||||
|
{...restProps}
|
||||||
|
>
|
||||||
|
{@render children?.()}
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import type { HTMLAttributes } from "svelte/elements";
|
||||||
|
import { cn, type WithElementRef } from "$lib/utils.js";
|
||||||
|
|
||||||
|
let {
|
||||||
|
ref = $bindable(null),
|
||||||
|
class: className,
|
||||||
|
children,
|
||||||
|
...restProps
|
||||||
|
}: WithElementRef<HTMLAttributes<HTMLDivElement>> = $props();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div bind:this={ref} data-slot="card-content" class={cn("px-6", className)} {...restProps}>
|
||||||
|
{@render children?.()}
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import type { HTMLAttributes } from "svelte/elements";
|
||||||
|
import { cn, type WithElementRef } from "$lib/utils.js";
|
||||||
|
|
||||||
|
let {
|
||||||
|
ref = $bindable(null),
|
||||||
|
class: className,
|
||||||
|
children,
|
||||||
|
...restProps
|
||||||
|
}: WithElementRef<HTMLAttributes<HTMLParagraphElement>> = $props();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<p
|
||||||
|
bind:this={ref}
|
||||||
|
data-slot="card-description"
|
||||||
|
class={cn("text-muted-foreground text-sm", className)}
|
||||||
|
{...restProps}
|
||||||
|
>
|
||||||
|
{@render children?.()}
|
||||||
|
</p>
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { cn, type WithElementRef } from "$lib/utils.js";
|
||||||
|
import type { HTMLAttributes } from "svelte/elements";
|
||||||
|
|
||||||
|
let {
|
||||||
|
ref = $bindable(null),
|
||||||
|
class: className,
|
||||||
|
children,
|
||||||
|
...restProps
|
||||||
|
}: WithElementRef<HTMLAttributes<HTMLDivElement>> = $props();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div
|
||||||
|
bind:this={ref}
|
||||||
|
data-slot="card-footer"
|
||||||
|
class={cn("[.border-t]:pt-6 flex items-center px-6", className)}
|
||||||
|
{...restProps}
|
||||||
|
>
|
||||||
|
{@render children?.()}
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { cn, type WithElementRef } from "$lib/utils.js";
|
||||||
|
import type { HTMLAttributes } from "svelte/elements";
|
||||||
|
|
||||||
|
let {
|
||||||
|
ref = $bindable(null),
|
||||||
|
class: className,
|
||||||
|
children,
|
||||||
|
...restProps
|
||||||
|
}: WithElementRef<HTMLAttributes<HTMLDivElement>> = $props();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div
|
||||||
|
bind:this={ref}
|
||||||
|
data-slot="card-header"
|
||||||
|
class={cn(
|
||||||
|
"@container/card-header has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6 grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 px-6",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...restProps}
|
||||||
|
>
|
||||||
|
{@render children?.()}
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import type { HTMLAttributes } from "svelte/elements";
|
||||||
|
import { cn, type WithElementRef } from "$lib/utils.js";
|
||||||
|
|
||||||
|
let {
|
||||||
|
ref = $bindable(null),
|
||||||
|
class: className,
|
||||||
|
children,
|
||||||
|
...restProps
|
||||||
|
}: WithElementRef<HTMLAttributes<HTMLDivElement>> = $props();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div
|
||||||
|
bind:this={ref}
|
||||||
|
data-slot="card-title"
|
||||||
|
class={cn("font-semibold leading-none", className)}
|
||||||
|
{...restProps}
|
||||||
|
>
|
||||||
|
{@render children?.()}
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import type { HTMLAttributes } from "svelte/elements";
|
||||||
|
import { cn, type WithElementRef } from "$lib/utils.js";
|
||||||
|
|
||||||
|
let {
|
||||||
|
ref = $bindable(null),
|
||||||
|
class: className,
|
||||||
|
children,
|
||||||
|
...restProps
|
||||||
|
}: WithElementRef<HTMLAttributes<HTMLDivElement>> = $props();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div
|
||||||
|
bind:this={ref}
|
||||||
|
data-slot="card"
|
||||||
|
class={cn(
|
||||||
|
"bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...restProps}
|
||||||
|
>
|
||||||
|
{@render children?.()}
|
||||||
|
</div>
|
||||||
25
fictionarchive-web-astro/src/lib/components/ui/card/index.ts
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
import Root from "./card.svelte";
|
||||||
|
import Content from "./card-content.svelte";
|
||||||
|
import Description from "./card-description.svelte";
|
||||||
|
import Footer from "./card-footer.svelte";
|
||||||
|
import Header from "./card-header.svelte";
|
||||||
|
import Title from "./card-title.svelte";
|
||||||
|
import Action from "./card-action.svelte";
|
||||||
|
|
||||||
|
export {
|
||||||
|
Root,
|
||||||
|
Content,
|
||||||
|
Description,
|
||||||
|
Footer,
|
||||||
|
Header,
|
||||||
|
Title,
|
||||||
|
Action,
|
||||||
|
//
|
||||||
|
Root as Card,
|
||||||
|
Content as CardContent,
|
||||||
|
Description as CardDescription,
|
||||||
|
Footer as CardFooter,
|
||||||
|
Header as CardHeader,
|
||||||
|
Title as CardTitle,
|
||||||
|
Action as CardAction,
|
||||||
|
};
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
import Root from "./input.svelte";
|
||||||
|
|
||||||
|
export {
|
||||||
|
Root,
|
||||||
|
//
|
||||||
|
Root as Input,
|
||||||
|
};
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import type { HTMLInputAttributes, HTMLInputTypeAttribute } from "svelte/elements";
|
||||||
|
import { cn, type WithElementRef } from "$lib/utils.js";
|
||||||
|
|
||||||
|
type InputType = Exclude<HTMLInputTypeAttribute, "file">;
|
||||||
|
|
||||||
|
type Props = WithElementRef<
|
||||||
|
Omit<HTMLInputAttributes, "type"> &
|
||||||
|
({ type: "file"; files?: FileList } | { type?: InputType; files?: undefined })
|
||||||
|
>;
|
||||||
|
|
||||||
|
let {
|
||||||
|
ref = $bindable(null),
|
||||||
|
value = $bindable(),
|
||||||
|
type,
|
||||||
|
files = $bindable(),
|
||||||
|
class: className,
|
||||||
|
"data-slot": dataSlot = "input",
|
||||||
|
...restProps
|
||||||
|
}: Props = $props();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{#if type === "file"}
|
||||||
|
<input
|
||||||
|
bind:this={ref}
|
||||||
|
data-slot={dataSlot}
|
||||||
|
class={cn(
|
||||||
|
"selection:bg-primary dark:bg-input/30 selection:text-primary-foreground border-input ring-offset-background placeholder:text-muted-foreground shadow-xs flex h-9 w-full min-w-0 rounded-md border bg-transparent px-3 pt-1.5 text-sm font-medium outline-none transition-[color,box-shadow] disabled:cursor-not-allowed disabled:opacity-50",
|
||||||
|
"focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]",
|
||||||
|
"aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
type="file"
|
||||||
|
bind:files
|
||||||
|
bind:value
|
||||||
|
{...restProps}
|
||||||
|
/>
|
||||||
|
{:else}
|
||||||
|
<input
|
||||||
|
bind:this={ref}
|
||||||
|
data-slot={dataSlot}
|
||||||
|
class={cn(
|
||||||
|
"border-input bg-background selection:bg-primary dark:bg-input/30 selection:text-primary-foreground ring-offset-background placeholder:text-muted-foreground shadow-xs flex h-9 w-full min-w-0 rounded-md border px-3 py-1 text-base outline-none transition-[color,box-shadow] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
|
||||||
|
"focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]",
|
||||||
|
"aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{type}
|
||||||
|
bind:value
|
||||||
|
{...restProps}
|
||||||
|
/>
|
||||||
|
{/if}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import type { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core';
|
import type { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core';
|
||||||
export type Maybe<T> = T | null;
|
export type Maybe<T> = T | null;
|
||||||
export type InputMaybe<T> = T | null;
|
export type InputMaybe<T> = Maybe<T>;
|
||||||
export type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
|
export type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
|
||||||
export type MakeOptional<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]?: Maybe<T[SubKey]> };
|
export type MakeOptional<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]?: Maybe<T[SubKey]> };
|
||||||
export type MakeMaybe<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]: Maybe<T[SubKey]> };
|
export type MakeMaybe<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]: Maybe<T[SubKey]> };
|
||||||
@@ -18,6 +18,17 @@ export type Scalars = {
|
|||||||
UnsignedInt: { input: any; output: any; }
|
UnsignedInt: { input: any; output: any; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** Defines when a policy shall be executed. */
|
||||||
|
export const ApplyPolicy = {
|
||||||
|
/** After the resolver was executed. */
|
||||||
|
AfterResolver: 'AFTER_RESOLVER',
|
||||||
|
/** Before the resolver was executed. */
|
||||||
|
BeforeResolver: 'BEFORE_RESOLVER',
|
||||||
|
/** The policy is applied in the validation step before the execution. */
|
||||||
|
Validation: 'VALIDATION'
|
||||||
|
} as const;
|
||||||
|
|
||||||
|
export type ApplyPolicy = typeof ApplyPolicy[keyof typeof ApplyPolicy];
|
||||||
export type Chapter = {
|
export type Chapter = {
|
||||||
body: LocalizationKey;
|
body: LocalizationKey;
|
||||||
createdTime: Scalars['Instant']['output'];
|
createdTime: Scalars['Instant']['output'];
|
||||||
21
fictionarchive-web-astro/src/lib/graphql/client.ts
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
import { Client, cacheExchange, fetchExchange } from '@urql/core';
|
||||||
|
import { get } from 'svelte/store';
|
||||||
|
import { user } from '../auth/authStore';
|
||||||
|
|
||||||
|
export function createClient() {
|
||||||
|
return new Client({
|
||||||
|
url: import.meta.env.PUBLIC_GRAPHQL_URI,
|
||||||
|
exchanges: [cacheExchange, fetchExchange],
|
||||||
|
fetchOptions: () => {
|
||||||
|
const currentUser = get(user);
|
||||||
|
return {
|
||||||
|
headers: currentUser?.access_token
|
||||||
|
? { Authorization: `Bearer ${currentUser.access_token}` }
|
||||||
|
: {},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Singleton for use in components
|
||||||
|
export const client = createClient();
|
||||||
49
fictionarchive-web-astro/src/lib/graphql/urqlStore.ts
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
import { writable } from 'svelte/store';
|
||||||
|
import type { OperationResult, TypedDocumentNode } from '@urql/core';
|
||||||
|
import { client } from './client';
|
||||||
|
|
||||||
|
export function queryStore<Data, Variables extends object>(
|
||||||
|
query: TypedDocumentNode<Data, Variables>,
|
||||||
|
variables: Variables
|
||||||
|
) {
|
||||||
|
const result = writable<OperationResult<Data> | null>(null);
|
||||||
|
const fetching = writable(true);
|
||||||
|
|
||||||
|
async function execute(vars: Variables = variables) {
|
||||||
|
fetching.set(true);
|
||||||
|
const res = await client.query(query, vars).toPromise();
|
||||||
|
result.set(res);
|
||||||
|
fetching.set(false);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initial fetch
|
||||||
|
execute();
|
||||||
|
|
||||||
|
return {
|
||||||
|
subscribe: result.subscribe,
|
||||||
|
fetching: { subscribe: fetching.subscribe },
|
||||||
|
refetch: execute,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function mutationStore<Data, Variables extends object>(
|
||||||
|
mutation: TypedDocumentNode<Data, Variables>
|
||||||
|
) {
|
||||||
|
const result = writable<OperationResult<Data> | null>(null);
|
||||||
|
const fetching = writable(false);
|
||||||
|
|
||||||
|
async function execute(variables: Variables) {
|
||||||
|
fetching.set(true);
|
||||||
|
const res = await client.mutation(mutation, variables).toPromise();
|
||||||
|
result.set(res);
|
||||||
|
fetching.set(false);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
subscribe: result.subscribe,
|
||||||
|
fetching: { subscribe: fetching.subscribe },
|
||||||
|
execute,
|
||||||
|
};
|
||||||
|
}
|
||||||
13
fictionarchive-web-astro/src/lib/utils.ts
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
import { clsx, type ClassValue } from "clsx";
|
||||||
|
import { twMerge } from "tailwind-merge";
|
||||||
|
|
||||||
|
export function cn(...inputs: ClassValue[]) {
|
||||||
|
return twMerge(clsx(inputs));
|
||||||
|
}
|
||||||
|
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
export type WithoutChild<T> = T extends { child?: any } ? Omit<T, "child"> : T;
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
export type WithoutChildren<T> = T extends { children?: any } ? Omit<T, "children"> : T;
|
||||||
|
export type WithoutChildrenOrChild<T> = WithoutChildren<WithoutChild<T>>;
|
||||||
|
export type WithElementRef<T, U extends HTMLElement = HTMLElement> = T & { ref?: U | null };
|
||||||
23
fictionarchive-web-astro/src/pages/404.astro
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
---
|
||||||
|
export const prerender = true; // Static page
|
||||||
|
|
||||||
|
import AppLayout from '../layouts/AppLayout.astro';
|
||||||
|
import { Card, CardContent, CardHeader, CardTitle } from '../lib/components/ui/card';
|
||||||
|
import { Button } from '../lib/components/ui/button';
|
||||||
|
---
|
||||||
|
|
||||||
|
<AppLayout title="Not Found - FictionArchive">
|
||||||
|
<div class="flex min-h-[50vh] items-center justify-center">
|
||||||
|
<Card class="mx-auto max-w-md text-center shadow-md shadow-primary/10">
|
||||||
|
<CardHeader>
|
||||||
|
<CardTitle class="text-4xl font-bold">404</CardTitle>
|
||||||
|
</CardHeader>
|
||||||
|
<CardContent class="space-y-4">
|
||||||
|
<p class="text-muted-foreground">
|
||||||
|
The page you're looking for doesn't exist or has been moved.
|
||||||
|
</p>
|
||||||
|
<Button href="/" variant="default">Go back home</Button>
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
</AppLayout>
|
||||||
10
fictionarchive-web-astro/src/pages/index.astro
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
---
|
||||||
|
export const prerender = true; // Static page
|
||||||
|
|
||||||
|
import AppLayout from '../layouts/AppLayout.astro';
|
||||||
|
import NovelsPage from '../lib/components/NovelsPage.svelte';
|
||||||
|
---
|
||||||
|
|
||||||
|
<AppLayout title="Novels - FictionArchive">
|
||||||
|
<NovelsPage client:load />
|
||||||
|
</AppLayout>
|
||||||
11
fictionarchive-web-astro/src/pages/novels/[id].astro
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
---
|
||||||
|
// SSR page (default in server mode, no prerender export needed)
|
||||||
|
import AppLayout from '../../layouts/AppLayout.astro';
|
||||||
|
import NovelDetailPage from '../../lib/components/NovelDetailPage.svelte';
|
||||||
|
|
||||||
|
const { id } = Astro.params;
|
||||||
|
---
|
||||||
|
|
||||||
|
<AppLayout title="Novel Detail - FictionArchive">
|
||||||
|
<NovelDetailPage novelId={id} client:load />
|
||||||
|
</AppLayout>
|
||||||
141
fictionarchive-web-astro/src/styles/global.css
Normal file
@@ -0,0 +1,141 @@
|
|||||||
|
@import "tailwindcss";
|
||||||
|
|
||||||
|
@import "tw-animate-css";
|
||||||
|
|
||||||
|
@custom-variant dark (&:is(.dark *));
|
||||||
|
|
||||||
|
:root {
|
||||||
|
--radius: 0.75rem;
|
||||||
|
/* Purple/Indigo theme matching original React app */
|
||||||
|
--background: oklch(0.98 0.01 250);
|
||||||
|
--foreground: oklch(0.2 0.04 260);
|
||||||
|
--card: oklch(1 0 0);
|
||||||
|
--card-foreground: oklch(0.2 0.04 260);
|
||||||
|
--popover: oklch(1 0 0);
|
||||||
|
--popover-foreground: oklch(0.2 0.04 260);
|
||||||
|
--primary: oklch(0.55 0.25 270);
|
||||||
|
--primary-foreground: oklch(1 0 0);
|
||||||
|
--secondary: oklch(0.95 0.02 270);
|
||||||
|
--secondary-foreground: oklch(0.2 0.04 260);
|
||||||
|
--muted: oklch(0.93 0.02 250);
|
||||||
|
--muted-foreground: oklch(0.5 0.03 250);
|
||||||
|
--accent: oklch(0.96 0.03 250);
|
||||||
|
--accent-foreground: oklch(0.2 0.04 260);
|
||||||
|
--destructive: oklch(0.6 0.24 25);
|
||||||
|
--destructive-foreground: oklch(1 0 0);
|
||||||
|
--border: oklch(0.92 0.02 250);
|
||||||
|
--input: oklch(0.92 0.02 250);
|
||||||
|
--ring: oklch(0.55 0.25 270);
|
||||||
|
--chart-1: oklch(0.646 0.222 41.116);
|
||||||
|
--chart-2: oklch(0.6 0.118 184.704);
|
||||||
|
--chart-3: oklch(0.398 0.07 227.392);
|
||||||
|
--chart-4: oklch(0.828 0.189 84.429);
|
||||||
|
--chart-5: oklch(0.769 0.188 70.08);
|
||||||
|
--sidebar: oklch(0.985 0.002 247.839);
|
||||||
|
--sidebar-foreground: oklch(0.2 0.04 260);
|
||||||
|
--sidebar-primary: oklch(0.55 0.25 270);
|
||||||
|
--sidebar-primary-foreground: oklch(1 0 0);
|
||||||
|
--sidebar-accent: oklch(0.95 0.02 270);
|
||||||
|
--sidebar-accent-foreground: oklch(0.2 0.04 260);
|
||||||
|
--sidebar-border: oklch(0.92 0.02 250);
|
||||||
|
--sidebar-ring: oklch(0.55 0.25 270);
|
||||||
|
}
|
||||||
|
|
||||||
|
.dark {
|
||||||
|
--background: oklch(0.2 0.04 260);
|
||||||
|
--foreground: oklch(0.98 0.01 250);
|
||||||
|
--card: oklch(0.2 0.04 260);
|
||||||
|
--card-foreground: oklch(0.98 0.01 250);
|
||||||
|
--popover: oklch(0.2 0.04 260);
|
||||||
|
--popover-foreground: oklch(0.98 0.01 250);
|
||||||
|
--primary: oklch(0.7 0.2 270);
|
||||||
|
--primary-foreground: oklch(0.2 0.04 260);
|
||||||
|
--secondary: oklch(0.25 0.04 260);
|
||||||
|
--secondary-foreground: oklch(0.98 0.01 250);
|
||||||
|
--muted: oklch(0.25 0.04 260);
|
||||||
|
--muted-foreground: oklch(0.65 0.02 250);
|
||||||
|
--accent: oklch(0.25 0.04 260);
|
||||||
|
--accent-foreground: oklch(0.98 0.01 250);
|
||||||
|
--destructive: oklch(0.6 0.24 25);
|
||||||
|
--destructive-foreground: oklch(0.98 0.01 250);
|
||||||
|
--border: oklch(0.3 0.04 260);
|
||||||
|
--input: oklch(0.3 0.04 260);
|
||||||
|
--ring: oklch(0.7 0.2 270);
|
||||||
|
--chart-1: oklch(0.488 0.243 264.376);
|
||||||
|
--chart-2: oklch(0.696 0.17 162.48);
|
||||||
|
--chart-3: oklch(0.769 0.188 70.08);
|
||||||
|
--chart-4: oklch(0.627 0.265 303.9);
|
||||||
|
--chart-5: oklch(0.645 0.246 16.439);
|
||||||
|
--sidebar: oklch(0.2 0.04 260);
|
||||||
|
--sidebar-foreground: oklch(0.98 0.01 250);
|
||||||
|
--sidebar-primary: oklch(0.7 0.2 270);
|
||||||
|
--sidebar-primary-foreground: oklch(0.98 0.01 250);
|
||||||
|
--sidebar-accent: oklch(0.25 0.04 260);
|
||||||
|
--sidebar-accent-foreground: oklch(0.98 0.01 250);
|
||||||
|
--sidebar-border: oklch(0.3 0.04 260);
|
||||||
|
--sidebar-ring: oklch(0.7 0.2 270);
|
||||||
|
}
|
||||||
|
|
||||||
|
@theme inline {
|
||||||
|
--radius-sm: calc(var(--radius) - 4px);
|
||||||
|
--radius-md: calc(var(--radius) - 2px);
|
||||||
|
--radius-lg: var(--radius);
|
||||||
|
--radius-xl: calc(var(--radius) + 4px);
|
||||||
|
--color-background: var(--background);
|
||||||
|
--color-foreground: var(--foreground);
|
||||||
|
--color-card: var(--card);
|
||||||
|
--color-card-foreground: var(--card-foreground);
|
||||||
|
--color-popover: var(--popover);
|
||||||
|
--color-popover-foreground: var(--popover-foreground);
|
||||||
|
--color-primary: var(--primary);
|
||||||
|
--color-primary-foreground: var(--primary-foreground);
|
||||||
|
--color-secondary: var(--secondary);
|
||||||
|
--color-secondary-foreground: var(--secondary-foreground);
|
||||||
|
--color-muted: var(--muted);
|
||||||
|
--color-muted-foreground: var(--muted-foreground);
|
||||||
|
--color-accent: var(--accent);
|
||||||
|
--color-accent-foreground: var(--accent-foreground);
|
||||||
|
--color-destructive: var(--destructive);
|
||||||
|
--color-border: var(--border);
|
||||||
|
--color-input: var(--input);
|
||||||
|
--color-ring: var(--ring);
|
||||||
|
--color-chart-1: var(--chart-1);
|
||||||
|
--color-chart-2: var(--chart-2);
|
||||||
|
--color-chart-3: var(--chart-3);
|
||||||
|
--color-chart-4: var(--chart-4);
|
||||||
|
--color-chart-5: var(--chart-5);
|
||||||
|
--color-sidebar: var(--sidebar);
|
||||||
|
--color-sidebar-foreground: var(--sidebar-foreground);
|
||||||
|
--color-sidebar-primary: var(--sidebar-primary);
|
||||||
|
--color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
|
||||||
|
--color-sidebar-accent: var(--sidebar-accent);
|
||||||
|
--color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
|
||||||
|
--color-sidebar-border: var(--sidebar-border);
|
||||||
|
--color-sidebar-ring: var(--sidebar-ring);
|
||||||
|
}
|
||||||
|
|
||||||
|
@layer base {
|
||||||
|
* {
|
||||||
|
@apply border-border outline-ring/50;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
@apply bg-background text-foreground min-h-screen antialiased;
|
||||||
|
font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
|
||||||
|
/* Subtle gradient background matching original React app */
|
||||||
|
background-image:
|
||||||
|
radial-gradient(circle at 20% 20%, oklch(0.95 0.05 270 / 50%), transparent 32%),
|
||||||
|
radial-gradient(circle at 80% 10%, oklch(0.95 0.05 150 / 40%), transparent 25%),
|
||||||
|
radial-gradient(circle at 50% 80%, oklch(0.95 0.05 25 / 30%), transparent 20%),
|
||||||
|
linear-gradient(180deg, oklch(1 0 0 / 90%), oklch(0.98 0.01 250 / 95%));
|
||||||
|
}
|
||||||
|
|
||||||
|
.dark body {
|
||||||
|
background-image: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Link styling */
|
||||||
|
a:not([class]) {
|
||||||
|
@apply text-primary font-medium hover:underline;
|
||||||
|
}
|
||||||
|
}
|
||||||
5
fictionarchive-web-astro/svelte.config.js
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
import { vitePreprocess } from '@astrojs/svelte';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
preprocess: vitePreprocess(),
|
||||||
|
}
|
||||||
14
fictionarchive-web-astro/tsconfig.json
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"extends": "astro/tsconfigs/strict",
|
||||||
|
"include": [".astro/types.d.ts", "**/*"],
|
||||||
|
"exclude": ["dist"],
|
||||||
|
"compilerOptions": {
|
||||||
|
// ...
|
||||||
|
"baseUrl": ".",
|
||||||
|
"paths": {
|
||||||
|
"$lib": ["./src/lib"],
|
||||||
|
"$lib/*": ["./src/lib/*"]
|
||||||
|
}
|
||||||
|
// ...
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1 +0,0 @@
|
|||||||
VITE_GRAPHQL_URI=http://localhost:5234/graphql/
|
|
||||||
24
fictionarchive-web/.gitignore
vendored
@@ -1,24 +0,0 @@
|
|||||||
# Logs
|
|
||||||
logs
|
|
||||||
*.log
|
|
||||||
npm-debug.log*
|
|
||||||
yarn-debug.log*
|
|
||||||
yarn-error.log*
|
|
||||||
pnpm-debug.log*
|
|
||||||
lerna-debug.log*
|
|
||||||
|
|
||||||
node_modules
|
|
||||||
dist
|
|
||||||
dist-ssr
|
|
||||||
*.local
|
|
||||||
|
|
||||||
# Editor directories and files
|
|
||||||
.vscode/*
|
|
||||||
!.vscode/extensions.json
|
|
||||||
.idea
|
|
||||||
.DS_Store
|
|
||||||
*.suo
|
|
||||||
*.ntvs*
|
|
||||||
*.njsproj
|
|
||||||
*.sln
|
|
||||||
*.sw?
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
FROM node:20-alpine AS build
|
|
||||||
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
# Build arguments for Vite environment variables
|
|
||||||
ARG VITE_GRAPHQL_URI
|
|
||||||
ARG VITE_OIDC_AUTHORITY
|
|
||||||
ARG VITE_OIDC_CLIENT_ID
|
|
||||||
ARG VITE_OIDC_REDIRECT_URI
|
|
||||||
ARG VITE_OIDC_POST_LOGOUT_REDIRECT_URI
|
|
||||||
|
|
||||||
# Set environment variables for build
|
|
||||||
ENV VITE_GRAPHQL_URI=$VITE_GRAPHQL_URI
|
|
||||||
ENV VITE_OIDC_AUTHORITY=$VITE_OIDC_AUTHORITY
|
|
||||||
ENV VITE_OIDC_CLIENT_ID=$VITE_OIDC_CLIENT_ID
|
|
||||||
ENV VITE_OIDC_REDIRECT_URI=$VITE_OIDC_REDIRECT_URI
|
|
||||||
ENV VITE_OIDC_POST_LOGOUT_REDIRECT_URI=$VITE_OIDC_POST_LOGOUT_REDIRECT_URI
|
|
||||||
|
|
||||||
COPY package*.json ./
|
|
||||||
RUN npm ci
|
|
||||||
|
|
||||||
COPY . .
|
|
||||||
RUN npm run build
|
|
||||||
|
|
||||||
FROM nginx:alpine
|
|
||||||
|
|
||||||
COPY --from=build /app/dist /usr/share/nginx/html
|
|
||||||
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
|
||||||
|
|
||||||
EXPOSE 80
|
|
||||||
|
|
||||||
CMD ["nginx", "-g", "daemon off;"]
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
# FictionArchive React Starter
|
|
||||||
|
|
||||||
A minimal React + Vite + Apollo Client scaffold ready to connect to the FictionArchive Fusion gateway. Point it at your own endpoint by changing `VITE_GRAPHQL_URI`.
|
|
||||||
|
|
||||||
## Getting started
|
|
||||||
|
|
||||||
```bash
|
|
||||||
cd fictionarchive-web
|
|
||||||
npm install
|
|
||||||
npm run dev
|
|
||||||
```
|
|
||||||
|
|
||||||
Then open the printed local URL. Update `.env` (create it if missing) with your endpoint:
|
|
||||||
|
|
||||||
```
|
|
||||||
VITE_GRAPHQL_URI=https://localhost:5001/graphql
|
|
||||||
VITE_OIDC_AUTHORITY=https://your-idp
|
|
||||||
VITE_OIDC_CLIENT_ID=fictionarchive-web
|
|
||||||
VITE_OIDC_REDIRECT_URI=http://localhost:5173
|
|
||||||
VITE_OIDC_POST_LOGOUT_REDIRECT_URI=http://localhost:5173
|
|
||||||
# Optional: token used only by codegen if your gateway requires auth
|
|
||||||
VITE_CODEGEN_TOKEN=your_api_token
|
|
||||||
```
|
|
||||||
|
|
||||||
## Scripts
|
|
||||||
|
|
||||||
- `npm run dev`: start Vite dev server.
|
|
||||||
- `npm run build`: type-check + production build.
|
|
||||||
- `npm run codegen`: generate typed hooks from `src/**/*.graphql` into `src/__generated__/graphql.ts`. **Run this manually after changing GraphQL operations or when the gateway schema changes.**
|
|
||||||
|
|
||||||
## Project notes
|
|
||||||
|
|
||||||
- `src/apolloClient.ts` configures the Apollo client with `InMemoryCache`, reads `VITE_GRAPHQL_URI`, and attaches an `Authorization: Bearer` header when an OIDC user is present.
|
|
||||||
- GraphQL code generation is configured via `codegen.ts` (loads `.env`/`.env.local` automatically); run `npm run codegen` to emit typed hooks to `src/__generated__/graphql.ts` (ignored by git) or rely on the `prebuild` hook.
|
|
||||||
- Routing is handled in `src/App.tsx` with `react-router-dom`; `/` renders the novels listing and `/novels/:id` is stubbed for future detail pages.
|
|
||||||
- Styles live primarily in `src/index.css` alongside the shared UI components.
|
|
||||||
|
|
||||||
## Codegen tips
|
|
||||||
|
|
||||||
- Default schema URL: `CODEGEN_SCHEMA_URL` (falls back to `VITE_GRAPHQL_URI`, then `https://localhost:5001/graphql`).
|
|
||||||
- Add `VITE_CODEGEN_TOKEN` (or `CODEGEN_TOKEN`) if your gateway requires a bearer token during introspection.
|
|
||||||
- Generated outputs land in `src/__generated__/graphql.ts` (committed to git). Run `npm run codegen` after schema/operation changes.
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
import type { CodegenConfig } from '@graphql-codegen/cli'
|
|
||||||
|
|
||||||
const schema =
|
|
||||||
process.env.CODEGEN_SCHEMA_URL ??
|
|
||||||
process.env.VITE_GRAPHQL_URI ??
|
|
||||||
'https://localhost:5001/graphql'
|
|
||||||
|
|
||||||
const authToken = process.env.VITE_CODEGEN_TOKEN ?? process.env.CODEGEN_TOKEN
|
|
||||||
const headers = authToken
|
|
||||||
? {
|
|
||||||
Authorization: `Bearer ${authToken}`,
|
|
||||||
}
|
|
||||||
: undefined
|
|
||||||
|
|
||||||
const config: CodegenConfig = {
|
|
||||||
schema: {
|
|
||||||
[schema]: { headers },
|
|
||||||
},
|
|
||||||
documents: 'src/**/*.graphql',
|
|
||||||
generates: {
|
|
||||||
'src/__generated__/graphql.ts': {
|
|
||||||
plugins: [
|
|
||||||
'typescript',
|
|
||||||
'typescript-operations',
|
|
||||||
'typed-document-node',
|
|
||||||
],
|
|
||||||
config: {
|
|
||||||
avoidOptionals: {
|
|
||||||
field: true,
|
|
||||||
inputValue: false,
|
|
||||||
},
|
|
||||||
enumsAsConst: true,
|
|
||||||
maybeValue: 'T | null',
|
|
||||||
skipTypename: true,
|
|
||||||
useTypeImports: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
ignoreNoDocuments: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
export default config
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
import js from '@eslint/js'
|
|
||||||
import globals from 'globals'
|
|
||||||
import reactHooks from 'eslint-plugin-react-hooks'
|
|
||||||
import reactRefresh from 'eslint-plugin-react-refresh'
|
|
||||||
import tseslint from 'typescript-eslint'
|
|
||||||
import { defineConfig, globalIgnores } from 'eslint/config'
|
|
||||||
|
|
||||||
export default defineConfig([
|
|
||||||
globalIgnores(['dist', 'src/__generated__']),
|
|
||||||
{
|
|
||||||
files: ['**/*.{ts,tsx}'],
|
|
||||||
extends: [
|
|
||||||
js.configs.recommended,
|
|
||||||
tseslint.configs.recommended,
|
|
||||||
reactHooks.configs.flat.recommended,
|
|
||||||
reactRefresh.configs.vite,
|
|
||||||
],
|
|
||||||
languageOptions: {
|
|
||||||
ecmaVersion: 2020,
|
|
||||||
globals: globals.browser,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
])
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
<!doctype html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8" />
|
|
||||||
<link rel="icon" type="image/png" href="/favicon-32.png" sizes="32x32" />
|
|
||||||
<link rel="icon" type="image/png" href="/favicon-64.png" sizes="64x64" />
|
|
||||||
<link rel="apple-touch-icon" href="/favicon-180.png" sizes="180x180" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
||||||
<title>FictionArchive</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div id="root"></div>
|
|
||||||
<script type="module" src="/src/main.tsx"></script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
server {
|
|
||||||
listen 80;
|
|
||||||
server_name localhost;
|
|
||||||
root /usr/share/nginx/html;
|
|
||||||
index index.html;
|
|
||||||
|
|
||||||
# Gzip compression
|
|
||||||
gzip on;
|
|
||||||
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
|
|
||||||
|
|
||||||
# Handle SPA routing - serve index.html for all routes
|
|
||||||
location / {
|
|
||||||
try_files $uri $uri/ /index.html;
|
|
||||||
}
|
|
||||||
|
|
||||||
# Cache static assets
|
|
||||||
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
|
|
||||||
expires 1y;
|
|
||||||
add_header Cache-Control "public, immutable";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
7727
fictionarchive-web/package-lock.json
generated
@@ -1,48 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "fictionarchive-web",
|
|
||||||
"private": true,
|
|
||||||
"version": "0.0.0",
|
|
||||||
"type": "module",
|
|
||||||
"scripts": {
|
|
||||||
"dev": "vite",
|
|
||||||
"build": "tsc -b && vite build",
|
|
||||||
"codegen": "graphql-codegen --config codegen.ts -r dotenv/config --use-system-ca",
|
|
||||||
"lint": "eslint .",
|
|
||||||
"preview": "vite preview"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"@apollo/client": "^4.0.9",
|
|
||||||
"@radix-ui/react-slot": "^1.1.2",
|
|
||||||
"class-variance-authority": "^0.7.1",
|
|
||||||
"clsx": "^2.1.1",
|
|
||||||
"graphql": "^16.12.0",
|
|
||||||
"oidc-client-ts": "^3.4.1",
|
|
||||||
"react": "^19.2.0",
|
|
||||||
"react-dom": "^19.2.0",
|
|
||||||
"react-router-dom": "^6.27.0",
|
|
||||||
"tailwind-merge": "^2.5.4"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"@eslint/js": "^9.39.1",
|
|
||||||
"@graphql-codegen/cli": "^5.0.3",
|
|
||||||
"@graphql-codegen/typed-document-node": "^6.1.1",
|
|
||||||
"@graphql-codegen/typescript": "^4.0.9",
|
|
||||||
"@graphql-codegen/typescript-operations": "^4.0.9",
|
|
||||||
"@types/node": "^24.10.1",
|
|
||||||
"@types/react": "^19.2.5",
|
|
||||||
"@types/react-dom": "^19.2.3",
|
|
||||||
"@vitejs/plugin-react": "^5.1.1",
|
|
||||||
"autoprefixer": "^10.4.20",
|
|
||||||
"dotenv": "^16.4.5",
|
|
||||||
"eslint": "^9.39.1",
|
|
||||||
"eslint-plugin-react-hooks": "^7.0.1",
|
|
||||||
"eslint-plugin-react-refresh": "^0.4.24",
|
|
||||||
"globals": "^16.5.0",
|
|
||||||
"postcss": "^8.4.49",
|
|
||||||
"tailwindcss": "^3.4.16",
|
|
||||||
"tailwindcss-animate": "^1.0.7",
|
|
||||||
"typescript": "~5.9.3",
|
|
||||||
"typescript-eslint": "^8.46.4",
|
|
||||||
"vite": "^7.2.4"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
module.exports = {
|
|
||||||
plugins: {
|
|
||||||
tailwindcss: {},
|
|
||||||
autoprefixer: {},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
Before Width: | Height: | Size: 36 KiB |
|
Before Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 5.7 KiB |
|
Before Width: | Height: | Size: 348 KiB |
@@ -1 +0,0 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
|
|
||||||
|
Before Width: | Height: | Size: 1.5 KiB |
@@ -1,158 +0,0 @@
|
|||||||
.page {
|
|
||||||
max-width: 960px;
|
|
||||||
margin: 0 auto;
|
|
||||||
padding: 2.5rem 1.5rem 3rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.card {
|
|
||||||
background: #ffffff;
|
|
||||||
border: 1px solid #e2e8f0;
|
|
||||||
border-radius: 16px;
|
|
||||||
padding: 1.5rem;
|
|
||||||
box-shadow: 0 18px 60px -30px rgba(15, 23, 42, 0.3);
|
|
||||||
}
|
|
||||||
|
|
||||||
.card + .card {
|
|
||||||
margin-top: 1.25rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.intro {
|
|
||||||
text-align: left;
|
|
||||||
}
|
|
||||||
|
|
||||||
.eyebrow {
|
|
||||||
text-transform: uppercase;
|
|
||||||
letter-spacing: 0.08em;
|
|
||||||
font-size: 0.75rem;
|
|
||||||
color: #475569;
|
|
||||||
margin: 0 0 0.35rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.lede {
|
|
||||||
color: #475569;
|
|
||||||
margin: 0.5rem 0 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.header {
|
|
||||||
display: flex;
|
|
||||||
align-items: flex-start;
|
|
||||||
justify-content: space-between;
|
|
||||||
gap: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.pill {
|
|
||||||
display: inline-flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 0.4rem;
|
|
||||||
padding: 0.3rem 0.7rem;
|
|
||||||
border-radius: 999px;
|
|
||||||
background: #eef2ff;
|
|
||||||
color: #312e81;
|
|
||||||
border: 1px solid #c7d2fe;
|
|
||||||
font-weight: 600;
|
|
||||||
}
|
|
||||||
|
|
||||||
.muted {
|
|
||||||
color: #475569;
|
|
||||||
margin: 0.35rem 0 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.query-form {
|
|
||||||
margin: 1rem 0;
|
|
||||||
display: grid;
|
|
||||||
gap: 0.35rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.label {
|
|
||||||
font-weight: 600;
|
|
||||||
color: #0f172a;
|
|
||||||
}
|
|
||||||
|
|
||||||
.field-row {
|
|
||||||
display: flex;
|
|
||||||
gap: 0.5rem;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.field-row input {
|
|
||||||
flex: 1;
|
|
||||||
padding: 0.65rem 0.75rem;
|
|
||||||
border: 1px solid #cbd5e1;
|
|
||||||
border-radius: 12px;
|
|
||||||
font-size: 1rem;
|
|
||||||
color: #0f172a;
|
|
||||||
background: #f8fafc;
|
|
||||||
}
|
|
||||||
|
|
||||||
.field-row input:focus {
|
|
||||||
outline: none;
|
|
||||||
border-color: #6366f1;
|
|
||||||
box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
|
|
||||||
}
|
|
||||||
|
|
||||||
.field-row button {
|
|
||||||
padding: 0.65rem 0.9rem;
|
|
||||||
border: 1px solid #312e81;
|
|
||||||
background: linear-gradient(135deg, #4338ca, #312e81);
|
|
||||||
color: #fff;
|
|
||||||
border-radius: 12px;
|
|
||||||
font-weight: 700;
|
|
||||||
cursor: pointer;
|
|
||||||
transition: transform 150ms ease, box-shadow 150ms ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.field-row button:hover {
|
|
||||||
transform: translateY(-1px);
|
|
||||||
box-shadow: 0 8px 24px -10px rgba(49, 46, 129, 0.6);
|
|
||||||
}
|
|
||||||
|
|
||||||
.field-row button:active {
|
|
||||||
transform: translateY(0);
|
|
||||||
box-shadow: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.country {
|
|
||||||
margin-top: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.country__headline {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 0.8rem;
|
|
||||||
margin-bottom: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.country h3 {
|
|
||||||
margin: 0.2rem 0 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.emoji {
|
|
||||||
font-size: 2rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.grid {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
|
|
||||||
gap: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
dt {
|
|
||||||
font-size: 0.9rem;
|
|
||||||
color: #475569;
|
|
||||||
margin-bottom: 0.2rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
dd {
|
|
||||||
margin: 0;
|
|
||||||
font-weight: 600;
|
|
||||||
color: #0f172a;
|
|
||||||
}
|
|
||||||
|
|
||||||
.error {
|
|
||||||
color: #b91c1c;
|
|
||||||
background: #fef2f2;
|
|
||||||
border: 1px solid #fecdd3;
|
|
||||||
border-radius: 12px;
|
|
||||||
padding: 0.75rem 1rem;
|
|
||||||
margin: 0.75rem 0 0;
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
import { Route, Routes } from 'react-router-dom'
|
|
||||||
import { AppLayout } from './layouts/AppLayout'
|
|
||||||
import { NovelsPage } from './pages/NovelsPage'
|
|
||||||
import { NovelDetailPage } from './pages/NovelDetailPage'
|
|
||||||
import { NotFoundPage } from './pages/NotFoundPage'
|
|
||||||
|
|
||||||
function App() {
|
|
||||||
return (
|
|
||||||
<Routes>
|
|
||||||
<Route path="/" element={<AppLayout />}>
|
|
||||||
<Route index element={<NovelsPage />} />
|
|
||||||
<Route path="novels/:id" element={<NovelDetailPage />} />
|
|
||||||
<Route path="*" element={<NotFoundPage />} />
|
|
||||||
</Route>
|
|
||||||
</Routes>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default App
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
import { ApolloClient, HttpLink, InMemoryCache } from '@apollo/client'
|
|
||||||
import {SetContextLink} from '@apollo/client/link/context'
|
|
||||||
import { userManager } from './auth/oidcClient'
|
|
||||||
|
|
||||||
const uri = import.meta.env.VITE_GRAPHQL_URI ?? 'https://localhost:5001/graphql'
|
|
||||||
|
|
||||||
const httpLink = new HttpLink({ uri })
|
|
||||||
|
|
||||||
const authLink = new SetContextLink(async ({ headers }) => {
|
|
||||||
if (!userManager) return { headers }
|
|
||||||
try {
|
|
||||||
const user = await userManager.getUser()
|
|
||||||
const token = user?.access_token
|
|
||||||
if (!token) return { headers }
|
|
||||||
return {
|
|
||||||
headers: {
|
|
||||||
...headers,
|
|
||||||
Authorization: `Bearer ${token}`,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.warn('Failed to load user for auth header', error)
|
|
||||||
return { headers }
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
export const apolloClient = new ApolloClient({
|
|
||||||
link: authLink.concat(httpLink),
|
|
||||||
cache: new InMemoryCache(),
|
|
||||||
})
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="35.93" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 228"><path fill="#00D8FF" d="M210.483 73.824a171.49 171.49 0 0 0-8.24-2.597c.465-1.9.893-3.777 1.273-5.621c6.238-30.281 2.16-54.676-11.769-62.708c-13.355-7.7-35.196.329-57.254 19.526a171.23 171.23 0 0 0-6.375 5.848a155.866 155.866 0 0 0-4.241-3.917C100.759 3.829 77.587-4.822 63.673 3.233C50.33 10.957 46.379 33.89 51.995 62.588a170.974 170.974 0 0 0 1.892 8.48c-3.28.932-6.445 1.924-9.474 2.98C17.309 83.498 0 98.307 0 113.668c0 15.865 18.582 31.778 46.812 41.427a145.52 145.52 0 0 0 6.921 2.165a167.467 167.467 0 0 0-2.01 9.138c-5.354 28.2-1.173 50.591 12.134 58.266c13.744 7.926 36.812-.22 59.273-19.855a145.567 145.567 0 0 0 5.342-4.923a168.064 168.064 0 0 0 6.92 6.314c21.758 18.722 43.246 26.282 56.54 18.586c13.731-7.949 18.194-32.003 12.4-61.268a145.016 145.016 0 0 0-1.535-6.842c1.62-.48 3.21-.974 4.76-1.488c29.348-9.723 48.443-25.443 48.443-41.52c0-15.417-17.868-30.326-45.517-39.844Zm-6.365 70.984c-1.4.463-2.836.91-4.3 1.345c-3.24-10.257-7.612-21.163-12.963-32.432c5.106-11 9.31-21.767 12.459-31.957c2.619.758 5.16 1.557 7.61 2.4c23.69 8.156 38.14 20.213 38.14 29.504c0 9.896-15.606 22.743-40.946 31.14Zm-10.514 20.834c2.562 12.94 2.927 24.64 1.23 33.787c-1.524 8.219-4.59 13.698-8.382 15.893c-8.067 4.67-25.32-1.4-43.927-17.412a156.726 156.726 0 0 1-6.437-5.87c7.214-7.889 14.423-17.06 21.459-27.246c12.376-1.098 24.068-2.894 34.671-5.345a134.17 134.17 0 0 1 1.386 6.193ZM87.276 214.515c-7.882 2.783-14.16 2.863-17.955.675c-8.075-4.657-11.432-22.636-6.853-46.752a156.923 156.923 0 0 1 1.869-8.499c10.486 2.32 22.093 3.988 34.498 4.994c7.084 9.967 14.501 19.128 21.976 27.15a134.668 134.668 0 0 1-4.877 4.492c-9.933 8.682-19.886 14.842-28.658 17.94ZM50.35 144.747c-12.483-4.267-22.792-9.812-29.858-15.863c-6.35-5.437-9.555-10.836-9.555-15.216c0-9.322 13.897-21.212 37.076-29.293c2.813-.98 5.757-1.905 8.812-2.773c3.204 10.42 7.406 21.315 12.477 32.332c-5.137 11.18-9.399 22.249-12.634 32.792a134.718 134.718 0 0 1-6.318-1.979Zm12.378-84.26c-4.811-24.587-1.616-43.134 6.425-47.789c8.564-4.958 27.502 2.111 47.463 19.835a144.318 144.318 0 0 1 3.841 3.545c-7.438 7.987-14.787 17.08-21.808 26.988c-12.04 1.116-23.565 2.908-34.161 5.309a160.342 160.342 0 0 1-1.76-7.887Zm110.427 27.268a347.8 347.8 0 0 0-7.785-12.803c8.168 1.033 15.994 2.404 23.343 4.08c-2.206 7.072-4.956 14.465-8.193 22.045a381.151 381.151 0 0 0-7.365-13.322Zm-45.032-43.861c5.044 5.465 10.096 11.566 15.065 18.186a322.04 322.04 0 0 0-30.257-.006c4.974-6.559 10.069-12.652 15.192-18.18ZM82.802 87.83a323.167 323.167 0 0 0-7.227 13.238c-3.184-7.553-5.909-14.98-8.134-22.152c7.304-1.634 15.093-2.97 23.209-3.984a321.524 321.524 0 0 0-7.848 12.897Zm8.081 65.352c-8.385-.936-16.291-2.203-23.593-3.793c2.26-7.3 5.045-14.885 8.298-22.6a321.187 321.187 0 0 0 7.257 13.246c2.594 4.48 5.28 8.868 8.038 13.147Zm37.542 31.03c-5.184-5.592-10.354-11.779-15.403-18.433c4.902.192 9.899.29 14.978.29c5.218 0 10.376-.117 15.453-.343c-4.985 6.774-10.018 12.97-15.028 18.486Zm52.198-57.817c3.422 7.8 6.306 15.345 8.596 22.52c-7.422 1.694-15.436 3.058-23.88 4.071a382.417 382.417 0 0 0 7.859-13.026a347.403 347.403 0 0 0 7.425-13.565Zm-16.898 8.101a358.557 358.557 0 0 1-12.281 19.815a329.4 329.4 0 0 1-23.444.823c-7.967 0-15.716-.248-23.178-.732a310.202 310.202 0 0 1-12.513-19.846h.001a307.41 307.41 0 0 1-10.923-20.627a310.278 310.278 0 0 1 10.89-20.637l-.001.001a307.318 307.318 0 0 1 12.413-19.761c7.613-.576 15.42-.876 23.31-.876H128c7.926 0 15.743.303 23.354.883a329.357 329.357 0 0 1 12.335 19.695a358.489 358.489 0 0 1 11.036 20.54a329.472 329.472 0 0 1-11 20.722Zm22.56-122.124c8.572 4.944 11.906 24.881 6.52 51.026c-.344 1.668-.73 3.367-1.15 5.09c-10.622-2.452-22.155-4.275-34.23-5.408c-7.034-10.017-14.323-19.124-21.64-27.008a160.789 160.789 0 0 1 5.888-5.4c18.9-16.447 36.564-22.941 44.612-18.3ZM128 90.808c12.625 0 22.86 10.235 22.86 22.86s-10.235 22.86-22.86 22.86s-22.86-10.235-22.86-22.86s10.235-22.86 22.86-22.86Z"></path></svg>
|
|
||||||
|
Before Width: | Height: | Size: 4.0 KiB |
@@ -1,168 +0,0 @@
|
|||||||
import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState, type ReactNode } from 'react'
|
|
||||||
import type { User } from 'oidc-client-ts'
|
|
||||||
import { isOidcConfigured, userManager } from './oidcClient'
|
|
||||||
|
|
||||||
// Cookie management helper functions
|
|
||||||
function setCookieFromUser(user: User) {
|
|
||||||
if (!user?.access_token) return
|
|
||||||
|
|
||||||
const isProduction = window.location.hostname !== 'localhost'
|
|
||||||
const domain = isProduction ? '.orfl.xyz' : undefined
|
|
||||||
const secure = isProduction
|
|
||||||
const sameSite = isProduction ? 'None' : 'Lax'
|
|
||||||
|
|
||||||
// Set cookie with JWT token from user
|
|
||||||
const cookieValue = `fa_session=${user.access_token}; path=/; ${secure ? 'secure; ' : ''}samesite=${sameSite}${domain ? `; domain=${domain}` : ''}`
|
|
||||||
document.cookie = cookieValue
|
|
||||||
}
|
|
||||||
|
|
||||||
function clearFaSessionCookie() {
|
|
||||||
const isProduction = window.location.hostname !== 'localhost'
|
|
||||||
const domain = isProduction ? '.orfl.xyz' : undefined
|
|
||||||
|
|
||||||
// Clear cookie by setting expiration date in the past
|
|
||||||
const cookieValue = `fa_session=; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT${domain ? `; domain=${domain}` : ''}`
|
|
||||||
document.cookie = cookieValue
|
|
||||||
}
|
|
||||||
|
|
||||||
type AuthContextValue = {
|
|
||||||
user: User | null
|
|
||||||
isLoading: boolean
|
|
||||||
isConfigured: boolean
|
|
||||||
login: () => Promise<void>
|
|
||||||
logout: () => Promise<void>
|
|
||||||
}
|
|
||||||
|
|
||||||
const AuthContext = createContext<AuthContextValue | undefined>(undefined)
|
|
||||||
|
|
||||||
export function AuthProvider({ children }: { children: ReactNode }) {
|
|
||||||
const [user, setUser] = useState<User | null>(null)
|
|
||||||
const [isLoading, setIsLoading] = useState(!!userManager)
|
|
||||||
const callbackHandledRef = useRef(false)
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (!userManager) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
let cancelled = false
|
|
||||||
userManager
|
|
||||||
.getUser()
|
|
||||||
.then((loadedUser) => {
|
|
||||||
if (!cancelled) {
|
|
||||||
setUser(loadedUser ?? null)
|
|
||||||
if (loadedUser) {
|
|
||||||
setCookieFromUser(loadedUser)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.finally(() => {
|
|
||||||
if (!cancelled) setIsLoading(false)
|
|
||||||
})
|
|
||||||
|
|
||||||
return () => {
|
|
||||||
cancelled = true
|
|
||||||
}
|
|
||||||
}, [])
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const manager = userManager
|
|
||||||
if (!manager) return
|
|
||||||
|
|
||||||
const handleLoaded = (nextUser: User) => {
|
|
||||||
setUser(nextUser)
|
|
||||||
setCookieFromUser(nextUser)
|
|
||||||
}
|
|
||||||
const handleUnloaded = () => {
|
|
||||||
setUser(null)
|
|
||||||
clearFaSessionCookie()
|
|
||||||
}
|
|
||||||
|
|
||||||
manager.events.addUserLoaded(handleLoaded)
|
|
||||||
manager.events.addUserUnloaded(handleUnloaded)
|
|
||||||
manager.events.addUserSignedOut(handleUnloaded)
|
|
||||||
|
|
||||||
return () => {
|
|
||||||
manager.events.removeUserLoaded(handleLoaded)
|
|
||||||
manager.events.removeUserUnloaded(handleUnloaded)
|
|
||||||
manager.events.removeUserSignedOut(handleUnloaded)
|
|
||||||
}
|
|
||||||
}, [])
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const manager = userManager
|
|
||||||
if (!manager || callbackHandledRef.current) return
|
|
||||||
|
|
||||||
const url = new URL(window.location.href)
|
|
||||||
const hasAuthParams =
|
|
||||||
url.searchParams.has('code') ||
|
|
||||||
url.searchParams.has('id_token') ||
|
|
||||||
url.searchParams.has('error')
|
|
||||||
|
|
||||||
if (!hasAuthParams) return
|
|
||||||
|
|
||||||
callbackHandledRef.current = true
|
|
||||||
manager
|
|
||||||
.signinRedirectCallback()
|
|
||||||
.then((nextUser) => {
|
|
||||||
setUser(nextUser ?? null)
|
|
||||||
if (nextUser) {
|
|
||||||
setCookieFromUser(nextUser)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
console.error('Failed to complete sign-in redirect', error)
|
|
||||||
})
|
|
||||||
.finally(() => {
|
|
||||||
const cleanUrl = `${url.origin}${url.pathname}`
|
|
||||||
window.history.replaceState({}, document.title, cleanUrl)
|
|
||||||
})
|
|
||||||
}, [])
|
|
||||||
|
|
||||||
const login = useCallback(async () => {
|
|
||||||
const manager = userManager
|
|
||||||
if (!manager) {
|
|
||||||
console.warn('OIDC is not configured; set VITE_OIDC_* environment variables.')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
await manager.signinRedirect()
|
|
||||||
}, [])
|
|
||||||
|
|
||||||
const logout = useCallback(async () => {
|
|
||||||
const manager = userManager
|
|
||||||
if (!manager) {
|
|
||||||
console.warn('OIDC is not configured; set VITE_OIDC_* environment variables.')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
await manager.signoutRedirect()
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Failed to sign out via redirect, clearing local session instead.', error)
|
|
||||||
await manager.removeUser()
|
|
||||||
setUser(null)
|
|
||||||
clearFaSessionCookie()
|
|
||||||
}
|
|
||||||
}, [])
|
|
||||||
|
|
||||||
const value = useMemo<AuthContextValue>(
|
|
||||||
() => ({
|
|
||||||
user,
|
|
||||||
isLoading,
|
|
||||||
isConfigured: isOidcConfigured,
|
|
||||||
login,
|
|
||||||
logout,
|
|
||||||
}),
|
|
||||||
[isLoading, login, logout, user],
|
|
||||||
)
|
|
||||||
|
|
||||||
return <AuthContext.Provider value={value}>{children}</AuthContext.Provider>
|
|
||||||
}
|
|
||||||
|
|
||||||
// eslint-disable-next-line react-refresh/only-export-components
|
|
||||||
export function useAuth() {
|
|
||||||
const context = useContext(AuthContext)
|
|
||||||
if (!context) {
|
|
||||||
throw new Error('useAuth must be used within an AuthProvider')
|
|
||||||
}
|
|
||||||
return context
|
|
||||||
}
|
|
||||||
@@ -1,103 +0,0 @@
|
|||||||
import { useEffect, useMemo, useRef, useState } from 'react'
|
|
||||||
import { useAuth } from '../auth/AuthContext'
|
|
||||||
import { Button } from './ui/button'
|
|
||||||
|
|
||||||
export function AuthenticationDisplay() {
|
|
||||||
const { user, isConfigured, isLoading, login, logout } = useAuth()
|
|
||||||
const [isOpen, setIsOpen] = useState(false)
|
|
||||||
const menuRef = useRef<HTMLDivElement>(null)
|
|
||||||
|
|
||||||
const email = useMemo(
|
|
||||||
() =>
|
|
||||||
user?.profile?.email ??
|
|
||||||
user?.profile?.preferred_username ??
|
|
||||||
user?.profile?.name ??
|
|
||||||
user?.profile?.sub ??
|
|
||||||
null,
|
|
||||||
[user],
|
|
||||||
)
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (!isOpen) return
|
|
||||||
|
|
||||||
const handleClickOutside = (event: MouseEvent) => {
|
|
||||||
if (!menuRef.current) return
|
|
||||||
if (!menuRef.current.contains(event.target as Node)) {
|
|
||||||
setIsOpen(false)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleEscape = (event: KeyboardEvent) => {
|
|
||||||
if (event.key === 'Escape') setIsOpen(false)
|
|
||||||
}
|
|
||||||
|
|
||||||
document.addEventListener('mousedown', handleClickOutside)
|
|
||||||
document.addEventListener('keydown', handleEscape)
|
|
||||||
|
|
||||||
return () => {
|
|
||||||
document.removeEventListener('mousedown', handleClickOutside)
|
|
||||||
document.removeEventListener('keydown', handleEscape)
|
|
||||||
}
|
|
||||||
}, [isOpen])
|
|
||||||
|
|
||||||
if (isLoading) {
|
|
||||||
return (
|
|
||||||
<Button variant="outline" size="sm" disabled>
|
|
||||||
Loading...
|
|
||||||
</Button>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isConfigured) {
|
|
||||||
return (
|
|
||||||
<Button
|
|
||||||
variant="secondary"
|
|
||||||
size="sm"
|
|
||||||
onClick={() =>
|
|
||||||
alert('OIDC is not configured. Set VITE_OIDC_* environment variables to enable login.')
|
|
||||||
}
|
|
||||||
>
|
|
||||||
Configure OIDC
|
|
||||||
</Button>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!user) {
|
|
||||||
return (
|
|
||||||
<Button variant="secondary" size="sm" onClick={login}>
|
|
||||||
Login
|
|
||||||
</Button>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="relative" ref={menuRef}>
|
|
||||||
<Button
|
|
||||||
variant="ghost"
|
|
||||||
size="sm"
|
|
||||||
className="flex items-center gap-2 text-foreground"
|
|
||||||
onClick={() => setIsOpen((open) => !open)}
|
|
||||||
aria-expanded={isOpen}
|
|
||||||
aria-haspopup="menu"
|
|
||||||
>
|
|
||||||
<span className="inline-flex h-7 w-7 items-center justify-center rounded-full bg-primary/10 text-sm font-semibold text-primary">
|
|
||||||
{(email ?? 'User').slice(0, 1).toUpperCase()}
|
|
||||||
</span>
|
|
||||||
<span className="max-w-[12ch] truncate">{email ?? 'User'}</span>
|
|
||||||
</Button>
|
|
||||||
{isOpen && (
|
|
||||||
<div className="absolute right-0 top-full mt-2 w-56 rounded-lg border bg-white p-2 shadow-lg">
|
|
||||||
<div className="px-3 py-2">
|
|
||||||
<p className="text-xs font-semibold uppercase tracking-wide text-muted-foreground">
|
|
||||||
Signed in
|
|
||||||
</p>
|
|
||||||
<p className="truncate text-sm font-medium text-foreground">{email ?? 'User'}</p>
|
|
||||||
</div>
|
|
||||||
<Button variant="ghost" size="sm" className="w-full justify-start" onClick={logout}>
|
|
||||||
Log out
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
@@ -1,50 +0,0 @@
|
|||||||
import { Link, NavLink } from 'react-router-dom'
|
|
||||||
import { AuthenticationDisplay } from './AuthenticationDisplay'
|
|
||||||
import { Button } from './ui/button'
|
|
||||||
import { Input } from './ui/input'
|
|
||||||
|
|
||||||
export function Navbar() {
|
|
||||||
return (
|
|
||||||
<nav className="sticky top-0 z-10 border-b bg-white/80 backdrop-blur">
|
|
||||||
<div className="mx-auto flex max-w-6xl items-center gap-6 px-4 py-3 sm:px-6 lg:px-8">
|
|
||||||
<div className="flex items-center gap-3">
|
|
||||||
<Link to="/" className="flex items-center gap-3">
|
|
||||||
<div
|
|
||||||
className="flex h-10 w-10 select-none items-center justify-center rounded-xl bg-primary text-primary-foreground font-bold shadow-md shadow-primary/20"
|
|
||||||
translate="no"
|
|
||||||
aria-label="FictionArchive"
|
|
||||||
>
|
|
||||||
FA
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<p className="text-sm font-semibold text-foreground">FictionArchive</p>
|
|
||||||
<p className="text-xs text-muted-foreground">GraphQL playground</p>
|
|
||||||
</div>
|
|
||||||
</Link>
|
|
||||||
</div>
|
|
||||||
<div className="flex items-center gap-2 text-sm font-medium text-muted-foreground">
|
|
||||||
<Button variant="ghost" size="sm" asChild>
|
|
||||||
<NavLink
|
|
||||||
to="/"
|
|
||||||
className={({ isActive }) =>
|
|
||||||
isActive ? 'text-foreground' : 'text-muted-foreground'
|
|
||||||
}
|
|
||||||
>
|
|
||||||
Novels
|
|
||||||
</NavLink>
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
<div className="ml-auto flex items-center gap-3">
|
|
||||||
<div className="flex items-center gap-2">
|
|
||||||
<Input
|
|
||||||
placeholder="Search"
|
|
||||||
className="w-48 sm:w-64"
|
|
||||||
aria-label="Search"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<AuthenticationDisplay />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
import type { NovelsQuery } from '../__generated__/graphql'
|
|
||||||
import { Card, CardContent, CardHeader, CardTitle } from './ui/card'
|
|
||||||
|
|
||||||
type NovelNode = NonNullable<NonNullable<NovelsQuery['novels']>['edges']>[number]['node']
|
|
||||||
|
|
||||||
type NovelCardProps = {
|
|
||||||
novel: NovelNode
|
|
||||||
}
|
|
||||||
|
|
||||||
function pickText(novelText?: NovelNode['name'] | NovelNode['description']) {
|
|
||||||
const texts = novelText?.texts ?? []
|
|
||||||
const english = texts.find((t) => t.language === 'EN')
|
|
||||||
return (english ?? texts[0])?.text ?? 'No description available.'
|
|
||||||
}
|
|
||||||
|
|
||||||
export function NovelCard({ novel }: NovelCardProps) {
|
|
||||||
const title = pickText(novel.name)
|
|
||||||
const description = pickText(novel.description)
|
|
||||||
const cover = novel.coverImage
|
|
||||||
|
|
||||||
const coverSrc = cover?.newPath ?? cover?.originalPath
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Card className="overflow-hidden border shadow-sm hover:shadow-md transition-shadow">
|
|
||||||
{coverSrc ? (
|
|
||||||
<div className="aspect-[3/4] w-full overflow-hidden bg-muted/50">
|
|
||||||
<img
|
|
||||||
src={coverSrc}
|
|
||||||
alt={title}
|
|
||||||
className="h-full w-full object-cover"
|
|
||||||
loading="lazy"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
<div className="aspect-[3/4] w-full bg-muted/50" />
|
|
||||||
)}
|
|
||||||
<CardHeader className="space-y-2">
|
|
||||||
<CardTitle className="line-clamp-2 text-lg leading-tight">
|
|
||||||
{title}
|
|
||||||
</CardTitle>
|
|
||||||
</CardHeader>
|
|
||||||
<CardContent className="pt-0">
|
|
||||||
<p className="line-clamp-3 text-sm text-muted-foreground">
|
|
||||||
{description}
|
|
||||||
</p>
|
|
||||||
</CardContent>
|
|
||||||
</Card>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
import * as React from 'react'
|
|
||||||
import { cva, type VariantProps } from 'class-variance-authority'
|
|
||||||
|
|
||||||
import { cn } from '../../lib/utils'
|
|
||||||
|
|
||||||
const badgeVariants = cva(
|
|
||||||
'inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2',
|
|
||||||
{
|
|
||||||
variants: {
|
|
||||||
variant: {
|
|
||||||
default:
|
|
||||||
'border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/90',
|
|
||||||
secondary:
|
|
||||||
'border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80',
|
|
||||||
outline: 'text-foreground',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
defaultVariants: {
|
|
||||||
variant: 'default',
|
|
||||||
},
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
export interface BadgeProps
|
|
||||||
extends React.HTMLAttributes<HTMLDivElement>,
|
|
||||||
VariantProps<typeof badgeVariants> {}
|
|
||||||
|
|
||||||
function Badge({ className, variant, ...props }: BadgeProps) {
|
|
||||||
return (
|
|
||||||
<div className={cn(badgeVariants({ variant }), className)} {...props} />
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// eslint-disable-next-line react-refresh/only-export-components
|
|
||||||
export { Badge, badgeVariants }
|
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
import * as React from 'react'
|
|
||||||
|
|
||||||
import { Slot } from '@radix-ui/react-slot'
|
|
||||||
import { cva, type VariantProps } from 'class-variance-authority'
|
|
||||||
|
|
||||||
import { cn } from '../../lib/utils'
|
|
||||||
|
|
||||||
const buttonVariants = cva(
|
|
||||||
'inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 ring-offset-background',
|
|
||||||
{
|
|
||||||
variants: {
|
|
||||||
variant: {
|
|
||||||
default: 'bg-primary text-primary-foreground shadow hover:bg-primary/90',
|
|
||||||
secondary:
|
|
||||||
'bg-secondary text-secondary-foreground hover:bg-secondary/80',
|
|
||||||
outline:
|
|
||||||
'border border-input bg-background hover:bg-accent hover:text-accent-foreground shadow-sm',
|
|
||||||
ghost: 'hover:bg-accent hover:text-accent-foreground',
|
|
||||||
},
|
|
||||||
size: {
|
|
||||||
default: 'h-10 px-4 py-2',
|
|
||||||
sm: 'h-9 rounded-md px-3',
|
|
||||||
lg: 'h-11 rounded-md px-8',
|
|
||||||
icon: 'h-10 w-10',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
defaultVariants: {
|
|
||||||
variant: 'default',
|
|
||||||
size: 'default',
|
|
||||||
},
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
export interface ButtonProps
|
|
||||||
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
|
|
||||||
VariantProps<typeof buttonVariants> {
|
|
||||||
asChild?: boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|
||||||
({ className, variant, size, asChild = false, ...props }, ref) => {
|
|
||||||
const Comp = asChild ? Slot : 'button'
|
|
||||||
return (
|
|
||||||
<Comp
|
|
||||||
className={cn(buttonVariants({ variant, size, className }))}
|
|
||||||
ref={ref}
|
|
||||||
{...props}
|
|
||||||
/>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
Button.displayName = 'Button'
|
|
||||||
|
|
||||||
// eslint-disable-next-line react-refresh/only-export-components
|
|
||||||
export { Button, buttonVariants }
|
|
||||||
@@ -1,76 +0,0 @@
|
|||||||
import * as React from 'react'
|
|
||||||
|
|
||||||
import { cn } from '../../lib/utils'
|
|
||||||
|
|
||||||
const Card = React.forwardRef<
|
|
||||||
HTMLDivElement,
|
|
||||||
React.HTMLAttributes<HTMLDivElement>
|
|
||||||
>(({ className, ...props }, ref) => (
|
|
||||||
<div
|
|
||||||
ref={ref}
|
|
||||||
className={cn(
|
|
||||||
'rounded-xl border bg-card text-card-foreground shadow-sm',
|
|
||||||
className
|
|
||||||
)}
|
|
||||||
{...props}
|
|
||||||
/>
|
|
||||||
))
|
|
||||||
Card.displayName = 'Card'
|
|
||||||
|
|
||||||
const CardHeader = React.forwardRef<
|
|
||||||
HTMLDivElement,
|
|
||||||
React.HTMLAttributes<HTMLDivElement>
|
|
||||||
>(({ className, ...props }, ref) => (
|
|
||||||
<div
|
|
||||||
ref={ref}
|
|
||||||
className={cn('flex flex-col space-y-1.5 p-6', className)}
|
|
||||||
{...props}
|
|
||||||
/>
|
|
||||||
))
|
|
||||||
CardHeader.displayName = 'CardHeader'
|
|
||||||
|
|
||||||
const CardTitle = React.forwardRef<
|
|
||||||
HTMLParagraphElement,
|
|
||||||
React.HTMLAttributes<HTMLHeadingElement>
|
|
||||||
>(({ className, ...props }, ref) => (
|
|
||||||
<h3
|
|
||||||
ref={ref}
|
|
||||||
className={cn('text-2xl font-semibold leading-none tracking-tight', className)}
|
|
||||||
{...props}
|
|
||||||
/>
|
|
||||||
))
|
|
||||||
CardTitle.displayName = 'CardTitle'
|
|
||||||
|
|
||||||
const CardDescription = React.forwardRef<
|
|
||||||
HTMLParagraphElement,
|
|
||||||
React.HTMLAttributes<HTMLParagraphElement>
|
|
||||||
>(({ className, ...props }, ref) => (
|
|
||||||
<p
|
|
||||||
ref={ref}
|
|
||||||
className={cn('text-sm text-muted-foreground', className)}
|
|
||||||
{...props}
|
|
||||||
/>
|
|
||||||
))
|
|
||||||
CardDescription.displayName = 'CardDescription'
|
|
||||||
|
|
||||||
const CardContent = React.forwardRef<
|
|
||||||
HTMLDivElement,
|
|
||||||
React.HTMLAttributes<HTMLDivElement>
|
|
||||||
>(({ className, ...props }, ref) => (
|
|
||||||
<div ref={ref} className={cn('p-6 pt-0', className)} {...props} />
|
|
||||||
))
|
|
||||||
CardContent.displayName = 'CardContent'
|
|
||||||
|
|
||||||
const CardFooter = React.forwardRef<
|
|
||||||
HTMLDivElement,
|
|
||||||
React.HTMLAttributes<HTMLDivElement>
|
|
||||||
>(({ className, ...props }, ref) => (
|
|
||||||
<div
|
|
||||||
ref={ref}
|
|
||||||
className={cn('flex items-center p-6 pt-0', className)}
|
|
||||||
{...props}
|
|
||||||
/>
|
|
||||||
))
|
|
||||||
CardFooter.displayName = 'CardFooter'
|
|
||||||
|
|
||||||
export { Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent }
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
import * as React from 'react'
|
|
||||||
|
|
||||||
import { cn } from '../../lib/utils'
|
|
||||||
|
|
||||||
export type InputProps = React.InputHTMLAttributes<HTMLInputElement>
|
|
||||||
|
|
||||||
const Input = React.forwardRef<HTMLInputElement, InputProps>(
|
|
||||||
({ className, type, ...props }, ref) => {
|
|
||||||
return (
|
|
||||||
<input
|
|
||||||
type={type}
|
|
||||||
className={cn(
|
|
||||||
'flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50',
|
|
||||||
className
|
|
||||||
)}
|
|
||||||
ref={ref}
|
|
||||||
{...props}
|
|
||||||
/>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
Input.displayName = 'Input'
|
|
||||||
|
|
||||||
export { Input }
|
|
||||||
@@ -1,69 +0,0 @@
|
|||||||
@tailwind base;
|
|
||||||
@tailwind components;
|
|
||||||
@tailwind utilities;
|
|
||||||
|
|
||||||
:root {
|
|
||||||
--background: 210 40% 98%;
|
|
||||||
--foreground: 222 47% 11%;
|
|
||||||
--muted: 214 32% 91%;
|
|
||||||
--muted-foreground: 215 16% 47%;
|
|
||||||
--popover: 0 0% 100%;
|
|
||||||
--popover-foreground: 222 47% 11%;
|
|
||||||
--card: 0 0% 100%;
|
|
||||||
--card-foreground: 222 47% 11%;
|
|
||||||
--border: 214 32% 91%;
|
|
||||||
--input: 214 32% 91%;
|
|
||||||
--primary: 243 75% 59%;
|
|
||||||
--primary-foreground: 0 0% 100%;
|
|
||||||
--secondary: 240 33% 94%;
|
|
||||||
--secondary-foreground: 222 47% 11%;
|
|
||||||
--accent: 220 70% 96%;
|
|
||||||
--accent-foreground: 222 47% 11%;
|
|
||||||
--destructive: 0 84% 60%;
|
|
||||||
--destructive-foreground: 0 0% 100%;
|
|
||||||
--ring: 243 75% 59%;
|
|
||||||
--radius: 12px;
|
|
||||||
--font-sans: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
|
|
||||||
}
|
|
||||||
|
|
||||||
.dark {
|
|
||||||
--background: 222 47% 11%;
|
|
||||||
--foreground: 210 40% 98%;
|
|
||||||
--muted: 222 47% 14%;
|
|
||||||
--muted-foreground: 215 20% 65%;
|
|
||||||
--popover: 222 47% 11%;
|
|
||||||
--popover-foreground: 210 40% 98%;
|
|
||||||
--card: 222 47% 11%;
|
|
||||||
--card-foreground: 210 40% 98%;
|
|
||||||
--border: 222 47% 20%;
|
|
||||||
--input: 222 47% 20%;
|
|
||||||
--primary: 243 75% 70%;
|
|
||||||
--primary-foreground: 222 47% 11%;
|
|
||||||
--secondary: 222 47% 20%;
|
|
||||||
--secondary-foreground: 210 40% 98%;
|
|
||||||
--accent: 222 47% 20%;
|
|
||||||
--accent-foreground: 210 40% 98%;
|
|
||||||
--destructive: 0 84% 60%;
|
|
||||||
--destructive-foreground: 210 40% 98%;
|
|
||||||
--ring: 243 75% 70%;
|
|
||||||
}
|
|
||||||
|
|
||||||
* {
|
|
||||||
@apply border-border;
|
|
||||||
}
|
|
||||||
|
|
||||||
body {
|
|
||||||
@apply bg-background text-foreground min-h-screen antialiased;
|
|
||||||
background-image: radial-gradient(circle at 20% 20%, #eef2ff, transparent 32%),
|
|
||||||
radial-gradient(circle at 80% 10%, #dcfce7, transparent 25%),
|
|
||||||
radial-gradient(circle at 50% 80%, #fee2e2, transparent 20%),
|
|
||||||
linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(248, 250, 252, 0.95));
|
|
||||||
}
|
|
||||||
|
|
||||||
a {
|
|
||||||
@apply text-primary font-medium;
|
|
||||||
}
|
|
||||||
|
|
||||||
a:hover {
|
|
||||||
@apply underline;
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
import { Outlet } from 'react-router-dom'
|
|
||||||
import { Navbar } from '../components/Navbar'
|
|
||||||
|
|
||||||
export function AppLayout() {
|
|
||||||
return (
|
|
||||||
<div className="min-h-screen bg-slate-50">
|
|
||||||
<Navbar />
|
|
||||||
<main className="mx-auto flex max-w-6xl flex-col gap-6 px-4 py-8 sm:px-6 lg:px-8">
|
|
||||||
<Outlet />
|
|
||||||
</main>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
import { type ClassValue, clsx } from 'clsx'
|
|
||||||
import { twMerge } from 'tailwind-merge'
|
|
||||||
|
|
||||||
export function cn(...inputs: ClassValue[]) {
|
|
||||||
return twMerge(clsx(inputs))
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
import { StrictMode } from 'react'
|
|
||||||
import { createRoot } from 'react-dom/client'
|
|
||||||
import './index.css'
|
|
||||||
import App from './App.tsx'
|
|
||||||
import { ApolloProvider } from '@apollo/client/react'
|
|
||||||
import { apolloClient } from './apolloClient.ts'
|
|
||||||
import { AuthProvider } from './auth/AuthContext'
|
|
||||||
import { BrowserRouter } from 'react-router-dom'
|
|
||||||
|
|
||||||
createRoot(document.getElementById('root')!).render(
|
|
||||||
<StrictMode>
|
|
||||||
<AuthProvider>
|
|
||||||
<ApolloProvider client={apolloClient}>
|
|
||||||
<BrowserRouter>
|
|
||||||
<App />
|
|
||||||
</BrowserRouter>
|
|
||||||
</ApolloProvider>
|
|
||||||
</AuthProvider>
|
|
||||||
</StrictMode>,
|
|
||||||
)
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
import { Card, CardContent, CardHeader, CardTitle } from '../components/ui/card'
|
|
||||||
|
|
||||||
export function NotFoundPage() {
|
|
||||||
return (
|
|
||||||
<Card className="shadow-md shadow-primary/10">
|
|
||||||
<CardHeader>
|
|
||||||
<CardTitle>Page not found</CardTitle>
|
|
||||||
</CardHeader>
|
|
||||||
<CardContent>
|
|
||||||
<p className="text-sm text-muted-foreground">
|
|
||||||
The page you are looking for does not exist. Head back to the novels
|
|
||||||
list to continue.
|
|
||||||
</p>
|
|
||||||
</CardContent>
|
|
||||||
</Card>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
import { Card, CardContent, CardHeader, CardTitle } from '../components/ui/card'
|
|
||||||
|
|
||||||
export function NovelDetailPage() {
|
|
||||||
return (
|
|
||||||
<Card className="shadow-md shadow-primary/10">
|
|
||||||
<CardHeader>
|
|
||||||
<CardTitle>Novel details</CardTitle>
|
|
||||||
</CardHeader>
|
|
||||||
<CardContent>
|
|
||||||
<p className="text-sm text-muted-foreground">
|
|
||||||
Detail view coming soon. Select a novel to explore chapters and
|
|
||||||
metadata once implemented.
|
|
||||||
</p>
|
|
||||||
</CardContent>
|
|
||||||
</Card>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
@@ -1,111 +0,0 @@
|
|||||||
import { useMemo } from 'react'
|
|
||||||
|
|
||||||
import { useQuery } from '@apollo/client/react'
|
|
||||||
import { NovelsDocument } from '../__generated__/graphql'
|
|
||||||
import { NovelCard } from '../components/NovelCard'
|
|
||||||
import { Button } from '../components/ui/button'
|
|
||||||
import { Card, CardContent, CardHeader, CardTitle } from '../components/ui/card'
|
|
||||||
|
|
||||||
const PAGE_SIZE = 12
|
|
||||||
|
|
||||||
export function NovelsPage() {
|
|
||||||
const { data, loading, error, fetchMore } = useQuery(NovelsDocument, {
|
|
||||||
variables: { first: PAGE_SIZE, after: null },
|
|
||||||
notifyOnNetworkStatusChange: true,
|
|
||||||
})
|
|
||||||
|
|
||||||
const pageInfo = data?.novels?.pageInfo
|
|
||||||
const hasNextPage = pageInfo?.hasNextPage ?? false
|
|
||||||
const endCursor = pageInfo?.endCursor ?? null
|
|
||||||
|
|
||||||
const novels = useMemo(
|
|
||||||
() => (data?.novels?.edges ?? []).map((edge) => edge?.node).filter(Boolean),
|
|
||||||
[data?.novels?.edges]
|
|
||||||
)
|
|
||||||
|
|
||||||
async function handleLoadMore() {
|
|
||||||
if (!hasNextPage || !endCursor) return
|
|
||||||
await fetchMore({
|
|
||||||
variables: { after: endCursor, first: PAGE_SIZE },
|
|
||||||
updateQuery: (prev, { fetchMoreResult }) => {
|
|
||||||
if (!fetchMoreResult?.novels?.edges) return prev
|
|
||||||
const mergedEdges = [
|
|
||||||
...(prev.novels?.edges ?? []),
|
|
||||||
...fetchMoreResult.novels.edges,
|
|
||||||
]
|
|
||||||
return {
|
|
||||||
...prev,
|
|
||||||
novels: {
|
|
||||||
...fetchMoreResult.novels,
|
|
||||||
edges: mergedEdges,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="space-y-4">
|
|
||||||
<Card className="shadow-md shadow-primary/10">
|
|
||||||
<CardHeader>
|
|
||||||
<CardTitle>Latest Novels</CardTitle>
|
|
||||||
<p className="text-sm text-muted-foreground">
|
|
||||||
Novels that have recently been updated.
|
|
||||||
</p>
|
|
||||||
</CardHeader>
|
|
||||||
</Card>
|
|
||||||
|
|
||||||
{loading && !data && (
|
|
||||||
<Card>
|
|
||||||
<CardContent>
|
|
||||||
<div className="flex items-center justify-center py-8">
|
|
||||||
<div className="h-10 w-10 animate-spin rounded-full border-2 border-primary border-t-transparent" aria-label="Loading novels" />
|
|
||||||
</div>
|
|
||||||
</CardContent>
|
|
||||||
</Card>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{error && (
|
|
||||||
<Card className="border-destructive/40 bg-destructive/5">
|
|
||||||
<CardContent>
|
|
||||||
<p className="py-4 text-sm text-destructive">
|
|
||||||
Could not load novels: {error.message}
|
|
||||||
</p>
|
|
||||||
</CardContent>
|
|
||||||
</Card>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{!loading && novels.length === 0 && !error && (
|
|
||||||
<Card>
|
|
||||||
<CardContent>
|
|
||||||
<p className="py-4 text-sm text-muted-foreground">
|
|
||||||
No novels found yet. Try adding content to the gateway.
|
|
||||||
</p>
|
|
||||||
</CardContent>
|
|
||||||
</Card>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{novels.length > 0 && (
|
|
||||||
<div className="grid gap-4 sm:grid-cols-2 lg:grid-cols-3">
|
|
||||||
{novels.map(
|
|
||||||
(novel) =>
|
|
||||||
novel && <NovelCard key={novel.id.toString()} novel={novel} />
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{hasNextPage && (
|
|
||||||
<div className="flex justify-center">
|
|
||||||
<Button
|
|
||||||
onClick={handleLoadMore}
|
|
||||||
variant="outline"
|
|
||||||
disabled={loading}
|
|
||||||
className="min-w-[160px]"
|
|
||||||
>
|
|
||||||
{loading ? 'Loading...' : 'Load more'}
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
@@ -1,69 +0,0 @@
|
|||||||
const { fontFamily } = require('tailwindcss/defaultTheme')
|
|
||||||
|
|
||||||
/** @type {import('tailwindcss').Config} */
|
|
||||||
module.exports = {
|
|
||||||
darkMode: ['class'],
|
|
||||||
content: ['./index.html', './src/**/*.{ts,tsx}'],
|
|
||||||
theme: {
|
|
||||||
extend: {
|
|
||||||
colors: {
|
|
||||||
border: 'hsl(var(--border))',
|
|
||||||
input: 'hsl(var(--input))',
|
|
||||||
ring: 'hsl(var(--ring))',
|
|
||||||
background: 'hsl(var(--background))',
|
|
||||||
foreground: 'hsl(var(--foreground))',
|
|
||||||
primary: {
|
|
||||||
DEFAULT: 'hsl(var(--primary))',
|
|
||||||
foreground: 'hsl(var(--primary-foreground))',
|
|
||||||
},
|
|
||||||
secondary: {
|
|
||||||
DEFAULT: 'hsl(var(--secondary))',
|
|
||||||
foreground: 'hsl(var(--secondary-foreground))',
|
|
||||||
},
|
|
||||||
destructive: {
|
|
||||||
DEFAULT: 'hsl(var(--destructive))',
|
|
||||||
foreground: 'hsl(var(--destructive-foreground))',
|
|
||||||
},
|
|
||||||
muted: {
|
|
||||||
DEFAULT: 'hsl(var(--muted))',
|
|
||||||
foreground: 'hsl(var(--muted-foreground))',
|
|
||||||
},
|
|
||||||
accent: {
|
|
||||||
DEFAULT: 'hsl(var(--accent))',
|
|
||||||
foreground: 'hsl(var(--accent-foreground))',
|
|
||||||
},
|
|
||||||
popover: {
|
|
||||||
DEFAULT: 'hsl(var(--popover))',
|
|
||||||
foreground: 'hsl(var(--popover-foreground))',
|
|
||||||
},
|
|
||||||
card: {
|
|
||||||
DEFAULT: 'hsl(var(--card))',
|
|
||||||
foreground: 'hsl(var(--card-foreground))',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
borderRadius: {
|
|
||||||
lg: 'var(--radius)',
|
|
||||||
md: 'calc(var(--radius) - 2px)',
|
|
||||||
sm: 'calc(var(--radius) - 4px)',
|
|
||||||
},
|
|
||||||
fontFamily: {
|
|
||||||
sans: ['var(--font-sans)', ...fontFamily.sans],
|
|
||||||
},
|
|
||||||
keyframes: {
|
|
||||||
'accordion-down': {
|
|
||||||
from: { height: '0' },
|
|
||||||
to: { height: 'var(--radix-accordion-content-height)' },
|
|
||||||
},
|
|
||||||
'accordion-up': {
|
|
||||||
from: { height: 'var(--radix-accordion-content-height)' },
|
|
||||||
to: { height: '0' },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
animation: {
|
|
||||||
'accordion-down': 'accordion-down 0.2s ease-out',
|
|
||||||
'accordion-up': 'accordion-up 0.2s ease-out',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
plugins: [require('tailwindcss-animate')],
|
|
||||||
}
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
{
|
|
||||||
"compilerOptions": {
|
|
||||||
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
|
|
||||||
"target": "ES2022",
|
|
||||||
"useDefineForClassFields": true,
|
|
||||||
"lib": ["ES2022", "DOM", "DOM.Iterable"],
|
|
||||||
"module": "ESNext",
|
|
||||||
"types": ["vite/client"],
|
|
||||||
"skipLibCheck": true,
|
|
||||||
|
|
||||||
/* Bundler mode */
|
|
||||||
"moduleResolution": "bundler",
|
|
||||||
"allowImportingTsExtensions": true,
|
|
||||||
"verbatimModuleSyntax": true,
|
|
||||||
"moduleDetection": "force",
|
|
||||||
"noEmit": true,
|
|
||||||
"jsx": "react-jsx",
|
|
||||||
|
|
||||||
/* Linting */
|
|
||||||
"strict": true,
|
|
||||||
"noUnusedLocals": true,
|
|
||||||
"noUnusedParameters": true,
|
|
||||||
"erasableSyntaxOnly": true,
|
|
||||||
"noFallthroughCasesInSwitch": true,
|
|
||||||
"noUncheckedSideEffectImports": true
|
|
||||||
},
|
|
||||||
"include": ["src"]
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
{
|
|
||||||
"files": [],
|
|
||||||
"references": [
|
|
||||||
{ "path": "./tsconfig.app.json" },
|
|
||||||
{ "path": "./tsconfig.node.json" }
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
{
|
|
||||||
"compilerOptions": {
|
|
||||||
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
|
|
||||||
"target": "ES2023",
|
|
||||||
"lib": ["ES2023"],
|
|
||||||
"module": "ESNext",
|
|
||||||
"types": ["node"],
|
|
||||||
"skipLibCheck": true,
|
|
||||||
|
|
||||||
/* Bundler mode */
|
|
||||||
"moduleResolution": "bundler",
|
|
||||||
"allowImportingTsExtensions": true,
|
|
||||||
"verbatimModuleSyntax": true,
|
|
||||||
"moduleDetection": "force",
|
|
||||||
"noEmit": true,
|
|
||||||
|
|
||||||
/* Linting */
|
|
||||||
"strict": true,
|
|
||||||
"noUnusedLocals": true,
|
|
||||||
"noUnusedParameters": true,
|
|
||||||
"erasableSyntaxOnly": true,
|
|
||||||
"noFallthroughCasesInSwitch": true,
|
|
||||||
"noUncheckedSideEffectImports": true
|
|
||||||
},
|
|
||||||
"include": ["vite.config.ts"]
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
import { defineConfig } from 'vite'
|
|
||||||
import react from '@vitejs/plugin-react'
|
|
||||||
import path from 'node:path'
|
|
||||||
|
|
||||||
// https://vite.dev/config/
|
|
||||||
export default defineConfig({
|
|
||||||
plugins: [react()],
|
|
||||||
resolve: {
|
|
||||||
alias: {
|
|
||||||
react: path.resolve(__dirname, 'node_modules/react'),
|
|
||||||
'react-dom': path.resolve(__dirname, 'node_modules/react-dom'),
|
|
||||||
'react/jsx-runtime': path.resolve(
|
|
||||||
__dirname,
|
|
||||||
'node_modules/react/jsx-runtime'
|
|
||||||
),
|
|
||||||
'react/jsx-dev-runtime': path.resolve(
|
|
||||||
__dirname,
|
|
||||||
'node_modules/react/jsx-dev-runtime'
|
|
||||||
),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||