Skip to content

Commit 60cbc68

Browse files
authored
feat: update fundamental-styles to 0.13.1-rc.2 (#1266)
* update to latest * remove tabindex * Revert "remove tabindex" This reverts commit 970a9f4.
1 parent 3eb3422 commit 60cbc68

File tree

77 files changed

+1256
-1033
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+1256
-1033
lines changed

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"@popperjs/core": "^2.4.3",
5151
"chain-function": "^1.0.1",
5252
"classnames": "^2.2.6",
53-
"fundamental-styles": "0.13.0-rc.34",
53+
"fundamental-styles": "0.13.1-rc.2",
5454
"hoist-non-react-statics": "^3.3.2",
5555
"keycode": "^2.2.0",
5656
"moment": "^2.26.0",

src/Breadcrumb/Breadcrumb.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ const classnames = classnamesBind.bind(styles);
1414
const Breadcrumb = React.forwardRef(({ children, cssNamespace, ...props }, ref) => (
1515
<ul {...props}
1616
className={classnames(`${cssNamespace}-breadcrumb`)}
17-
ref={ref}>{children}</ul>)
17+
ref={ref}
18+
role='menu'>{children}</ul>)
1819
);
1920

2021
Breadcrumb.displayName = 'Breadcrumb';

src/Breadcrumb/_BreadcrumbItem.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,17 @@ const BreadcrumbItem = ({ url, name, className, children, cssNamespace, ...props
1010
const renderLink = () => {
1111
if (!children && url) {
1212
return (
13-
<a className={classnames(`${cssNamespace}-breadcrumb__link`)} href={url}>{name}</a>
13+
<a
14+
className={classnames(`${cssNamespace}-breadcrumb__link`)}
15+
href={url}
16+
tabIndex='0'>
17+
{name}
18+
</a>
1419
);
1520
} else if (children) {
1621
return React.cloneElement(children, {
17-
'className': classnames(`${cssNamespace}-breadcrumb__link`)
22+
'className': classnames(`${cssNamespace}-breadcrumb__link`),
23+
'tabIndex': '0'
1824
});
1925
}
2026
};
@@ -25,7 +31,11 @@ const BreadcrumbItem = ({ url, name, className, children, cssNamespace, ...props
2531
);
2632

2733
return (
28-
<li {...props} className={breadcrumbItemClasses}>
34+
<li
35+
{...props}
36+
className={breadcrumbItemClasses}
37+
role='menuitem'
38+
tabIndex='-1'>
2939
{renderLink()}
3040
</li>
3141
);

src/Breadcrumb/__stories__/__snapshots__/Breadcrumb.stories.storyshot

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,43 @@ exports[`Storyshots Component API/Breadcrumb No Styles 1`] = `
66
>
77
<ul
88
className="xxx-breadcrumb"
9+
role="menu"
910
>
1011
<li
1112
className="xxx-breadcrumb__item"
13+
role="menuitem"
14+
tabIndex="-1"
1215
>
1316
<a
1417
className="xxx-breadcrumb__link"
1518
href="#"
19+
tabIndex="0"
1620
>
1721
Link Text
1822
</a>
1923
</li>
2024
<li
2125
className="xxx-breadcrumb__item"
26+
role="menuitem"
27+
tabIndex="-1"
2228
>
2329
<a
2430
className="xxx-breadcrumb__link"
2531
href="#"
32+
tabIndex="0"
2633
>
2734
Link Text
2835
</a>
2936
</li>
3037
<li
3138
className="xxx-breadcrumb__item"
39+
role="menuitem"
40+
tabIndex="-1"
3241
>
3342
<a
3443
className="xxx-breadcrumb__link"
3544
href="#"
45+
tabIndex="0"
3646
>
3747
Link Text
3848
</a>
@@ -47,33 +57,43 @@ exports[`Storyshots Component API/Breadcrumb Primary 1`] = `
4757
>
4858
<ul
4959
className="fd-breadcrumb"
60+
role="menu"
5061
>
5162
<li
5263
className="fd-breadcrumb__item"
64+
role="menuitem"
65+
tabIndex="-1"
5366
>
5467
<a
5568
className="fd-breadcrumb__link"
5669
href="#"
70+
tabIndex="0"
5771
>
5872
Link Text
5973
</a>
6074
</li>
6175
<li
6276
className="fd-breadcrumb__item"
77+
role="menuitem"
78+
tabIndex="-1"
6379
>
6480
<a
6581
className="fd-breadcrumb__link"
6682
href="#"
83+
tabIndex="0"
6784
>
6885
Link Text
6986
</a>
7087
</li>
7188
<li
7289
className="fd-breadcrumb__item"
90+
role="menuitem"
91+
tabIndex="-1"
7392
>
7493
<a
7594
className="fd-breadcrumb__link"
7695
href="#"
96+
tabIndex="0"
7797
>
7898
Link Text
7999
</a>
@@ -88,33 +108,43 @@ exports[`Storyshots Component API/Breadcrumb With url property 1`] = `
88108
>
89109
<ul
90110
className="fd-breadcrumb"
111+
role="menu"
91112
>
92113
<li
93114
className="fd-breadcrumb__item"
115+
role="menuitem"
116+
tabIndex="-1"
94117
>
95118
<a
96119
className="fd-breadcrumb__link"
97120
href="#"
121+
tabIndex="0"
98122
>
99123
Link Text
100124
</a>
101125
</li>
102126
<li
103127
className="fd-breadcrumb__item"
128+
role="menuitem"
129+
tabIndex="-1"
104130
>
105131
<a
106132
className="fd-breadcrumb__link"
107133
href="#"
134+
tabIndex="0"
108135
>
109136
Link Text
110137
</a>
111138
</li>
112139
<li
113140
className="fd-breadcrumb__item"
141+
role="menuitem"
142+
tabIndex="-1"
114143
>
115144
<a
116145
className="fd-breadcrumb__link"
117146
href="#"
147+
tabIndex="0"
118148
>
119149
Link Text
120150
</a>

src/Button/Button.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ const Button = React.forwardRef(({
3232
className,
3333
cssNamespace,
3434
textClassName,
35+
badge,
36+
badgeClassName,
3537
...props
3638
}, ref) => {
3739

@@ -52,6 +54,11 @@ const Button = React.forwardRef(({
5254
textClassName
5355
);
5456

57+
const badgeClasses = classnames(
58+
`${cssNamespace}-button__badge`,
59+
badgeClassName
60+
);
61+
5562
const ariaDisabled = props['aria-disabled'];
5663
let disabledInAnyWay = disabled || ariaDisabled;
5764

@@ -107,11 +114,11 @@ const Button = React.forwardRef(({
107114
className={buttonClasses}
108115
onClick={onClickHandler}
109116
ref={ref}
110-
selected={selected}
111117
type={typeAttr}>
112118
{iconBeforeText && renderIcon()}
113119
{children && <span className={buttonTextClasses}>{children}</span>}
114120
{!iconBeforeText && renderIcon()}
121+
{badge && <span className={badgeClasses}>{badge}</span>}
115122
</button>
116123
{renderButtonStateMessage()}
117124
</>
@@ -140,11 +147,21 @@ const validateStateTransitionMessage = (props, propName) => {
140147
}
141148
};
142149

150+
const badgePropValidation = (props, propName) => {
151+
if (props[propName].length < 1 || props[propName].length > 4) {
152+
return new Error(`${propName} must be between 1-4 characters.`);
153+
}
154+
};
155+
143156
Button.propTypes = {
144157
/** Set to **true** to enable button focus through keyboard on a disabled button */
145158
allowFocusOnDisable: PropTypes.bool,
146159
/** Automatically set when disabled prop is passed into button */
147160
'aria-disabled': PropTypes.bool,
161+
/** Content to display in a badge. Must be between 1-4 characters */
162+
badge: badgePropValidation,
163+
/** CSS class(es) to add to the badge element */
164+
badgeClassName: PropTypes.string,
148165
/** Node(s) to render within the component */
149166
children: PropTypes.node,
150167
/** CSS class(es) to add to the element */

src/Button/__stories__/Button.stories.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,34 @@ export const sizes = () => (
9595

9696
sizes.storyName = 'Sizes';
9797

98+
/** Button gets a badge in cases of collecting a number of items from various pages in order to trigger an action.
99+
* Currently the Emphasized, Standard and Transparent type of buttons are recommended to be used with Badge.
100+
* Badges cannot contain more than 4 characters.
101+
*/
102+
103+
export const badges = () => (
104+
<div className='fddocs-container'>
105+
<Button badge='1234'>Default</Button>
106+
<Button badge='123' option='emphasized'>Emphasized</Button>
107+
<Button badge='12' option='transparent'>Transparent</Button>
108+
<Button badge='1234' compact>Default compact</Button>
109+
<Button
110+
badge='123'
111+
compact
112+
option='emphasized'>
113+
Emphasized compact
114+
</Button>
115+
<Button
116+
badge='12'
117+
compact
118+
option='transparent'>
119+
Transparent compact
120+
</Button>
121+
</div>
122+
);
123+
124+
badges.storyName = 'Badges';
125+
98126
/** There are four states: default, `selected`, `disabled`, and `allowFocusOnDisable`. `allowFocusOnDisabled` allows a
99127
* disabled button to be focusable. This is to ensure a screen reader can tab into the button and read its state.
100128
* if `allowFocusOnDisabled` is selected there must be a `disabledMessage` and `enabledMessage` prop within the button

src/Button/__stories__/ButtonSegmented.stories.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,12 @@ export default {
99
};
1010

1111
export const primary = () => (<ButtonSegmented>
12-
<Button glyph='survey' />
13-
<Button glyph='pie-chart' selected />
14-
<Button glyph='pool' />
12+
<Button aria-label='Survey' glyph='survey' />
13+
<Button
14+
aria-label='Pie chart'
15+
glyph='pie-chart'
16+
selected />
17+
<Button aria-label='Pool' glyph='pool' />
1518
</ButtonSegmented>);
1619

1720

@@ -27,9 +30,12 @@ compact.storyName = 'Compact';
2730

2831
export const noStyles = () => (
2932
<ButtonSegmented cssNamespace='xxx'>
30-
<Button glyph='survey' />
31-
<Button glyph='pie-chart' selected />
32-
<Button glyph='pool' />
33+
<Button aria-label='Survey' glyph='survey' />
34+
<Button
35+
aria-label='Pie chart'
36+
glyph='pie-chart'
37+
selected />
38+
<Button aria-label='Pool' glyph='pool' />
3339
</ButtonSegmented>
3440
);
3541
noStyles.parameters = { docs: { disable: true } };

0 commit comments

Comments
 (0)