Skip to content

Commit 282f771

Browse files
authored
feat: update fundamental styles to 0.11.3-rc.8 (#1142)
In this change we * Update `fundamental-styles` to `0.11.3-rc.8` and support the new features and fixes therein. * This also includes some accessibility upgrades * ActionBar has a glyph based back button. Enforce aria-label for it. * MultiInput has a glyph based popover trigger button. Enforce aria-label for it. * Tokens have a glyph based close/clear button. Allow setting aria-label for it. * It wasn't possible to remove MultiInput tokens from the input field using a keyboard. After this change, if a MultiInput token has focus, pressing `backspace` or `delete` should remove it. * Update TimePicker stories so that there are no accessibility issues in Storybook * Support FormLabel with colons feature (SAP/fundamental-styles#1181) * Deprecate LocalizationEditor (SAP/fundamental-styles#1261)
1 parent f49b881 commit 282f771

File tree

20 files changed

+608
-199
lines changed

20 files changed

+608
-199
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import Markdown from 'markdown-to-jsx';
2+
import React from 'react';
3+
4+
const Description = (props) => {
5+
return (
6+
<Markdown options={{ forceBlock: true}}>{props.desc}</Markdown>
7+
)
8+
}
9+
10+
Description.displayName = 'Description';
11+
12+
export default Description;

.storybook/custom/components/DocsPage.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import '../custom.scss';
22
import Community from './Community';
3+
import Description from './Description';
34
import { DocsContext } from '@storybook/addon-docs/blocks';
45
import Footer from './Footer';
56
import Header from './Header';
@@ -10,7 +11,6 @@ import React, { useContext, useEffect } from 'react';
1011
import {
1112
Title,
1213
Subtitle,
13-
Description,
1414
Heading,
1515
Props,
1616
DocsStory,
@@ -46,8 +46,8 @@ const DocsPage = () => {
4646
<Title />
4747
<Toc />
4848
<Subtitle />
49+
{context?.parameters?.description && <Description desc={context?.parameters?.description} />}
4950
<Import />
50-
<Description />
5151
<Heading>Examples</Heading>
5252
{stories.map((story) => story && <DocsStory
5353
key={story.id}

.storybook/custom/custom.scss

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,3 +243,23 @@ $heading-toc-spacer: $docs-hd-tp + $docs-hd-bp + $docs-hd-ch + $docs-tm;
243243
height: 120px;
244244
}
245245
}
246+
247+
/* blockquote e.g. depreciated warning */
248+
blockquote {
249+
margin: 15px 0;
250+
padding: 10px;
251+
border: 1px solid #ccc;
252+
border-left-width: 5px;
253+
border-radius: 5px;
254+
background: #fffde4;
255+
font-size: 1rem;
256+
257+
&.docs-deprecated {
258+
background: #ffebeb;
259+
background: var(--sapErrorBackground, #ffebeb);
260+
color: #bb0000;
261+
color: var(--sapNegativeColor, #bb0000);
262+
border-color: #bb0000;
263+
border-color: var(--sapNegativeColor, #bb0000);
264+
}
265+
}

package-lock.json

Lines changed: 3 additions & 3 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
@@ -51,7 +51,7 @@
5151
"chain-function": "^1.0.1",
5252
"classnames": "^2.2.6",
5353
"detect-browser": "^5.1.0",
54-
"fundamental-styles": "0.11.3-rc.7",
54+
"fundamental-styles": "0.11.3-rc.8",
5555
"keycode": "^2.2.0",
5656
"moment": "^2.26.0",
5757
"prop-types": "^15.7.1",

src/ActionBar/ActionBar.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import classnames from 'classnames';
33
import CustomPropTypes from '../utils/CustomPropTypes/CustomPropTypes';
44
import PropTypes from 'prop-types';
55
import React from 'react';
6+
import requiredIf from 'react-required-if';
67
import 'fundamental-styles/dist/action-bar.css';
78

89
/**
@@ -15,6 +16,7 @@ const ActionBar = React.forwardRef(({
1516
actionClassName,
1617
actionProps,
1718
className,
19+
backButtonLabel,
1820
buttonContainerClassName,
1921
buttonProps,
2022
description,
@@ -62,6 +64,7 @@ const ActionBar = React.forwardRef(({
6264
<div {...props} className={actionBarHeaderClasses}>
6365
{onBackClick && (<div className={actionBarBackClasses}>
6466
<Button
67+
aria-label={backButtonLabel}
6568
{...buttonProps}
6669
compact
6770
glyph='navigation-left-arrow'
@@ -93,6 +96,10 @@ ActionBar.propTypes = {
9396
actionProps: PropTypes.object,
9497
/** Button components to add to the ActionBar */
9598
actions: PropTypes.node,
99+
/** Localized string for 'Back' button's aria-label. This is required if the button is enabled and `buttonProps` doesn't have a valid `aria-label` */
100+
backButtonLabel: requiredIf(PropTypes.string, props => {
101+
return typeof props?.onBackClick === 'function' && (!props?.buttonProps || !props.buttonProps['aria-label']?.trim());
102+
}),
96103
/** Classnames to spread to the back Button container */
97104
buttonContainerClassName: PropTypes.string,
98105
/** Additional props to be spread to the `<button>` element */

src/ActionBar/__stories__/ActionBar.stories.js

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export const primary = () => (
1919
<Button option='emphasized'>Button</Button>
2020
</>
2121
)}
22+
backButtonLabel='Back to home'
2223
description={'Action Bar Description'}
2324
onBackClick={() => {}}
2425
title={'Page Title'} />
@@ -41,18 +42,25 @@ more than 3-4 actions. This also works well for a responsive/adaptive applicatio
4142

4243
export const contextualMenu = () => (
4344
<ActionBar
44-
actions={<Popover
45-
body={
46-
<Menu>
47-
<Menu.List>
48-
<Menu.Item url='#'>Option 1</Menu.Item>
49-
<Menu.Item url='#'>Option 2</Menu.Item>
50-
<Menu.Item url='#'>Option 3</Menu.Item>
51-
<Menu.Item url='#'>Option 4</Menu.Item>
52-
</Menu.List>
53-
</Menu>}
54-
control={<Button glyph='vertical-grip' option='transparent' />}
55-
placement='bottom-end' />}
45+
actions={
46+
<Popover
47+
body={
48+
<Menu>
49+
<Menu.List>
50+
<Menu.Item url='#'>Option 1</Menu.Item>
51+
<Menu.Item url='#'>Option 2</Menu.Item>
52+
<Menu.Item url='#'>Option 3</Menu.Item>
53+
<Menu.Item url='#'>Option 4</Menu.Item>
54+
</Menu.List>
55+
</Menu>}
56+
control={
57+
<Button
58+
aria-label='More actions'
59+
glyph='vertical-grip'
60+
option='transparent' />
61+
}
62+
placement='bottom-end' />
63+
}
5664
description='Action Bar Description'
5765
title='Page Title' />
5866
);
@@ -64,6 +72,9 @@ export const dev = () => (
6472
actions={(<><Button>Button</Button>
6573
<Button option='emphasized'>Button</Button></>
6674
)}
75+
buttonProps={{
76+
'aria-label': 'Back to home'
77+
}}
6778
description={text('description', 'Action Bar description')}
6879
headingLevel={number('headingLevel', 2, {
6980
range: true,

src/ActionBar/__stories__/__snapshots__/ActionBar.stories.storyshot

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ exports[`Storyshots Component API/ActionBar Dev 1`] = `
1414
className="fd-action-bar__back"
1515
>
1616
<button
17+
aria-label="Back to home"
1718
className="fd-button fd-button--transparent fd-button--compact sap-icon--navigation-left-arrow"
1819
onClick={[Function]}
1920
type="button"
@@ -161,6 +162,7 @@ exports[`Storyshots Component API/ActionBar Primary 1`] = `
161162
className="fd-action-bar__back"
162163
>
163164
<button
165+
aria-label="Back to home"
164166
className="fd-button fd-button--transparent fd-button--compact sap-icon--navigation-left-arrow"
165167
onClick={[Function]}
166168
type="button"
@@ -230,6 +232,7 @@ exports[`Storyshots Component API/ActionBar With a ContextualMenu 1`] = `
230232
aria-controls="fd-mocked-short-id"
231233
aria-expanded={false}
232234
aria-haspopup={true}
235+
aria-label="More actions"
233236
className="fd-button fd-button--transparent sap-icon--vertical-grip"
234237
onClick={[Function]}
235238
onKeyPress={[Function]}

src/Forms/FormLabel.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const FormLabel = React.forwardRef(({
1111
className,
1212
disabled,
1313
isInlineHelp,
14+
includeColon,
1415
...props
1516
}, ref) => {
1617

@@ -19,7 +20,8 @@ const FormLabel = React.forwardRef(({
1920
{
2021
'is-disabled': disabled,
2122
'fd-form-label--inline-help': isInlineHelp,
22-
'fd-form-label--required': required
23+
'fd-form-label--required': required,
24+
'fd-form-label--colon': includeColon
2325
},
2426
className
2527
);
@@ -44,6 +46,8 @@ FormLabel.propTypes = {
4446
className: PropTypes.string,
4547
/** Set to **true** to mark component as disabled and make it non-interactive */
4648
disabled: PropTypes.bool,
49+
/** Set to **true** to add the `:` character at the end of a label as pseudo element.*/
50+
includeColon: PropTypes.bool,
4751
/** Set to **true** if child is InlineHelp component */
4852
isInlineHelp: PropTypes.bool,
4953
/** Set to **true** for required input fields */

src/Forms/__stories__/FormLabel.stories.js

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,39 @@ export default {
1212

1313
export const primary = () => (
1414
<FormItem>
15-
<FormLabel>Default Label</FormLabel>
16-
<FormInput />
15+
<FormLabel htmlFor='primaryLabelExample' >Default Label</FormLabel>
16+
<FormInput id='primaryLabelExample' />
1717
</FormItem>
1818
);
1919

2020
export const required = () => (
2121
<FormItem>
22-
<FormLabel required>Required Label</FormLabel>
23-
<FormInput />
22+
<FormLabel
23+
htmlFor='requiredLabelExample'
24+
required>
25+
Required Label
26+
</FormLabel >
27+
<FormInput id='requiredLabelExample' />
2428
</FormItem>
2529
);
2630

31+
/** To achieve overflow proof colon provide the `includeColon` property. The `:` character will be added at the end of a label as pseudo element. */
32+
33+
export const includeColon = () => (
34+
<div style={{
35+
maxWidth: '250px'
36+
}}>
37+
<FormItem>
38+
<FormLabel
39+
htmlFor='includeColonLabelExample'
40+
includeColon>
41+
Overflow proof colon, overflow proof colon, overflow proof colon
42+
</FormLabel>
43+
<FormInput id='includeColonLabelExample' />
44+
</FormItem>
45+
</div>
46+
);
47+
2748
export const disabled = () => (
2849
<FormItem>
2950
<FormLabel disabled>Disabled Label</FormLabel>
@@ -34,9 +55,12 @@ export const disabled = () => (
3455
export const dev = () => (
3556
<FormItem>
3657
<FormLabel
58+
htmlFor='devLabelExample'
59+
includeColon={boolean('Include colon?', false)}
3760
required={boolean('Required?', true)}>
38-
Default</FormLabel>
39-
<FormInput />
61+
Dev
62+
</FormLabel>
63+
<FormInput id='devLabelExample' />
4064
</FormItem>
4165
);
4266

0 commit comments

Comments
 (0)