Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESIGN.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ A cool, nearly colorless shell with one working blue and six author lanes reserv
- **Author Lanes** (`lane-0` through `lane-5`, burnt orange, green, violet, teal, rose, ochre; each with a `-dark` lift): chosen by the user in Settings → Profile, otherwise assigned by hashing the user id (`User::automaticLane()`); every serialized user carries the effective `lane` (0–5) and the frontend paints it with `laneColor(user.lane)`. Used only for graph nodes, rail segments, the staged composer node, the 8px dot before a handle in profile contexts, and the 2px ring around a profile avatar. Never text, never fills behind text, never buttons.

### Tertiary
- **Rm Red** (`destructive`): delete affordances (trash icon on hover, inline confirm wash at 8% opacity, destructive button), "Unfollow" on hover, the composer counter at 0.
- **Rm Red** (`destructive`): delete affordances (trash icon on hover, inline confirm wash at 8% opacity, destructive button), "Unfollow" on hover, the composer counter at 0, and the border and warning status ("Hard to see", "Hard to see (WCAG)" or "Partly hard to see") on a guild icon preview.

### Neutral
- **Cool Shell** (`shell`): page background around the feed column and side columns; also the hole punched in each node.
Expand Down
6 changes: 5 additions & 1 deletion KNOWLEDGE_BASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,11 @@ Sources: [issue command UI](resources/js/components/issue-command.tsx), [issue v

### Guilds (preview)

Guilds are public groups around hashtags and are not generally available yet. In the preview, matching hashtags become small clickable guild labels; ordinary hashtags still open search. Create a guild from the Guilds overview or a hashtag's search page. From the overview, its display name determines the hashtag: “Laravel 4ever” becomes `#laravel4ever`. Display names and handles each allow up to 60 characters. When claiming a hashtag, the display name must match its letters, numbers and underscores, ignoring case; spaces, punctuation and decorative symbols are ignored, so `/dev/null` is valid for `#devnull`. Accents and underscores remain significant. Its creator joins automatically and maintains its display name, icon and description; a new display name must still match the hashtag, so `#adhd` can become “ADHD” but never another hashtag. Each person can create up to 100 guilds. A guild's name, description and icon pass the same automated moderation as commits before the guild is published or edited. When the moderation flags a new guild or an edit, it waits for an admin to review it instead: nothing of it is public until it is approved, the guild keeps its current details meanwhile, and a rejected submission is discarded. Submitting again for the same hashtag replaces the one still waiting, and new guilds waiting for review count toward the creation limit.
Guilds are public groups around hashtags and are not generally available yet. In the preview, matching hashtags become small clickable guild labels; ordinary hashtags still open search. Create a guild from the Guilds overview or a hashtag's search page. From the overview, its display name determines the hashtag: “Laravel 4ever” becomes `#laravel4ever`. Display names and handles each allow up to 60 characters. When claiming a hashtag, the display name must match its letters, numbers and underscores, ignoring case; spaces, punctuation and decorative symbols are ignored, so `/dev/null` is valid for `#devnull`. Accents and underscores remain significant. Its creator joins automatically and maintains its display name, icon and description; a new display name must still match the hashtag, so `#adhd` can become “ADHD” but never another hashtag. Each person can create up to 100 guilds.

A guild's icon is an emoji or an uploaded image. When you upload an image, or edit a guild that already has one, the image is previewed in light and dark mode, with a warning if all or part of it is hard to see in one mode, such as a dark logo on a transparent background in dark mode, so you can pick another image before saving. “Hard to see (WCAG)” means the image can be made out but falls short of the contrast that the Web Content Accessibility Guidelines ask of graphics. An image that fills its own square or circle, such as a photo or a logo on a colored square, brings its own background, so it is only flagged if it nearly disappears. A drop shadow on one side of a logo can also count as a part that is hard to see, since it fades into one of the two backgrounds; the warning is advice, and you can still save the image.

A guild's name, description and uploaded icon image (not an emoji) pass the same automated moderation as commits before the guild is published or edited. When the moderation flags a new guild or an edit, it waits for an admin to review it instead: nothing of it is public until it is approved, the guild keeps its current details meanwhile, and a rejected submission is discarded. Submitting again for the same hashtag replaces the one still waiting, and new guilds waiting for review count toward the creation limit.

The Guilds page lists groups by member count, with 24 guilds per page. Search matches keywords in guild names, handles, and descriptions, ignoring case; a leading `#` is optional. This directory search is keyword-based, not semantic. Click a guild's member count to browse its members: the moderator appears first, labeled “(moderator)”, followed by newest joins, with 50 people per page and Load more for the next page. Joining adds matching commits to Following without following every author and clears any existing mute. When a commit appears only because of a joined guild, it says “because you joined” beside the guild label. Leave a guild to reveal its Mute control. Muting hides matching commits from logs and search, including commits by followed authors. You can still open the guild or a commit directly.

Expand Down
8 changes: 6 additions & 2 deletions resources/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,9 @@
}
}

:root {
/* data-theme-scope gives an element the regular light or dark tokens, as in the guild icon preview. */
:root,
[data-theme-scope='light'] {
--background: #f6f7f8;
--foreground: #121417;
--card: #ffffff;
Expand Down Expand Up @@ -432,7 +434,9 @@
--sidebar-ring: var(--ring);
}

.dark {
/* data-theme-scope gives an element the regular light or dark tokens, as in the guild icon preview. */
.dark,
[data-theme-scope='dark'] {
--background: #111112;
--foreground: #ececec;
--card: #18181a;
Expand Down
41 changes: 40 additions & 1 deletion resources/js/components/guild-dialog.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import type { FormComponentRef } from '@inertiajs/core';
import { Form, router } from '@inertiajs/react';
import { LoaderCircle, Plus, Save } from 'lucide-react';
import { type ReactNode, useRef, useState } from 'react';
import { type ReactNode, useEffect, useRef, useState } from 'react';
import { store, update } from '@/actions/App/Http/Controllers/GuildController';
import { EmojiPickerButton } from '@/components/emoji-picker';
import { GuildIcon } from '@/components/guild-icon';
import { ImageContrastPreview } from '@/components/image-contrast-preview';
import InputError from '@/components/input-error';
import { Button } from '@/components/ui/button';
import {
Expand Down Expand Up @@ -36,7 +37,30 @@ export function GuildDialog({
const [emoji, setEmoji] = useState(guild?.emoji ?? '💻');
const [removeIcon, setRemoveIcon] = useState(false);
const [name, setName] = useState(guild?.name ?? handle ?? '');
const [preview, setPreview] = useState<string | null>(null);
const form = useRef<FormComponentRef>(null);

const previewUrl = useRef<string | null>(null);

function showPreview(file: File | null) {
if (previewUrl.current) {
URL.revokeObjectURL(previewUrl.current);
}
previewUrl.current = file ? URL.createObjectURL(file) : null;
setPreview(previewUrl.current);
}

useEffect(
() => () => {
if (previewUrl.current) {
URL.revokeObjectURL(previewUrl.current);
}
},
[],
);
// A new upload, or else the icon the guild has unless an emoji replaces it.
const previewSrc =
preview ?? (removeIcon ? null : (guild?.icon_url ?? null));
const nameHandle = name.replace(/[^\p{L}\p{M}\p{N}_]+/gu, '').toLowerCase();
const hashtag = guild?.handle ?? handle ?? nameHandle;

Expand All @@ -48,6 +72,7 @@ export function GuildDialog({
onCloseAutoFocus={() => {
setEmoji(guild?.emoji ?? '💻');
setRemoveIcon(false);
showPreview(null);
setName(guild?.name ?? handle ?? '');
}}
>
Expand Down Expand Up @@ -215,9 +240,23 @@ export function GuildDialog({
name="images[]"
type="file"
accept="image/jpeg,image/png,image/webp"
onChange={(event) =>
showPreview(
event.target.files?.[0] ?? null,
)
}
className={`${fieldClass} file:mr-3 file:text-sm`}
aria-describedby="guild-icon-help guild-icon-error"
/>
{previewSrc && (
// Guild icons show at 13–48px. The check runs near the small end, where they fade
// most; the tiles show 40px, the most common size.
<ImageContrastPreview
src={previewSrc}
label="Icon"
size={20}
/>
)}
<p
id="guild-icon-help"
className="text-xs text-muted-foreground"
Expand Down
134 changes: 134 additions & 0 deletions resources/js/components/image-contrast-preview.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
import { CircleAlert } from 'lucide-react';
import { useRef, useState } from 'react';
import { readPixels, visibility } from '@/lib/image-contrast';
import type { Visibility } from '@/lib/image-contrast';
import { cn } from '@/lib/utils';

const modes = [
{ theme: 'light', label: 'Light mode' },
{ theme: 'dark', label: 'Dark mode' },
] as const;

const statuses: Record<Visibility, string> = {
easy: 'Easy to see',
partly: 'Partly hard to see',
wcag: 'Hard to see (WCAG)',
hard: 'Hard to see',
};

/**
* Shows an image on the light and dark mode backgrounds and flags a mode where all or part of it is
* hard to see.
* `label` names the image for screen readers; `size` is the size, in pixels, it is shown at elsewhere,
* so the check sees it as people will. The image is shown and checked as a centered square, and only
* a same-origin (or CORS-enabled) `src` can be checked: another shows without a status.
*/
export function ImageContrastPreview({
src,
label = 'Image',
size,
}: {
src: string;
label?: string;
size: number;
}) {
return (
<div
className="@container grid grid-cols-2 gap-2"
data-test="image-contrast-preview"
role="group"
aria-label={`${label} preview in light and dark mode`}
>
{modes.map((mode) => (
// Keyed by the image, so a new one starts without a status.
<PreviewTile
key={`${mode.theme}-${src}`}
src={src}
size={size}
{...mode}
/>
))}
</div>
);
}

// data-theme-scope gives the tile its mode's regular tokens. Only var(--…) reads follow it:
// bg-muted-style utilities resolve at the root.
function PreviewTile({
src,
size,
theme,
label,
}: {
src: string;
size: number;
theme: 'light' | 'dark';
label: string;
}) {
const tile = useRef<HTMLDivElement>(null);
const [status, setStatus] = useState<Visibility | null>(null);
const warns = status !== null && status !== 'easy';

return (
<div
ref={tile}
data-theme-scope={theme}
aria-live="polite"
aria-atomic
// Stacks when narrow. A warning's border takes the page's red, which stands out from the page,
// and its inset ring the tile's, which stands out from the tile, without moving anything.
className={cn(
'flex flex-col items-start gap-2 rounded-md border border-(--border) bg-(--muted) p-3 text-(--foreground) @sm:flex-row @sm:items-center @sm:gap-3',
warns &&
'border-destructive shadow-[inset_0_0_0_1px_var(--destructive)]',
)}
>
<span className="inline-flex size-10 shrink-0 overflow-hidden rounded-sm">
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
<img
src={src}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
alt=""
className="size-full object-cover"
onLoad={(event) => {
let pixels;
try {
pixels = readPixels(event.currentTarget, size);
} catch {
// Pixels it can't read (another origin's, say) leave no status.
return;
}
setStatus(
visibility(
pixels,
getComputedStyle(tile.current!)
.getPropertyValue('--muted')
.trim(),
),
);
}}
/>
</span>
<span className="flex min-w-0 flex-col gap-0.5 text-xs">
<span>{label}</span>
<span
className={cn(
'flex min-h-4 items-start gap-1',
Comment thread
shanesmithdev marked this conversation as resolved.
Resolved
warns
? 'text-(--destructive)'
: 'text-(--muted-foreground)',
)}
>
{warns && (
<CircleAlert
aria-hidden
className="size-3.5 shrink-0 translate-y-px"
/>
)}
{/* Wraps beside the icon when the tile is narrow. */}
{status && (
<span className="text-balance">{statuses[status]}</span>
)}
</span>
</span>
</div>
);
}
Loading