Skip to content
This repository was archived by the owner on Apr 20, 2026. It is now read-only.

Commit 45f28bd

Browse files
jkrengeclaude
andauthored
feat: add alert appearance mode and new demo presets (#1)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent ea409e0 commit 45f28bd

6 files changed

Lines changed: 70 additions & 6 deletions

File tree

dev/index.html

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,20 @@ <h2 class="text-base font-semibold">Configuration</h2>
7474
>
7575
Shirt
7676
</button>
77+
<button
78+
class="text-xs font-semibold px-3 h-8 rounded-lg border border-navy-200 bg-navy-50 text-navy-500 hover:bg-navy-100 transition-colors cursor-pointer"
79+
data-sample="pants-large"
80+
type="button"
81+
>
82+
Pants (large)
83+
</button>
84+
<button
85+
class="text-xs font-semibold px-3 h-8 rounded-lg border border-navy-200 bg-navy-50 text-navy-500 hover:bg-navy-100 transition-colors cursor-pointer"
86+
data-sample="pants-small"
87+
type="button"
88+
>
89+
Pants (small)
90+
</button>
7791
</div>
7892
</div>
7993

@@ -119,6 +133,7 @@ <h2 class="text-base font-semibold">Configuration</h2>
119133
>
120134
<option value="neutral">Neutral</option>
121135
<option value="colored">Colored</option>
136+
<option value="alert">Alert</option>
122137
</select>
123138
</label>
124139

dev/main.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ const SAMPLE_REQUESTS = {
77
productId: '6792154579016',
88
accountId: '1619013',
99
},
10+
'pants-large': {
11+
productId: "Men's Pro 3L 3.0 Pants",
12+
accountId: '1617954',
13+
},
14+
'pants-small': {
15+
productId: "Men's Iver 5-Pocket Pants",
16+
accountId: '1617954',
17+
},
1018
};
1119

1220
const DEFAULT_SAMPLE = SAMPLE_REQUESTS.pants;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@parcellab/selection-guide-ui",
3-
"version": "0.1.5",
3+
"version": "0.1.6",
44
"description": "Embeddable size recommendation widget for retailer product detail pages. Displays fit guidance, confidence scores, and customer feedback summaries powered by the parcelLab Size Recommender API.",
55
"type": "module",
66
"license": "MIT",

src/config.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,11 @@ function parseAccountId(accountId: WidgetConfig['accountId']): number {
4040
function parseAppearance(
4141
appearance: WidgetConfig['appearance'],
4242
): AppearanceMode {
43-
return appearance === 'colored' ? 'colored' : 'neutral';
43+
if (appearance === 'colored' || appearance === 'alert') {
44+
return appearance;
45+
}
46+
47+
return 'neutral';
4448
}
4549

4650
function parseDensity(density: WidgetConfig['density']): DensityMode {
@@ -134,7 +138,7 @@ export function readConfigFromElement(
134138
config.apiBaseUrl = dataset.apiBaseUrl;
135139
}
136140

137-
if (dataset.appearance === 'colored' || dataset.appearance === 'neutral') {
141+
if (dataset.appearance === 'colored' || dataset.appearance === 'neutral' || dataset.appearance === 'alert') {
138142
config.appearance = dataset.appearance;
139143
}
140144

src/render.ts

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,42 @@ const STYLES = `
105105
}
106106
107107
.${ROOT_CLASS}--colored.${ROOT_CLASS}--fit-large {
108+
--plsr-accent: #4f7de2;
109+
--plsr-badge-background: #edf3ff;
110+
--plsr-badge-text: #37568a;
111+
--plsr-track-start: #e9ebef;
112+
--plsr-track: #e9ebef;
113+
--plsr-track-end: #dce8ff;
114+
}
115+
116+
.${ROOT_CLASS}--colored.${ROOT_CLASS}--fit-unknown {
117+
--plsr-accent: #6b6b6b;
118+
--plsr-badge-background: #efefef;
119+
--plsr-badge-text: #333333;
120+
--plsr-track-start: #e3e3e3;
121+
--plsr-track: #e3e3e3;
122+
--plsr-track-end: #e3e3e3;
123+
}
124+
125+
.${ROOT_CLASS}--alert.${ROOT_CLASS}--fit-small {
126+
--plsr-accent: #cf6868;
127+
--plsr-badge-background: #fdf0f0;
128+
--plsr-badge-text: #7a4040;
129+
--plsr-track-start: #f8dddd;
130+
--plsr-track: #f0e6e6;
131+
--plsr-track-end: #ececec;
132+
}
133+
134+
.${ROOT_CLASS}--alert.${ROOT_CLASS}--fit-true {
135+
--plsr-accent: #4c8b61;
136+
--plsr-badge-background: #edf7ef;
137+
--plsr-badge-text: #315743;
138+
--plsr-track-start: #e7ece8;
139+
--plsr-track: #dde6de;
140+
--plsr-track-end: #e7ece8;
141+
}
142+
143+
.${ROOT_CLASS}--alert.${ROOT_CLASS}--fit-large {
108144
--plsr-accent: #cf6868;
109145
--plsr-badge-background: #fdf0f0;
110146
--plsr-badge-text: #7a4040;
@@ -113,7 +149,7 @@ const STYLES = `
113149
--plsr-track-end: #f8dddd;
114150
}
115151
116-
.${ROOT_CLASS}--colored.${ROOT_CLASS}--fit-unknown {
152+
.${ROOT_CLASS}--alert.${ROOT_CLASS}--fit-unknown {
117153
--plsr-accent: #6b6b6b;
118154
--plsr-badge-background: #efefef;
119155
--plsr-badge-text: #333333;
@@ -191,7 +227,8 @@ const STYLES = `
191227
position: relative;
192228
}
193229
194-
.${ROOT_CLASS}--colored .${ROOT_CLASS}__track {
230+
.${ROOT_CLASS}--colored .${ROOT_CLASS}__track,
231+
.${ROOT_CLASS}--alert .${ROOT_CLASS}__track {
195232
background: linear-gradient(
196233
90deg,
197234
var(--plsr-track-start) 0%,

src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export type NotFoundMode = 'empty' | 'true-to-size';
44

55
export type FitCategory = 'small' | 'true' | 'large' | 'unknown';
66

7-
export type AppearanceMode = 'neutral' | 'colored';
7+
export type AppearanceMode = 'neutral' | 'colored' | 'alert';
88

99
export type DensityMode = 'compact' | 'comfortable';
1010

0 commit comments

Comments
 (0)