mirror of
https://github.com/pvrzz/directify.git
synced 2026-11-29 05:22:24 +00:00
Add directify desktop app source
osu!lazer-style beatmap search (mode, mania key count, genre, language, star-rating range) against catboy.best-compatible mirrors with automatic fallback, library management with offline-cached cover art, a collection.db editor, portable beatpack backup/restore, i18n (en/es/ja), light/dark theme, keyboard shortcuts, proxy support, and an in-app GitHub Releases update check.
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"name": "@directify/shared",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"main": "./src/index.ts",
|
||||
"types": "./src/index.ts",
|
||||
"scripts": {
|
||||
"test": "vitest run",
|
||||
"lint": "tsc --noEmit"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^20.14.0",
|
||||
"typescript": "^5.6.0",
|
||||
"vitest": "^2.1.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { readCollectionDb, writeCollectionDb } from "./collection-db";
|
||||
import type { CollectionDatabase } from "./types";
|
||||
|
||||
describe("collection.db round-trip", () => {
|
||||
it("writes then reads back an identical structure", () => {
|
||||
const db: CollectionDatabase = {
|
||||
version: 20240101,
|
||||
collections: [
|
||||
{
|
||||
name: "Favorites",
|
||||
beatmapChecksums: [
|
||||
"a".repeat(32),
|
||||
"b".repeat(32),
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Empty collection",
|
||||
beatmapChecksums: [],
|
||||
},
|
||||
{
|
||||
name: "unicode ☆ collection 譜面",
|
||||
beatmapChecksums: ["c".repeat(32)],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const buf = writeCollectionDb(db);
|
||||
const roundTripped = readCollectionDb(buf);
|
||||
|
||||
expect(roundTripped).toEqual(db);
|
||||
});
|
||||
|
||||
it("produces byte-identical output when re-serialized", () => {
|
||||
const db: CollectionDatabase = {
|
||||
version: 20240101,
|
||||
collections: [{ name: "Test", beatmapChecksums: ["d".repeat(32)] }],
|
||||
};
|
||||
|
||||
const first = writeCollectionDb(db);
|
||||
const second = writeCollectionDb(readCollectionDb(first));
|
||||
|
||||
expect(second.equals(first)).toBe(true);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,145 @@
|
||||
import type { Collection, CollectionDatabase } from "./types";
|
||||
|
||||
/**
|
||||
* Reader/writer for osu!stable's `collection.db`.
|
||||
*
|
||||
* Format (little-endian):
|
||||
* int32 version
|
||||
* int32 collection count
|
||||
* for each collection:
|
||||
* string name
|
||||
* int32 beatmap count
|
||||
* for each beatmap:
|
||||
* string beatmap (.osu) MD5 checksum
|
||||
*
|
||||
* osu!-strings are a single marker byte (0x00 = null, 0x0b = present)
|
||||
* followed, when present, by a ULEB128-encoded byte length and the UTF-8 bytes.
|
||||
*/
|
||||
|
||||
const STRING_NULL = 0x00;
|
||||
const STRING_PRESENT = 0x0b;
|
||||
|
||||
class ByteReader {
|
||||
private offset = 0;
|
||||
constructor(private readonly buf: Buffer) {}
|
||||
|
||||
get bytesRemaining(): number {
|
||||
return this.buf.length - this.offset;
|
||||
}
|
||||
|
||||
readInt32(): number {
|
||||
const value = this.buf.readInt32LE(this.offset);
|
||||
this.offset += 4;
|
||||
return value;
|
||||
}
|
||||
|
||||
readByte(): number {
|
||||
const value = this.buf.readUInt8(this.offset);
|
||||
this.offset += 1;
|
||||
return value;
|
||||
}
|
||||
|
||||
private readUleb128(): number {
|
||||
let result = 0;
|
||||
let shift = 0;
|
||||
for (;;) {
|
||||
const byte = this.readByte();
|
||||
result |= (byte & 0x7f) << shift;
|
||||
if ((byte & 0x80) === 0) break;
|
||||
shift += 7;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
readString(): string | null {
|
||||
const marker = this.readByte();
|
||||
if (marker === STRING_NULL) return null;
|
||||
if (marker !== STRING_PRESENT) {
|
||||
throw new Error(`Unexpected osu!-string marker byte 0x${marker.toString(16)}`);
|
||||
}
|
||||
const length = this.readUleb128();
|
||||
const value = this.buf.toString("utf8", this.offset, this.offset + length);
|
||||
this.offset += length;
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
class ByteWriter {
|
||||
private chunks: Buffer[] = [];
|
||||
|
||||
writeInt32(value: number): this {
|
||||
const b = Buffer.alloc(4);
|
||||
b.writeInt32LE(value, 0);
|
||||
this.chunks.push(b);
|
||||
return this;
|
||||
}
|
||||
|
||||
writeByte(value: number): this {
|
||||
this.chunks.push(Buffer.from([value]));
|
||||
return this;
|
||||
}
|
||||
|
||||
private writeUleb128(value: number): this {
|
||||
const bytes: number[] = [];
|
||||
let v = value;
|
||||
do {
|
||||
let byte = v & 0x7f;
|
||||
v >>>= 7;
|
||||
if (v !== 0) byte |= 0x80;
|
||||
bytes.push(byte);
|
||||
} while (v !== 0);
|
||||
this.chunks.push(Buffer.from(bytes));
|
||||
return this;
|
||||
}
|
||||
|
||||
writeString(value: string | null | undefined): this {
|
||||
if (value === null || value === undefined) {
|
||||
return this.writeByte(STRING_NULL);
|
||||
}
|
||||
this.writeByte(STRING_PRESENT);
|
||||
const utf8 = Buffer.from(value, "utf8");
|
||||
this.writeUleb128(utf8.length);
|
||||
this.chunks.push(utf8);
|
||||
return this;
|
||||
}
|
||||
|
||||
toBuffer(): Buffer {
|
||||
return Buffer.concat(this.chunks);
|
||||
}
|
||||
}
|
||||
|
||||
export function readCollectionDb(buf: Buffer): CollectionDatabase {
|
||||
const reader = new ByteReader(buf);
|
||||
const version = reader.readInt32();
|
||||
const collectionCount = reader.readInt32();
|
||||
|
||||
const collections: Collection[] = [];
|
||||
for (let i = 0; i < collectionCount; i++) {
|
||||
const name = reader.readString() ?? "";
|
||||
const beatmapCount = reader.readInt32();
|
||||
const beatmapChecksums: string[] = [];
|
||||
for (let j = 0; j < beatmapCount; j++) {
|
||||
const checksum = reader.readString();
|
||||
if (checksum) beatmapChecksums.push(checksum);
|
||||
}
|
||||
collections.push({ name, beatmapChecksums });
|
||||
}
|
||||
|
||||
return { version, collections };
|
||||
}
|
||||
|
||||
export function writeCollectionDb(db: CollectionDatabase): Buffer {
|
||||
const writer = new ByteWriter();
|
||||
writer.writeInt32(db.version);
|
||||
writer.writeInt32(db.collections.length);
|
||||
|
||||
for (const collection of db.collections) {
|
||||
writer.writeString(collection.name);
|
||||
writer.writeInt32(collection.beatmapChecksums.length);
|
||||
for (const checksum of collection.beatmapChecksums) {
|
||||
writer.writeString(checksum);
|
||||
}
|
||||
}
|
||||
|
||||
return writer.toBuffer();
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
export * from "./types";
|
||||
export * from "./collection-db";
|
||||
@@ -0,0 +1,139 @@
|
||||
export type OsuMode = "osu" | "taiko" | "fruits" | "mania";
|
||||
|
||||
export type RankedStatus =
|
||||
| "graveyard"
|
||||
| "wip"
|
||||
| "pending"
|
||||
| "ranked"
|
||||
| "approved"
|
||||
| "qualified"
|
||||
| "loved"
|
||||
/** Status can't be determined from a local scan alone (no online lookup performed). */
|
||||
| "unknown";
|
||||
|
||||
/** A single difficulty within a beatmapset. */
|
||||
export interface Beatmap {
|
||||
id: number;
|
||||
beatmapsetId: number;
|
||||
version: string;
|
||||
mode: OsuMode;
|
||||
difficultyRating: number;
|
||||
bpm: number;
|
||||
totalLength: number;
|
||||
/** Circle size — also doubles as the key count for mania difficulties. */
|
||||
cs: number;
|
||||
ar: number;
|
||||
od: number;
|
||||
hp: number;
|
||||
/** MD5 of the .osu file, used as the key in osu!stable's collection.db. */
|
||||
checksum: string;
|
||||
}
|
||||
|
||||
/** A beatmapset as indexed from a source mirror. */
|
||||
export interface BeatmapSet {
|
||||
id: number;
|
||||
title: string;
|
||||
artist: string;
|
||||
creator: string;
|
||||
status: RankedStatus;
|
||||
coverUrl?: string;
|
||||
previewUrl?: string;
|
||||
tags: string[];
|
||||
genre?: string;
|
||||
language?: string;
|
||||
submittedAt: string;
|
||||
updatedAt: string;
|
||||
beatmaps: Beatmap[];
|
||||
/** Which source mirror this record was resolved from, or "local" for an installed scan. */
|
||||
source: string;
|
||||
/** Present for beatmapsets found on disk; the Songs subfolder name, used for file operations. */
|
||||
folderName?: string;
|
||||
}
|
||||
|
||||
/** osu!'s own genre enum (matches the IDs osu!/mirrors report; "any" omitted since it means "no filter"). */
|
||||
export const GENRES: Record<number, string> = {
|
||||
1: "Unspecified",
|
||||
2: "Video Game",
|
||||
3: "Anime",
|
||||
4: "Rock",
|
||||
5: "Pop",
|
||||
6: "Other",
|
||||
7: "Novelty",
|
||||
9: "Hip Hop",
|
||||
10: "Electronic",
|
||||
11: "Metal",
|
||||
12: "Classical",
|
||||
13: "Folk",
|
||||
14: "Jazz",
|
||||
};
|
||||
|
||||
/** osu!'s own language enum. */
|
||||
export const LANGUAGES: Record<number, string> = {
|
||||
1: "Unspecified",
|
||||
2: "English",
|
||||
3: "Japanese",
|
||||
4: "Chinese",
|
||||
5: "Instrumental",
|
||||
6: "Korean",
|
||||
7: "French",
|
||||
8: "German",
|
||||
9: "Swedish",
|
||||
10: "Spanish",
|
||||
11: "Italian",
|
||||
12: "Russian",
|
||||
13: "Polish",
|
||||
14: "Other",
|
||||
};
|
||||
|
||||
export interface BeatmapSearchQuery {
|
||||
query?: string;
|
||||
mode?: OsuMode;
|
||||
status?: RankedStatus;
|
||||
minStars?: number;
|
||||
maxStars?: number;
|
||||
/** Numeric genre id — see GENRES. */
|
||||
genre?: number;
|
||||
/** Numeric language id — see LANGUAGES. */
|
||||
language?: number;
|
||||
/** Mania key count (4, 7, ...) — matched against difficulty CS. Ignored unless mode is "mania". */
|
||||
keys?: number;
|
||||
page?: number;
|
||||
pageSize?: number;
|
||||
}
|
||||
|
||||
export interface BeatmapSearchResult {
|
||||
results: BeatmapSet[];
|
||||
page: number;
|
||||
pageSize: number;
|
||||
total: number;
|
||||
}
|
||||
|
||||
/** In-memory representation of an osu!stable collection. */
|
||||
export interface Collection {
|
||||
name: string;
|
||||
/** Beatmap (.osu) MD5 checksums belonging to this collection. */
|
||||
beatmapChecksums: string[];
|
||||
}
|
||||
|
||||
export interface CollectionDatabase {
|
||||
version: number;
|
||||
collections: Collection[];
|
||||
}
|
||||
|
||||
export interface BeatmapSourceConfig {
|
||||
id: string;
|
||||
name: string;
|
||||
baseUrl: string;
|
||||
builtIn?: boolean;
|
||||
enabled: boolean;
|
||||
}
|
||||
|
||||
export type ThemeMode = "dark" | "light" | "system";
|
||||
|
||||
export type ProxyType = "none" | "http" | "https" | "socks4" | "socks5";
|
||||
|
||||
export interface ProxyConfig {
|
||||
type: ProxyType;
|
||||
host: string;
|
||||
port: string;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "dist",
|
||||
"rootDir": "src"
|
||||
},
|
||||
"include": ["src"]
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"name": "@directify/ui",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"main": "./src/index.ts",
|
||||
"types": "./src/index.ts",
|
||||
"scripts": {
|
||||
"lint": "tsc --noEmit"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": "^18.3.0",
|
||||
"react-dom": "^18.3.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@directify/shared": "workspace:*",
|
||||
"framer-motion": "^11.11.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^20.14.0",
|
||||
"@types/react": "^18.3.0",
|
||||
"@types/react-dom": "^18.3.0",
|
||||
"typescript": "^5.6.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
// Button: pink (primary) is the app's own branded action, blue (accent) is reserved for download/get-the-app actions — matches osu!'s own site split between "Support" (pink) and "Download" (blue) rather than one hue for everything.
|
||||
import { motion } from "framer-motion";
|
||||
import type { ButtonHTMLAttributes, ReactNode } from "react";
|
||||
|
||||
export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
||||
variant?: "primary" | "accent" | "secondary" | "ghost";
|
||||
children: ReactNode;
|
||||
}
|
||||
|
||||
const variantStyles: Record<NonNullable<ButtonProps["variant"]>, React.CSSProperties> = {
|
||||
primary: {
|
||||
background: "var(--df-pink)",
|
||||
color: "var(--df-on-fill)",
|
||||
border: "none",
|
||||
boxShadow: "var(--df-shadow-sm)",
|
||||
},
|
||||
accent: {
|
||||
background: "var(--df-blue)",
|
||||
color: "var(--df-on-fill)",
|
||||
border: "none",
|
||||
boxShadow: "var(--df-shadow-sm)",
|
||||
},
|
||||
secondary: {
|
||||
background: "var(--df-surface-2)",
|
||||
color: "var(--df-text)",
|
||||
border: "1px solid var(--df-border)",
|
||||
},
|
||||
ghost: {
|
||||
background: "transparent",
|
||||
color: "var(--df-text-muted)",
|
||||
border: "1px solid transparent",
|
||||
},
|
||||
};
|
||||
|
||||
const hoverGlow: Partial<Record<NonNullable<ButtonProps["variant"]>, string>> = {
|
||||
primary: "var(--df-glow-pink)",
|
||||
accent: "var(--df-glow-blue)",
|
||||
};
|
||||
|
||||
export function Button({ variant = "primary", style, children, ...rest }: ButtonProps) {
|
||||
return (
|
||||
<motion.button
|
||||
whileHover={{ y: -2, filter: "brightness(1.08)", boxShadow: hoverGlow[variant] }}
|
||||
whileTap={{ y: 0, scale: 0.98 }}
|
||||
transition={{ type: "spring", stiffness: 500, damping: 30 }}
|
||||
style={{
|
||||
padding: "10px 20px",
|
||||
borderRadius: "var(--df-radius-sm)",
|
||||
fontWeight: 600,
|
||||
fontSize: 14,
|
||||
cursor: "pointer",
|
||||
...variantStyles[variant],
|
||||
...style,
|
||||
}}
|
||||
{...(rest as any)}
|
||||
>
|
||||
{children}
|
||||
</motion.button>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
// Beatmapset-style card: soft resting shadow, lifts on hover/selection; the cover is a real <img> (not a CSS background string) so a failed/missing cover degrades to the plain surface color instead of rendering nothing; keyboard-operable when clickable.
|
||||
import { motion } from "framer-motion";
|
||||
import { useState, type KeyboardEvent, type ReactNode } from "react";
|
||||
|
||||
export interface CardProps {
|
||||
children: ReactNode;
|
||||
onClick?: () => void;
|
||||
coverUrl?: string;
|
||||
selected?: boolean;
|
||||
label?: string;
|
||||
}
|
||||
|
||||
export function Card({ children, onClick, coverUrl, selected, label }: CardProps) {
|
||||
const [coverFailed, setCoverFailed] = useState(false);
|
||||
const showCover = !!coverUrl && !coverFailed;
|
||||
|
||||
function handleKeyDown(e: KeyboardEvent<HTMLDivElement>) {
|
||||
if (!onClick) return;
|
||||
if (e.key === "Enter" || e.key === " ") {
|
||||
e.preventDefault();
|
||||
onClick();
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<motion.div
|
||||
onClick={onClick}
|
||||
onKeyDown={handleKeyDown}
|
||||
role={onClick ? "button" : undefined}
|
||||
tabIndex={onClick ? 0 : undefined}
|
||||
aria-pressed={onClick ? selected : undefined}
|
||||
aria-label={label}
|
||||
initial={false}
|
||||
animate={{
|
||||
boxShadow: selected ? "var(--df-glow-pink)" : "var(--df-shadow-sm)",
|
||||
}}
|
||||
whileHover={onClick ? { y: -3, boxShadow: "var(--df-shadow-md)" } : undefined}
|
||||
transition={{ type: "spring", stiffness: 400, damping: 32 }}
|
||||
style={{
|
||||
position: "relative",
|
||||
borderRadius: "var(--df-radius-md)",
|
||||
overflow: "hidden",
|
||||
background: "var(--df-surface-1)",
|
||||
border: `1px solid ${selected ? "var(--df-pink)" : "var(--df-border)"}`,
|
||||
cursor: onClick ? "pointer" : "default",
|
||||
minHeight: 140,
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
justifyContent: "flex-end",
|
||||
padding: 24,
|
||||
}}
|
||||
>
|
||||
{showCover && (
|
||||
<>
|
||||
<img
|
||||
src={coverUrl}
|
||||
alt=""
|
||||
aria-hidden
|
||||
onError={() => setCoverFailed(true)}
|
||||
style={{
|
||||
position: "absolute",
|
||||
inset: 0,
|
||||
width: "100%",
|
||||
height: "100%",
|
||||
objectFit: "cover",
|
||||
zIndex: 0,
|
||||
}}
|
||||
/>
|
||||
<div
|
||||
style={{
|
||||
position: "absolute",
|
||||
inset: 0,
|
||||
background:
|
||||
"linear-gradient(180deg, rgba(23,26,28,0.15) 0%, rgba(23,26,28,0.95) 85%)",
|
||||
zIndex: 0,
|
||||
}}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
<div style={{ position: "relative", zIndex: 1 }}>{children}</div>
|
||||
</motion.div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
// Two-thumb range slider (e.g. min/max star rating) built from two overlapping native <input type="range"> elements sharing one visual track — no drag-and-drop implementation needed, fully keyboard-operable for free.
|
||||
import { useId } from "react";
|
||||
|
||||
export interface DualRangeSliderProps {
|
||||
min: number;
|
||||
max: number;
|
||||
step?: number;
|
||||
valueMin: number;
|
||||
valueMax: number;
|
||||
onChange: (min: number, max: number) => void;
|
||||
formatValue?: (v: number) => string;
|
||||
label: string;
|
||||
}
|
||||
|
||||
export function DualRangeSlider({
|
||||
min,
|
||||
max,
|
||||
step = 0.1,
|
||||
valueMin,
|
||||
valueMax,
|
||||
onChange,
|
||||
formatValue = (v) => v.toFixed(1),
|
||||
label,
|
||||
}: DualRangeSliderProps) {
|
||||
const id = useId();
|
||||
const pct = (v: number) => ((v - min) / (max - min)) * 100;
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div
|
||||
style={{
|
||||
display: "flex",
|
||||
justifyContent: "space-between",
|
||||
fontSize: 13,
|
||||
marginBottom: 8,
|
||||
color: "var(--df-text-muted)",
|
||||
}}
|
||||
>
|
||||
<span>{label}</span>
|
||||
<span style={{ color: "var(--df-text)", fontWeight: 600 }}>
|
||||
{formatValue(valueMin)} – {formatValue(valueMax)}
|
||||
</span>
|
||||
</div>
|
||||
<div style={{ position: "relative", height: 24 }}>
|
||||
<div
|
||||
style={{
|
||||
position: "absolute",
|
||||
top: 10,
|
||||
left: 0,
|
||||
right: 0,
|
||||
height: 4,
|
||||
borderRadius: 2,
|
||||
background: "var(--df-surface-3)",
|
||||
}}
|
||||
/>
|
||||
<div
|
||||
style={{
|
||||
position: "absolute",
|
||||
top: 10,
|
||||
height: 4,
|
||||
borderRadius: 2,
|
||||
background: "var(--df-pink)",
|
||||
left: `${pct(valueMin)}%`,
|
||||
right: `${100 - pct(valueMax)}%`,
|
||||
}}
|
||||
/>
|
||||
<input
|
||||
id={`${id}-min`}
|
||||
type="range"
|
||||
min={min}
|
||||
max={max}
|
||||
step={step}
|
||||
value={valueMin}
|
||||
aria-label={`${label} minimum`}
|
||||
onChange={(e) => onChange(Math.min(Number(e.target.value), valueMax), valueMax)}
|
||||
className="df-range-thumb"
|
||||
style={{ zIndex: valueMin > max - (max - min) / 2 ? 2 : 1 }}
|
||||
/>
|
||||
<input
|
||||
id={`${id}-max`}
|
||||
type="range"
|
||||
min={min}
|
||||
max={max}
|
||||
step={step}
|
||||
value={valueMax}
|
||||
aria-label={`${label} maximum`}
|
||||
onChange={(e) => onChange(valueMin, Math.max(Number(e.target.value), valueMin))}
|
||||
className="df-range-thumb"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
// Icon: resolves a name+tone to a URL via a swappable resolver. Default is a
|
||||
// root-relative `/icons/<tone>/<name>.svg` path, correct for anything served
|
||||
// over http(s) with its own public/ folder at the origin root (e.g. the
|
||||
// Next.js site) — but wrong for a file:// window, where a root slash
|
||||
// resolves against the filesystem drive root, not the app's own folder.
|
||||
// Apps loaded via file:// (Electron's packaged build) override this with
|
||||
// IconProvider and real bundled asset URLs; see
|
||||
// apps/desktop/src/renderer/src/icon-map.ts for that resolver.
|
||||
import { createContext, useContext, type ReactNode } from "react";
|
||||
|
||||
export type IconTone = "muted" | "pink" | "light" | "dark";
|
||||
|
||||
export interface IconProps {
|
||||
name: string;
|
||||
tone?: IconTone;
|
||||
size?: number;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
type IconResolver = (name: string, tone: IconTone) => string;
|
||||
|
||||
const defaultResolver: IconResolver = (name, tone) => `/icons/${tone}/${name}.svg`;
|
||||
|
||||
const IconResolverContext = createContext<IconResolver>(defaultResolver);
|
||||
|
||||
export function IconProvider({
|
||||
resolve,
|
||||
children,
|
||||
}: {
|
||||
resolve: IconResolver;
|
||||
children: ReactNode;
|
||||
}) {
|
||||
return (
|
||||
<IconResolverContext.Provider value={resolve}>{children}</IconResolverContext.Provider>
|
||||
);
|
||||
}
|
||||
|
||||
export function Icon({ name, tone = "muted", size = 18, className }: IconProps) {
|
||||
const resolve = useContext(IconResolverContext);
|
||||
return (
|
||||
<img
|
||||
src={resolve(name, tone)}
|
||||
alt=""
|
||||
aria-hidden
|
||||
width={size}
|
||||
height={size}
|
||||
className={className}
|
||||
style={{ display: "block" }}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
import type { RankedStatus } from "@directify/shared";
|
||||
|
||||
// Mirrors osu!'s own status colors (extracted live from osu.ppy.sh — see
|
||||
// /.tastemaker/style-lock.md) rather than inventing a new status palette.
|
||||
const STATUS_COLOR: Record<RankedStatus, string> = {
|
||||
ranked: "var(--df-lime)",
|
||||
approved: "var(--df-lime)",
|
||||
qualified: "var(--df-blue)",
|
||||
pending: "var(--df-blue)",
|
||||
loved: "var(--df-pink)",
|
||||
wip: "var(--df-text-muted)",
|
||||
graveyard: "var(--df-text-muted)",
|
||||
unknown: "var(--df-text-muted)",
|
||||
};
|
||||
|
||||
export function StatusBadge({ status }: { status: RankedStatus }) {
|
||||
const color = STATUS_COLOR[status];
|
||||
return (
|
||||
<span
|
||||
style={{
|
||||
display: "inline-flex",
|
||||
alignItems: "center",
|
||||
gap: 6,
|
||||
padding: "3px 8px",
|
||||
borderRadius: 999,
|
||||
fontSize: 11,
|
||||
fontWeight: 700,
|
||||
letterSpacing: 0.3,
|
||||
textTransform: "uppercase",
|
||||
color: "var(--df-on-fill)",
|
||||
background: color,
|
||||
}}
|
||||
>
|
||||
{status}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import type { InputHTMLAttributes } from "react";
|
||||
|
||||
export function TextInput({ style, ...rest }: InputHTMLAttributes<HTMLInputElement>) {
|
||||
return (
|
||||
<input
|
||||
style={{
|
||||
padding: "10px 12px",
|
||||
borderRadius: "var(--df-radius-sm)",
|
||||
border: "1px solid var(--df-border)",
|
||||
background: "var(--df-surface-2)",
|
||||
color: "var(--df-text)",
|
||||
fontSize: 14,
|
||||
fontFamily: "inherit",
|
||||
outline: "none",
|
||||
...style,
|
||||
}}
|
||||
{...rest}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
export * from "./Button";
|
||||
export * from "./Card";
|
||||
export * from "./DualRangeSlider";
|
||||
export * from "./Icon";
|
||||
export * from "./StatusBadge";
|
||||
export * from "./TextInput";
|
||||
import "./theme.css";
|
||||
@@ -0,0 +1,155 @@
|
||||
/*
|
||||
* Design tokens for both apps. Dark palette grounded in osu.ppy.sh's own
|
||||
* rendered styles (getComputedStyle, 2026-09-17); light palette is a
|
||||
* from-scratch WCAG-checked counterpart (osu! itself has no light mode to
|
||||
* ground against). Font is Roboto — "Google Sans" (used on the logo) is
|
||||
* Google-internal and not redistributable, Roboto is the real open-source
|
||||
* font it derives its character from. Full extraction, contrast matrix, and
|
||||
* rationale in /.tastemaker/style-lock.md.
|
||||
*/
|
||||
:root,
|
||||
:root[data-theme="dark"] {
|
||||
--df-bg: #171a1c;
|
||||
--df-surface-1: #22282a;
|
||||
--df-surface-2: #2e3538;
|
||||
--df-surface-3: #394246;
|
||||
--df-surface-4: #454f54;
|
||||
--df-border: #394246;
|
||||
|
||||
--df-bg-elevated: var(--df-surface-1);
|
||||
--df-bg-elevated-2: var(--df-surface-2);
|
||||
|
||||
--df-text: #f4f2f7;
|
||||
--df-text-muted: #9ca3a8;
|
||||
|
||||
--df-pink: #ff66ab;
|
||||
--df-blue: #66ccff;
|
||||
--df-lime: #b3ff66;
|
||||
--df-on-fill: #171a1c;
|
||||
|
||||
--df-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4), 0 1px 1px rgba(0, 0, 0, 0.3);
|
||||
--df-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.45), 0 2px 4px rgba(0, 0, 0, 0.3);
|
||||
--df-shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.5), 0 4px 10px rgba(0, 0, 0, 0.35);
|
||||
--df-glow-pink: 0 0 0 1px rgba(255, 102, 171, 0.3), 0 8px 24px rgba(255, 102, 171, 0.18);
|
||||
--df-glow-blue: 0 0 0 1px rgba(102, 204, 255, 0.3), 0 8px 24px rgba(102, 204, 255, 0.18);
|
||||
|
||||
--df-glass-bg: rgba(34, 40, 42, 0.72);
|
||||
--df-glass-blur: blur(14px) saturate(140%);
|
||||
}
|
||||
|
||||
:root[data-theme="light"] {
|
||||
--df-bg: #f4f5f6;
|
||||
--df-surface-1: #ffffff;
|
||||
--df-surface-2: #eceeef;
|
||||
--df-surface-3: #dde0e2;
|
||||
--df-surface-4: #c7cbce;
|
||||
--df-border: #dde0e2;
|
||||
|
||||
--df-bg-elevated: var(--df-surface-1);
|
||||
--df-bg-elevated-2: var(--df-surface-2);
|
||||
|
||||
--df-text: #171a1c;
|
||||
--df-text-muted: #5b6367;
|
||||
|
||||
--df-pink: #c41f6b;
|
||||
--df-blue: #0972a8;
|
||||
--df-lime: #4f7a1a;
|
||||
--df-on-fill: #ffffff;
|
||||
|
||||
--df-shadow-sm: 0 1px 2px rgba(23, 26, 28, 0.08), 0 1px 1px rgba(23, 26, 28, 0.06);
|
||||
--df-shadow-md: 0 4px 12px rgba(23, 26, 28, 0.1), 0 2px 4px rgba(23, 26, 28, 0.06);
|
||||
--df-shadow-lg: 0 16px 40px rgba(23, 26, 28, 0.14), 0 4px 10px rgba(23, 26, 28, 0.08);
|
||||
--df-glow-pink: 0 0 0 1px rgba(196, 31, 107, 0.25), 0 8px 24px rgba(196, 31, 107, 0.12);
|
||||
--df-glow-blue: 0 0 0 1px rgba(9, 114, 168, 0.25), 0 8px 24px rgba(9, 114, 168, 0.12);
|
||||
|
||||
--df-glass-bg: rgba(255, 255, 255, 0.72);
|
||||
--df-glass-blur: blur(14px) saturate(140%);
|
||||
}
|
||||
|
||||
:root {
|
||||
--df-radius-sm: 8px;
|
||||
--df-radius-md: 10px;
|
||||
--df-radius-lg: 16px;
|
||||
--df-font: "Roboto", "Segoe UI", system-ui, sans-serif;
|
||||
}
|
||||
|
||||
:root[data-reduce-motion="true"] *,
|
||||
:root[data-reduce-motion="true"] *::before,
|
||||
:root[data-reduce-motion="true"] *::after {
|
||||
animation-duration: 0.001ms !important;
|
||||
animation-iteration-count: 1 !important;
|
||||
transition-duration: 0.001ms !important;
|
||||
scroll-behavior: auto !important;
|
||||
}
|
||||
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
background: radial-gradient(circle at 20% -10%, color-mix(in srgb, var(--df-pink) 8%, transparent), transparent 45%),
|
||||
radial-gradient(circle at 100% 0%, color-mix(in srgb, var(--df-blue) 8%, transparent), transparent 40%),
|
||||
var(--df-bg);
|
||||
color: var(--df-text);
|
||||
font-family: var(--df-font);
|
||||
transition: background-color 0.2s ease, color 0.2s ease;
|
||||
}
|
||||
|
||||
:focus-visible {
|
||||
outline: 2px solid var(--df-blue);
|
||||
outline-offset: 2px;
|
||||
border-radius: var(--df-radius-sm);
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
*,
|
||||
*::before,
|
||||
*::after {
|
||||
animation-duration: 0.001ms !important;
|
||||
animation-iteration-count: 1 !important;
|
||||
transition-duration: 0.001ms !important;
|
||||
scroll-behavior: auto !important;
|
||||
}
|
||||
}
|
||||
|
||||
.df-range-thumb {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
margin: 0;
|
||||
background: none;
|
||||
pointer-events: none;
|
||||
appearance: none;
|
||||
-webkit-appearance: none;
|
||||
}
|
||||
|
||||
.df-range-thumb::-webkit-slider-thumb {
|
||||
appearance: none;
|
||||
-webkit-appearance: none;
|
||||
pointer-events: auto;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
border-radius: 50%;
|
||||
background: var(--df-pink);
|
||||
border: 2px solid var(--df-on-fill);
|
||||
box-shadow: var(--df-shadow-sm);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.df-range-thumb::-moz-range-thumb {
|
||||
pointer-events: auto;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
border-radius: 50%;
|
||||
background: var(--df-pink);
|
||||
border: 2px solid var(--df-on-fill);
|
||||
box-shadow: var(--df-shadow-sm);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.df-range-thumb::-webkit-slider-runnable-track,
|
||||
.df-range-thumb::-moz-range-track {
|
||||
background: transparent;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "dist",
|
||||
"rootDir": "src",
|
||||
"jsx": "react-jsx",
|
||||
"lib": ["ES2022", "DOM"]
|
||||
},
|
||||
"include": ["src"]
|
||||
}
|
||||
Reference in New Issue
Block a user