Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build-tools/utils/pluralize.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ const pluralizationMap = {
ProgressBar: 'ProgressBars',
PromptInput: 'PromptInputs',
PropertyFilter: 'PropertyFilters',
RadioButton: 'RadioButtons',
RadioGroup: 'RadioGroups',
S3ResourceSelector: 'S3ResourceSelectors',
SegmentedControl: 'SegmentedControls',
Expand Down
52 changes: 52 additions & 0 deletions pages/radio-button/common.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
import React from 'react';

import RadioButton, { RadioButtonProps } from '~components/radio-button';

import createPermutations from '../utils/permutations';

const shortText = 'Short text';

export const longText =
'Long text, long enough to wrap. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Whatever.';

type Permutation = Omit<RadioButtonProps, 'name'>;

export const permutations = createPermutations<Permutation>([
{
description: [undefined, shortText, longText],
children: [undefined, shortText, longText],
readOnly: [false, true],
disabled: [false, true],
checked: [true, false],
},
]);

export const RadioButtonPermutation = ({
children,
description,
readOnly,
disabled,
checked,
index,
}: Permutation & { index?: number }) => {
const commonProps = {
children,
description,
readOnly,
disabled,
checked,
name: `radio-group-${index}`,
};
if (children) {
return <RadioButton {...commonProps} />;
} else {
// If no visual label provided, add a label for screen readers
return (
<label aria-label={`Select ${index}`}>
<RadioButton {...commonProps} />
</label>
);
}
};
47 changes: 47 additions & 0 deletions pages/radio-button/custom-style.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
import { palette } from '../app/themes/style-api';

export default {
input: {
stroke: {
default: palette.neutral80,
disabled: palette.neutral100,
readOnly: palette.neutral90,
},
fill: {
checked: palette.teal80,
default: palette.neutral10,
disabled: palette.neutral60,
readOnly: palette.neutral40,
},
circle: {
fill: {
checked: palette.neutral10,
disabled: palette.neutral10,
readOnly: palette.neutral80,
},
},
focusRing: {
borderColor: palette.teal80,
borderRadius: '2px',
borderWidth: '1px',
},
},
label: {
color: {
checked: `light-dark(${palette.neutral100}, ${palette.neutral10})`,
default: `light-dark(${palette.neutral100}, ${palette.neutral10})`,
disabled: `light-dark(${palette.neutral80}, ${palette.neutral40})`,
readOnly: `light-dark(${palette.neutral80}, ${palette.neutral40})`,
},
},
description: {
color: {
checked: `light-dark(${palette.neutral100}, ${palette.neutral10})`,
default: `light-dark(${palette.neutral100}, ${palette.neutral10})`,
disabled: `light-dark(${palette.neutral80}, ${palette.neutral40})`,
readOnly: `light-dark(${palette.neutral80}, ${palette.neutral40})`,
},
},
};
23 changes: 23 additions & 0 deletions pages/radio-button/focus-test.page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
import React, { useState } from 'react';

import RadioButton from '~components/radio-button';

import FocusTarget from '../common/focus-target';
import ScreenshotArea from '../utils/screenshot-area';

export default function RadioButtonScenario() {
const [checked, setChecked] = useState(false);
return (
<article>
<h1>Radio buttons should be focused using the correct highlight</h1>
<FocusTarget />
<ScreenshotArea>
<RadioButton name="radio-button-group" checked={checked} onSelect={() => setChecked(true)}>
Radio button label
</RadioButton>
</ScreenshotArea>
</article>
);
}
18 changes: 18 additions & 0 deletions pages/radio-button/permutations.page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
import React from 'react';

import { SimplePage } from '../app/templates';
import PermutationsView from '../utils/permutations-view';
import { permutations, RadioButtonPermutation } from './common';

export default function RadioButtonPermutations() {
return (
<SimplePage title="RadioButton permutations" screenshotArea={{}}>
<PermutationsView
permutations={permutations}
render={(permutation, index) => <RadioButtonPermutation {...permutation} index={index} />}
/>
</SimplePage>
);
}
19 changes: 19 additions & 0 deletions pages/radio-button/style-custom.page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
import React from 'react';

import { SimplePage } from '../app/templates';
import PermutationsView from '../utils/permutations-view';
import { permutations, RadioButtonPermutation } from './common';
import customStyle from './custom-style';

export default function RadioButtonPermutations() {
return (
<SimplePage title="RadioButton permutations with custom styles" screenshotArea={{}}>
<PermutationsView
permutations={permutations}
render={(permutation, index) => <RadioButtonPermutation {...permutation} index={index} style={customStyle} />}
/>
</SimplePage>
);
}
19 changes: 19 additions & 0 deletions pages/radio-button/styles.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

@use '~design-tokens' as awsui;

.radio-group {
display: flex;
column-gap: awsui.$space-scaled-m;
row-gap: awsui.$space-scaled-xs;
&--horizontal {
flex-direction: row;
flex-wrap: wrap;
}
&--vertical {
flex-direction: column;
}
}
10 changes: 4 additions & 6 deletions pages/radio-group/common-permutations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import React from 'react';
import Link from '~components/link';
import { RadioGroupProps } from '~components/radio-group';

import { longText } from '../radio-button/common';
import createPermutations from '../utils/permutations';

const permutations = createPermutations<RadioGroupProps>([
Expand All @@ -19,15 +20,12 @@ const permutations = createPermutations<RadioGroupProps>([
[
{
value: 'first',
label:
'Long text, long enough to wrap. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Whatever.',
label: longText,
},
{
value: 'second',
label:
'Long text, long enough to wrap. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Whatever.',
description:
'Long text, long enough to wrap. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Whatever.',
label: longText,
description: longText,
},
],
],
Expand Down
52 changes: 4 additions & 48 deletions pages/radio-group/style-custom.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React from 'react';

import { RadioGroup, SpaceBetween } from '~components';

import { palette } from '../app/themes/style-api';
import customStyle from '../radio-button/custom-style';
import ScreenshotArea from '../utils/screenshot-area';

export default function CustomRadio() {
Expand All @@ -27,59 +27,15 @@ export default function CustomRadio() {
},
];

const style = {
input: {
stroke: {
default: palette.neutral80,
disabled: palette.neutral100,
readOnly: palette.neutral90,
},
fill: {
checked: palette.teal80,
default: palette.neutral10,
disabled: palette.neutral60,
readOnly: palette.neutral40,
},
circle: {
fill: {
checked: palette.neutral10,
disabled: palette.neutral10,
readOnly: palette.neutral80,
},
},
focusRing: {
borderColor: palette.teal80,
borderRadius: '2px',
borderWidth: '1px',
},
},
label: {
color: {
checked: `light-dark(${palette.neutral100}, ${palette.neutral10})`,
default: `light-dark(${palette.neutral100}, ${palette.neutral10})`,
disabled: `light-dark(${palette.neutral80}, ${palette.neutral40})`,
readOnly: `light-dark(${palette.neutral80}, ${palette.neutral40})`,
},
},
description: {
color: {
checked: `light-dark(${palette.neutral100}, ${palette.neutral10})`,
default: `light-dark(${palette.neutral100}, ${palette.neutral10})`,
disabled: `light-dark(${palette.neutral80}, ${palette.neutral40})`,
readOnly: `light-dark(${palette.neutral80}, ${palette.neutral40})`,
},
},
};

return (
<ScreenshotArea>
<h1>Custom Radio</h1>

<SpaceBetween size="m" direction="vertical">
<SpaceBetween size="m" direction="horizontal">
<RadioGroup value="first" items={items} style={style} data-testid="1" />
<RadioGroup value="second" items={items} style={style} />
<RadioGroup value="third" items={items} style={style} readOnly={true} />
<RadioGroup value="first" items={items} style={customStyle} data-testid="1" />
<RadioGroup value="second" items={items} style={customStyle} />
<RadioGroup value="third" items={items} style={customStyle} readOnly={true} />
</SpaceBetween>
</SpaceBetween>
</ScreenshotArea>
Expand Down
Loading
Loading