Skip to content

Commit 3056b94

Browse files
authored
revert: "feat: Implementation of the Badge component Style API (#3650)" (#3675)
1 parent 8fa9df2 commit 3056b94

File tree

9 files changed

+43
-252
lines changed

9 files changed

+43
-252
lines changed

pages/badge.page.tsx

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,43 @@
11
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
3-
export { default } from './badge/permutations.page';
3+
import * as React from 'react';
4+
5+
import Badge, { BadgeProps } from '~components/badge';
6+
7+
import createPermutations from './utils/permutations';
8+
import PermutationsView from './utils/permutations-view';
9+
import ScreenshotArea from './utils/screenshot-area';
10+
11+
const permutations = createPermutations<BadgeProps>([
12+
{
13+
color: [
14+
'blue',
15+
'grey',
16+
'green',
17+
'red',
18+
'severity-critical',
19+
'severity-high',
20+
'severity-medium',
21+
'severity-low',
22+
'severity-neutral',
23+
],
24+
children: [
25+
'ABC',
26+
'Badge With A Very Long Text',
27+
<>
28+
Badge with <strong>html</strong>
29+
</>,
30+
],
31+
},
32+
]);
33+
34+
export default function BadgePermutations() {
35+
return (
36+
<>
37+
<h1>Badge permutations</h1>
38+
<ScreenshotArea disableAnimations={true}>
39+
<PermutationsView permutations={permutations} render={permutation => <Badge {...permutation} />} />
40+
</ScreenshotArea>
41+
</>
42+
);
43+
}

pages/badge/permutations.page.tsx

Lines changed: 0 additions & 43 deletions
This file was deleted.

pages/badge/style-custom-types.page.tsx

Lines changed: 0 additions & 108 deletions
This file was deleted.

src/__tests__/snapshot-tests/__snapshots__/documenter.test.ts.snap

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2907,23 +2907,6 @@ use the \`id\` attribute, consider setting it on a parent element instead.",
29072907
"optional": true,
29082908
"type": "string",
29092909
},
2910-
{
2911-
"description": "Specifies an object of selectors and properties that are used to apply custom styles.
2912-
2913-
- \`root.background\` (string) - (Optional) Background for badge.
2914-
- \`root.borderColor\` (string) - (Optional) Border color for badge.
2915-
- \`root.borderRadius\` (string) - (Optional) Border radius style.
2916-
- \`root.borderWidth\` (string) - (Optional) Border width style.
2917-
- \`root.color\` (string) - (Optional) Text color for badge.
2918-
- \`root.paddingBlock\` (string) - (Optional) Block dimension padding.
2919-
- \`root.paddingInline\` (string) - (Optional) Inline dimension padding.",
2920-
"name": "style",
2921-
"optional": true,
2922-
"systemTags": [
2923-
"core",
2924-
],
2925-
"type": "BadgeProps.Style",
2926-
},
29272910
],
29282911
"regions": [
29292912
{

src/badge/__tests__/badge.test.tsx

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -57,31 +57,3 @@ describe('Badge', () => {
5757
expect(badge).toHaveClass(styles[`badge-color-grey`]);
5858
});
5959
});
60-
61-
describe('Style API', () => {
62-
test('all style properties', () => {
63-
const badge = renderBadge(
64-
<Badge
65-
style={{
66-
root: {
67-
background: 'rgb(255, 255, 255)',
68-
borderColor: 'rgb(0, 0, 0)',
69-
borderRadius: '8px',
70-
borderWidth: '2px',
71-
paddingBlock: '4px',
72-
paddingInline: '8px',
73-
},
74-
}}
75-
>
76-
Badge
77-
</Badge>
78-
);
79-
80-
expect(getComputedStyle(badge).getPropertyValue('background')).toBe('rgb(255, 255, 255)');
81-
expect(getComputedStyle(badge).getPropertyValue('border-color')).toBe('rgb(0, 0, 0)');
82-
expect(getComputedStyle(badge).getPropertyValue('border-radius')).toBe('8px');
83-
expect(getComputedStyle(badge).getPropertyValue('border-width')).toBe('2px');
84-
expect(getComputedStyle(badge).getPropertyValue('padding-block')).toBe('4px');
85-
expect(getComputedStyle(badge).getPropertyValue('padding-inline')).toBe('8px');
86-
});
87-
});

src/badge/index.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,19 @@ import { getBaseProps } from '../internal/base-component';
88
import useBaseComponent from '../internal/hooks/use-base-component';
99
import { applyDisplayName } from '../internal/utils/apply-display-name';
1010
import { BadgeProps } from './interfaces';
11-
import { getBadgeStyles } from './style';
1211

1312
import styles from './styles.css.js';
1413

1514
export { BadgeProps };
1615

17-
export default function Badge({ color = 'grey', children, style, ...rest }: BadgeProps) {
16+
export default function Badge({ color = 'grey', children, ...rest }: BadgeProps) {
1817
const { __internalRootRef } = useBaseComponent('Badge', { props: { color } });
1918
const baseProps = getBaseProps(rest);
2019

2120
const className = clsx(baseProps.className, styles.badge, styles[`badge-color-${color}`]);
2221

2322
return (
24-
<span {...baseProps} {...{ className }} ref={__internalRootRef} style={getBadgeStyles(style)}>
23+
<span {...baseProps} {...{ className }} ref={__internalRootRef}>
2524
{children}
2625
</span>
2726
);

src/badge/interfaces.ts

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -23,32 +23,4 @@ export interface BadgeProps extends BaseComponentProps {
2323
* Text displayed inside the badge.
2424
*/
2525
children?: React.ReactNode;
26-
27-
/**
28-
* Specifies an object of selectors and properties that are used to apply custom styles.
29-
*
30-
* - `root.background` (string) - (Optional) Background for badge.
31-
* - `root.borderColor` (string) - (Optional) Border color for badge.
32-
* - `root.borderRadius` (string) - (Optional) Border radius style.
33-
* - `root.borderWidth` (string) - (Optional) Border width style.
34-
* - `root.color` (string) - (Optional) Text color for badge.
35-
* - `root.paddingBlock` (string) - (Optional) Block dimension padding.
36-
* - `root.paddingInline` (string) - (Optional) Inline dimension padding.
37-
* @awsuiSystem core
38-
*/
39-
style?: BadgeProps.Style;
40-
}
41-
42-
export namespace BadgeProps {
43-
export interface Style {
44-
root?: {
45-
background?: string;
46-
borderColor?: string;
47-
borderRadius?: string;
48-
borderWidth?: string;
49-
color?: string;
50-
paddingBlock?: string;
51-
paddingInline?: string;
52-
};
53-
}
5426
}

src/badge/style.tsx

Lines changed: 0 additions & 22 deletions
This file was deleted.

src/badge/styles.scss

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
border-start-end-radius: awsui.$border-radius-badge;
1717
border-end-start-radius: awsui.$border-radius-badge;
1818
border-end-end-radius: awsui.$border-radius-badge;
19-
border-block-style: solid;
20-
border-inline-style: solid;
2119
padding-block: 0;
2220
padding-inline: awsui.$space-xs;
2321
color: awsui.$color-text-notification-default;

0 commit comments

Comments
 (0)