Skip to content

Commit a6732f9

Browse files
committed
test: B1
1 parent 44d9c1d commit a6732f9

File tree

3 files changed

+114
-1
lines changed

3 files changed

+114
-1
lines changed

docs/evaluation/HUMAN_EVALUATION.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
| Test | Prompt | State | Was the response helpful? | Was the response Accurate? (1-5) | What was missing? | Token cost / Credits Used | Response time | Notes | Response |
2121
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
2222
| B1 | Create a dev page for the badge component using app context to control color | without AGENTS.MD | | | | | | | |
23-
| | | with AGENTS.md | | | | | | | |
23+
| | | with AGENTS.md | Yes | 5 || 4.77 | 1m 22s | Claude Opus 4.6. Working solution, uses SimplePage template, typed AppContext, all 9 color options. Read ~8 files to match conventions. | [response](responses/with/B1.md) |
2424
| B2 | Write a style API for the token component | without AGENTS.MD | | | | | | | |
2525
| | | with AGENTS.md | | | | | | | |
2626
| B3 | Add a size prop to badge component | without AGENTS.MD | | | | | | | |
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# B1 — Create a dev page for the badge component using app context to control color
2+
3+
```tsx
4+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
5+
// SPDX-License-Identifier: Apache-2.0
6+
import React, { useContext } from 'react';
7+
8+
import Badge, { BadgeProps } from '~components/badge';
9+
import FormField from '~components/form-field';
10+
import Select from '~components/select';
11+
import SpaceBetween from '~components/space-between';
12+
13+
import AppContext, { AppContextType } from '../app/app-context';
14+
import { SimplePage } from '../app/templates';
15+
16+
type PageContext = React.Context<AppContextType<{ color: BadgeProps['color'] }>>;
17+
18+
const colorOptions: Array<{ value: NonNullable<BadgeProps['color']>; label: string }> = [
19+
{ value: 'grey', label: 'Grey' },
20+
{ value: 'blue', label: 'Blue' },
21+
{ value: 'green', label: 'Green' },
22+
{ value: 'red', label: 'Red' },
23+
{ value: 'severity-critical', label: 'Severity critical' },
24+
{ value: 'severity-high', label: 'Severity high' },
25+
{ value: 'severity-medium', label: 'Severity medium' },
26+
{ value: 'severity-low', label: 'Severity low' },
27+
{ value: 'severity-neutral', label: 'Severity neutral' },
28+
];
29+
30+
export default function BadgeAppContext() {
31+
const { urlParams, setUrlParams } = useContext(AppContext as PageContext);
32+
const color = urlParams.color ?? 'grey';
33+
34+
return (
35+
<SimplePage
36+
title="Badge - App Context"
37+
screenshotArea={{}}
38+
settings={
39+
<FormField label="Color">
40+
<Select
41+
selectedOption={colorOptions.find(o => o.value === color) ?? colorOptions[0]}
42+
options={colorOptions}
43+
onChange={({ detail }) => setUrlParams({ color: detail.selectedOption.value as BadgeProps['color'] })}
44+
/>
45+
</FormField>
46+
}
47+
>
48+
<SpaceBetween direction="horizontal" size="m">
49+
<Badge color={color}>Badge</Badge>
50+
<Badge color={color}>Status: Active</Badge>
51+
<Badge color={color}>42</Badge>
52+
</SpaceBetween>
53+
</SimplePage>
54+
);
55+
}
56+
```
57+
58+
---
59+
60+
*Files read: ~8 (badge/interfaces.ts, badge/index.tsx, badge/permutations.page.tsx, badge/style-custom-types.page.tsx, tooltip/simple.page.tsx, app/app-context.tsx, app/templates.tsx, grep for AppContext usage)*
61+
*Credits: 4.77 · Time: 1m 22s*

pages/badge/app-context.page.tsx

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
import React, { useContext } from 'react';
4+
5+
import Badge, { BadgeProps } from '~components/badge';
6+
import FormField from '~components/form-field';
7+
import Select from '~components/select';
8+
import SpaceBetween from '~components/space-between';
9+
10+
import AppContext, { AppContextType } from '../app/app-context';
11+
import { SimplePage } from '../app/templates';
12+
13+
type PageContext = React.Context<AppContextType<{ color: BadgeProps['color'] }>>;
14+
15+
const colorOptions: Array<{ value: NonNullable<BadgeProps['color']>; label: string }> = [
16+
{ value: 'grey', label: 'Grey' },
17+
{ value: 'blue', label: 'Blue' },
18+
{ value: 'green', label: 'Green' },
19+
{ value: 'red', label: 'Red' },
20+
{ value: 'severity-critical', label: 'Severity critical' },
21+
{ value: 'severity-high', label: 'Severity high' },
22+
{ value: 'severity-medium', label: 'Severity medium' },
23+
{ value: 'severity-low', label: 'Severity low' },
24+
{ value: 'severity-neutral', label: 'Severity neutral' },
25+
];
26+
27+
export default function BadgeAppContext() {
28+
const { urlParams, setUrlParams } = useContext(AppContext as PageContext);
29+
const color = urlParams.color ?? 'grey';
30+
31+
return (
32+
<SimplePage
33+
title="Badge - App Context"
34+
screenshotArea={{}}
35+
settings={
36+
<FormField label="Color">
37+
<Select
38+
selectedOption={colorOptions.find(o => o.value === color) ?? colorOptions[0]}
39+
options={colorOptions}
40+
onChange={({ detail }) => setUrlParams({ color: detail.selectedOption.value as BadgeProps['color'] })}
41+
/>
42+
</FormField>
43+
}
44+
>
45+
<SpaceBetween direction="horizontal" size="m">
46+
<Badge color={color}>Badge</Badge>
47+
<Badge color={color}>Status: Active</Badge>
48+
<Badge color={color}>42</Badge>
49+
</SpaceBetween>
50+
</SimplePage>
51+
);
52+
}

0 commit comments

Comments
 (0)