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,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;
|
||||
}
|
||||
Reference in New Issue
Block a user