Commit 449a177
authored
feat: adaptive background detection for dark mode support (#23)
* feat: adaptive background detection for dark mode support
Replace hardcoded white (255,255,255) background assumption in content
detection with auto-detection from image perimeter pixels.
Two strategies, chosen automatically:
- Alpha-only: transparent PNGs skip color-distance filtering entirely
- Perimeter sampling: opaque images infer background via quantized
color bucketing of edge pixels
Adds backgroundColor prop as explicit override fallback.
* fix: revert corner-first optimization, restore full perimeter scan
The corner-first fast path misidentified logo content as background
when logos extended to the corners, causing sizing regressions.
Restores the first commit's logic (full perimeter scan, alphaOnly for
transparent images) with typed arrays instead of Map for bucketing.
* feat: add dark mode stories, test logos, shared story controls
- Inverted SVGs (transparent, light content) and JPG test logos
- Dark Mode, JPG, and Comparison stories under LogoSoup group
- Shared StoryLogoSoup wrapper with debug controls
- Consolidated argTypes, defaults, and types in shared.tsx
- alphaOnly path for transparent images, color distance for opaque
- min(a, sqrt(distSq)) opacity for opaque density normalization
* fix: story sidebar ordering by renaming DarkMode story file
* feat: accept CSS color strings for backgroundColor prop
BackgroundColor type accepts hex, rgb(), hsl(), named colors, or
[r, g, b] tuples. CSS strings are resolved via a 1×1 canvas.1 parent 1b88111 commit 449a177
File tree
139 files changed
+1621
-373
lines changed- .storybook
- scripts
- src
- components
- hooks
- utils
- static
- logos-inverted
- logos-jpg
- stories
- tests
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
139 files changed
+1621
-373
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
12 | 21 | | |
13 | 22 | | |
14 | 23 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
| |||
42 | 43 | | |
43 | 44 | | |
44 | 45 | | |
| 46 | + | |
45 | 47 | | |
46 | 48 | | |
47 | 49 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| |||
91 | 92 | | |
92 | 93 | | |
93 | 94 | | |
| 95 | + | |
94 | 96 | | |
95 | 97 | | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
96 | 106 | | |
97 | 107 | | |
98 | 108 | | |
| |||
105 | 115 | | |
106 | 116 | | |
107 | 117 | | |
| 118 | + | |
108 | 119 | | |
109 | 120 | | |
110 | 121 | | |
| |||
120 | 131 | | |
121 | 132 | | |
122 | 133 | | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
123 | 139 | | |
124 | 140 | | |
125 | | - | |
| 141 | + | |
| 142 | + | |
126 | 143 | | |
127 | 144 | | |
128 | | - | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
129 | 150 | | |
130 | 151 | | |
131 | 152 | | |
| |||
178 | 199 | | |
179 | 200 | | |
180 | 201 | | |
| 202 | + | |
181 | 203 | | |
182 | 204 | | |
183 | 205 | | |
| |||
244 | 266 | | |
245 | 267 | | |
246 | 268 | | |
| 269 | + | |
247 | 270 | | |
248 | 271 | | |
249 | 272 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
3 | 10 | | |
4 | 11 | | |
5 | 12 | | |
| |||
65 | 72 | | |
66 | 73 | | |
67 | 74 | | |
| 75 | + | |
68 | 76 | | |
69 | 77 | | |
70 | 78 | | |
| |||
82 | 90 | | |
83 | 91 | | |
84 | 92 | | |
| 93 | + | |
85 | 94 | | |
86 | 95 | | |
87 | 96 | | |
| |||
0 commit comments