-
Notifications
You must be signed in to change notification settings - Fork 0
feat(web): pixel drop-shadow follows node variant + cycles per multi-data pixel #60
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
8b2fc02
feat(web): pixel drop-shadow follows node variant + cycles per multi-…
b7f792d
feat(web): apply hue-rotate sprite filter so multi-data carrots are v…
8e3acf6
fix(web): move multi-data hue-rotate to the <img> so the carrot itsel…
40ba900
fix(web): widen multi-data stagger so distinct hues separate visually
91af711
feat(web): cycle palette across all carrots in a step (multi-data + b…
2df4b6e
feat(web): drop yellow from the variant palette
5041029
refactor(web): tidy pixel-color path now that the actual rule is settled
2c90cff
fix(web): include dynamic create-step nodes in the pixel-color map
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| import { describe, expect, it } from 'vitest' | ||
| import { | ||
| VARIANT_ACCENT, | ||
| assignNodeVariants, | ||
| resolvePixelStyle, | ||
| stepPixelColor, | ||
| stepPixelFilter, | ||
| } from '../src/lib/pixel-palette' | ||
|
|
||
| describe('assignNodeVariants', () => { | ||
| it('gives the first node of each independent type the original (orange) accent', () => { | ||
| const variants = assignNodeVariants([ | ||
| { id: 'api', type: 'endpoint' }, | ||
| { id: 'db', type: 'database' }, | ||
| ]) | ||
| expect(variants.get('api')?.color).toBe(VARIANT_ACCENT[0]) | ||
| expect(variants.get('db')?.color).toBe(VARIANT_ACCENT[0]) | ||
| }) | ||
|
|
||
| it('cycles successive same-type-pool nodes through the palette', () => { | ||
| const variants = assignNodeVariants([ | ||
| { id: 'svc-a', type: 'service' }, | ||
| { id: 'svc-b', type: 'service' }, | ||
| { id: 'svc-c', type: 'service' }, | ||
| ]) | ||
| expect(variants.get('svc-a')?.color).toBe(VARIANT_ACCENT[0]) | ||
| expect(variants.get('svc-b')?.color).toBe(VARIANT_ACCENT[1]) | ||
| expect(variants.get('svc-c')?.color).toBe(VARIANT_ACCENT[2]) | ||
| }) | ||
|
|
||
| it('shares a counter between service and custom (they fall back to the same sprite)', () => { | ||
| const variants = assignNodeVariants([ | ||
| { id: 'svc', type: 'service' }, | ||
| { id: 'cust', type: 'custom' }, | ||
| ]) | ||
| expect(variants.get('svc')?.color).toBe(VARIANT_ACCENT[0]) | ||
| expect(variants.get('cust')?.color).toBe(VARIANT_ACCENT[1]) | ||
| }) | ||
|
|
||
| it('first variant has no filter, subsequent variants get a hue-rotate filter', () => { | ||
| const variants = assignNodeVariants([ | ||
| { id: 'a', type: 'service' }, | ||
| { id: 'b', type: 'service' }, | ||
| ]) | ||
| expect(variants.get('a')?.filter).toBeUndefined() | ||
| expect(variants.get('b')?.filter).toBeTruthy() | ||
| }) | ||
| }) | ||
|
|
||
| describe('stepPixelColor', () => { | ||
| it('returns palette[index] and wraps around at the end', () => { | ||
| expect(stepPixelColor(0)).toBe(VARIANT_ACCENT[0]) | ||
| expect(stepPixelColor(1)).toBe(VARIANT_ACCENT[1]) | ||
| expect(stepPixelColor(VARIANT_ACCENT.length)).toBe(VARIANT_ACCENT[0]) | ||
| }) | ||
| }) | ||
|
|
||
| describe('stepPixelFilter', () => { | ||
| it('returns undefined for index 0 (the original orange sprite, no filter)', () => { | ||
| expect(stepPixelFilter(0)).toBeUndefined() | ||
| }) | ||
|
|
||
| it('returns a hue-rotate filter for subsequent indices', () => { | ||
| expect(stepPixelFilter(1)).toMatch(/hue-rotate/) | ||
| expect(stepPixelFilter(2)).toMatch(/hue-rotate/) | ||
| }) | ||
| }) | ||
|
|
||
| describe('resolvePixelStyle', () => { | ||
| it('cycles palette per pixel when the step has 2+ carrots and no explicit data color', () => { | ||
| expect(resolvePixelStyle(true, 0)).toEqual({ | ||
| pixelColor: VARIANT_ACCENT[0], | ||
| pixelFilter: undefined, | ||
| }) | ||
| expect(resolvePixelStyle(true, 1).pixelColor).toBe(VARIANT_ACCENT[1]) | ||
| expect(resolvePixelStyle(true, 1).pixelFilter).toMatch(/hue-rotate/) | ||
| }) | ||
|
|
||
| it('returns no overrides for single-carrot steps so DataPixel falls back to the variant color', () => { | ||
| expect(resolvePixelStyle(false, 0)).toEqual({ | ||
| pixelColor: undefined, | ||
| pixelFilter: undefined, | ||
| }) | ||
| }) | ||
|
|
||
| it('respects an explicit data.color and suppresses the sprite filter', () => { | ||
| expect(resolvePixelStyle(true, 1, '#123456')).toEqual({ | ||
| pixelColor: '#123456', | ||
| pixelFilter: undefined, | ||
| }) | ||
| }) | ||
| }) |
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.