-
Notifications
You must be signed in to change notification settings - Fork 5k
feat(web): add project sidebar accents #7972
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 8 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
395fd98
feat(web): add project sidebar accents
msegec f2082f3
fix(web): keep project accents working in the mobile sheet and multi-…
msegec 46e9b70
feat(web): fade project accents in from the right
msegec 35c8bf5
fix(web): make accent fade replace hover and selected fills
msegec 5e08cf0
fix(web): keep the hover wash under the accent fade
msegec 9046a31
fix(web): stop thread info tooltips flashing on sidebar sweeps
msegec 1d1af96
fix(web): sidebar hover actions wait for the pointer to park
msegec 226dc14
perf(web): stabilize accent row paints
msegec 4f3e614
fix(server): acquire accent resolver from context
msegec 9c1bccd
feat(web): add active project accent color
msegec 4a19e83
test(server): update exact accent fixture
msegec 7ed3bf1
test(web): use Effect filesystem
msegec e6088fa
fix(web): retain accent row surface fills
msegec c4936fc
fix(web): align sidebar accent interactions
msegec 4992d0c
fix(web): align search row accent states
msegec 28666b3
docs(web): correct accent docs and liveness comments
msegec 7f380c9
fix(web): keep the highlighted search row on the strong row fill
msegec c5f18f0
Merge branch 'main' into feat/project-sidebar-accents
msegec File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| import type { ProjectAccent } from "@t3tools/contracts"; | ||
| import { it, describe, expect } from "@effect/vitest"; | ||
| import * as Effect from "effect/Effect"; | ||
|
|
||
| import * as ProjectAccents from "./ProjectAccents.ts"; | ||
| import * as ProjectFaviconResolver from "./ProjectFaviconResolver.ts"; | ||
|
|
||
| const resolverReturning = ( | ||
| accentByRoot: Readonly<Record<string, ProjectAccent>>, | ||
| ): ProjectFaviconResolver.ProjectFaviconResolver["Service"] => | ||
| ProjectFaviconResolver.ProjectFaviconResolver.of({ | ||
| resolvePath: () => Effect.succeed(null), | ||
| resolveAccent: (cwd) => Effect.succeed(accentByRoot[cwd] ?? null), | ||
| }); | ||
|
|
||
| const failingResolver: ProjectFaviconResolver.ProjectFaviconResolver["Service"] = | ||
| ProjectFaviconResolver.ProjectFaviconResolver.of({ | ||
| resolvePath: () => Effect.succeed(null), | ||
| resolveAccent: (cwd) => | ||
| Effect.fail( | ||
| new ProjectFaviconResolver.ProjectFaviconResolutionError({ | ||
| operation: "normalize-workspace", | ||
| workspaceRoot: cwd, | ||
| cause: new Error("unreadable checkout"), | ||
| }), | ||
| ), | ||
| }); | ||
|
|
||
| describe("ProjectAccents", () => { | ||
| it.effect("attaches each project's accent to the payload that creates its rows", () => | ||
| Effect.gen(function* () { | ||
| const projects = [ | ||
| { id: "a", workspaceRoot: "/repos/one" }, | ||
| { id: "b", workspaceRoot: "/repos/two" }, | ||
| { id: "c", workspaceRoot: "/repos/three" }, | ||
| ]; | ||
|
|
||
| const decorated = yield* ProjectAccents.withProjectAccents( | ||
| resolverReturning({ | ||
| "/repos/one": "#1688f0", | ||
| "/repos/two": { idle: "#071525", selected: "#173b60" }, | ||
| }), | ||
| projects, | ||
| ); | ||
|
|
||
| expect(decorated).toEqual([ | ||
| { id: "a", workspaceRoot: "/repos/one", accent: "#1688f0" }, | ||
| { | ||
| id: "b", | ||
| workspaceRoot: "/repos/two", | ||
| accent: { idle: "#071525", selected: "#173b60" }, | ||
| }, | ||
| // Written as an explicit null, never omitted: clearing accentColor in | ||
| // t3.json has to clear the row rather than leave the old value. | ||
| { id: "c", workspaceRoot: "/repos/three", accent: null }, | ||
| ]); | ||
| }), | ||
| ); | ||
|
|
||
| it.effect("keeps an unreadable checkout in the snapshot without an accent", () => | ||
| Effect.gen(function* () { | ||
| const decorated = yield* ProjectAccents.withProjectAccents(failingResolver, [ | ||
| { id: "a", workspaceRoot: "/repos/gone" }, | ||
| ]); | ||
|
|
||
| expect(decorated).toEqual([{ id: "a", workspaceRoot: "/repos/gone", accent: null }]); | ||
| }), | ||
| ); | ||
|
|
||
| it.effect("decorates a single project the same way", () => | ||
| Effect.gen(function* () { | ||
| const decorated = yield* ProjectAccents.withProjectAccent( | ||
| resolverReturning({ "/repos/one": "#1688f0" }), | ||
| { id: "a", workspaceRoot: "/repos/one" }, | ||
| ); | ||
|
|
||
| expect(decorated).toEqual({ id: "a", workspaceRoot: "/repos/one", accent: "#1688f0" }); | ||
| }), | ||
| ); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| /** | ||
| * ProjectAccents - decorates client-facing project payloads with the accent | ||
| * declared in each checkout's `t3.json`. | ||
| * | ||
| * The accent is read live rather than projected because `t3.json` is a | ||
| * checked-in file the user edits by hand; an event-sourced copy would go stale | ||
| * the moment someone pulls a branch. It rides on the project record instead of | ||
| * on the favicon asset URL so sidebar rows know their accent in the same paint | ||
| * that creates them. Fetching it separately repaints the whole list a round | ||
| * trip later, which reads as a flash. | ||
| * | ||
| * Callers pass the resolver rather than pulling it from context so decorating | ||
| * a payload never widens a handler's requirements. | ||
| * | ||
| * @module ProjectAccents | ||
| */ | ||
| import type { ProjectAccent } from "@t3tools/contracts"; | ||
| import * as Effect from "effect/Effect"; | ||
|
|
||
| import type * as ProjectFaviconResolver from "./ProjectFaviconResolver.ts"; | ||
|
|
||
| type Resolver = ProjectFaviconResolver.ProjectFaviconResolver["Service"]; | ||
|
|
||
| interface AccentTarget { | ||
| readonly workspaceRoot: string; | ||
| } | ||
|
|
||
| type WithAccent<T> = T & { readonly accent: ProjectAccent | null }; | ||
|
|
||
| /** | ||
| * A project whose checkout cannot be read still belongs in the payload, so an | ||
| * unreadable workspace resolves to "no accent" rather than failing the | ||
| * snapshot. The accent is always written, never omitted: clearing `accentColor` | ||
| * in `t3.json` has to clear the row, not leave the previous value in place. | ||
| */ | ||
| const resolveAccent = ( | ||
| resolver: Resolver, | ||
| workspaceRoot: string, | ||
| ): Effect.Effect<ProjectAccent | null> => | ||
| resolver.resolveAccent(workspaceRoot).pipe(Effect.orElseSucceed(() => null)); | ||
|
|
||
| /** Attach `accent` to one project record. */ | ||
| export const withProjectAccent = <T extends AccentTarget>( | ||
| resolver: Resolver, | ||
| project: T, | ||
| ): Effect.Effect<WithAccent<T>> => | ||
| resolveAccent(resolver, project.workspaceRoot).pipe( | ||
| Effect.map((accent) => ({ ...project, accent })), | ||
| ); | ||
|
|
||
| /** | ||
| * Attach `accent` to every project in a shell snapshot. | ||
| */ | ||
| export const withProjectAccents = <T extends AccentTarget>( | ||
| resolver: Resolver, | ||
| projects: ReadonlyArray<T>, | ||
| ): Effect.Effect<ReadonlyArray<WithAccent<T>>> => | ||
| Effect.forEach(projects, (project) => withProjectAccent(resolver, project), { | ||
| concurrency: 16, | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.