Skip to content
This repository was archived by the owner on Jan 14, 2025. It is now read-only.

Commit 2541ce2

Browse files
mgr34Matt Goo
authored and
Matt Goo
committed
chore(top-app-bar): deprecate render props (#915)
BREAKING CHANGE: Top App Bar render props removed
1 parent 10a68f6 commit 2541ce2

File tree

2 files changed

+1
-118
lines changed

2 files changed

+1
-118
lines changed

packages/top-app-bar/README.md

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -84,17 +84,6 @@ scrollTarget | React.RefObject | Sets scroll target to different DOM node (defau
8484
tag | String | Customizes the `TopAppBar` HTML tag. (default: `<header>`)
8585
> NOTES: As per design guidelines, prominent and dense variants should not be used with short or short collapsed. Additionally, dense variants should only be used on desktop. Additionally short top-app-bars should be used with no more than 1 action item.
8686
87-
#### Deprecated TopAppBar Props
88-
89-
The following props are deprecated since v0.11.0 and are scheduled for removal in v0.13.0.
90-
They will still render as expected until v0.13.0, but will output a warning to the console.
91-
92-
Prop Name | Type | Description
93-
--- | --- | ---
94-
actionItems | Array | Accepts an array of elements that should be rendered to the opposite side of the title. Note that a single action item should also be passed as an array.
95-
navigationIcon | Element | Appears adjacent to the title. This acts as the main action of the Top App Bar.
96-
title | String | The Title of the Top App Bar.
97-
9887
### TopAppBarRow
9988
Prop Name | Type | Description
10089
--- | --- | ---

packages/top-app-bar/index.tsx

Lines changed: 1 addition & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,7 @@ export type MDCTopAppBarFoundationTypes =
3939
| MDCTopAppBarFoundation
4040
| MDCShortTopAppBarFoundation;
4141

42-
/**
43-
* @deprecated since 0.11.0. Will be deleted in 0.13.0
44-
*/
45-
interface DeprecatedProps {
46-
actionItems?: React.ReactElement<any>[];
47-
navigationIcon?: React.ReactElement<any>;
48-
title?: string;
49-
}
50-
51-
export interface TopAppBarProps<T> extends React.HTMLProps<T>, DeprecatedProps {
42+
export interface TopAppBarProps<T> extends React.HTMLProps<T> {
5243
className?: string;
5344
dense?: boolean;
5445
fixed?: boolean;
@@ -162,19 +153,6 @@ class TopAppBar<
162153
this.foundation.init();
163154
};
164155

165-
/**
166-
* @deprecated since 0.11.0. Will be deleted in 0.13.0
167-
*/
168-
addClassesToElement /* istanbul ignore next */(
169-
classes: string,
170-
element: React.ReactElement<any>
171-
) {
172-
const updatedProps = {
173-
className: classnames(classes, element.props.className),
174-
};
175-
return React.cloneElement(element, updatedProps);
176-
}
177-
178156
getMergedStyles = () => {
179157
const {style} = this.state;
180158
return Object.assign({}, style, this.props.style);
@@ -266,41 +244,10 @@ class TopAppBar<
266244
prominent,
267245
scrollTarget,
268246
tag: Tag,
269-
actionItems,
270-
navigationIcon,
271-
title,
272247
...otherProps
273248
/* eslint-enable @typescript-eslint/no-unused-vars */
274249
} = this.props;
275250

276-
/**
277-
* @deprecated since 0.11.0. Will be deleted in 0.13.0
278-
*/
279-
/* istanbul ignore if */
280-
if (actionItems || navigationIcon || title) {
281-
// TODO(mgr34): remove all deprecated statements and istanbul ignore's for v0.13.0
282-
const warning =
283-
'actionItems, navigationIcon, and title are deprecated ' +
284-
'since v0.11.0 and will be removed in v0.13.0. Please refer to ' +
285-
'https://github.com/material-components/material-components-web-react' +
286-
'/blob/master/packages/top-app-bar/README.md';
287-
console.warn(warning);
288-
return (
289-
// @ts-ignore Tag does not have any construct https://github.com/Microsoft/TypeScript/issues/28892
290-
<Tag
291-
{...otherProps}
292-
className={this.classes}
293-
style={this.getMergedStyles()}
294-
ref={this.topAppBarElement}
295-
>
296-
<div className='mdc-top-app-bar__row'>
297-
{this.renderTitleAndNavigationSection()}
298-
{this.renderActionItems()}
299-
</div>
300-
</Tag>
301-
);
302-
}
303-
304251
return (
305252
// @ts-ignore Tag does not have any construct https://github.com/Microsoft/TypeScript/issues/28892
306253
<Tag
@@ -313,59 +260,6 @@ class TopAppBar<
313260
</Tag>
314261
);
315262
}
316-
317-
/**
318-
* @deprecated since 0.11.0. Will be deleted in 0.13.0
319-
*/
320-
renderTitleAndNavigationSection /* istanbul ignore next */() {
321-
const {title} = this.props;
322-
const classes =
323-
'mdc-top-app-bar__section mdc-top-app-bar__section--align-start';
324-
return (
325-
<section className={classes}>
326-
{this.renderNavigationIcon()}
327-
<span className='mdc-top-app-bar__title'>{title}</span>
328-
</section>
329-
);
330-
}
331-
332-
/**
333-
* @deprecated since 0.11.0. Will be deleted in 0.13.0
334-
*/
335-
renderNavigationIcon /* istanbul ignore next */() {
336-
const {navigationIcon} = this.props;
337-
if (!navigationIcon) {
338-
return;
339-
}
340-
return this.addClassesToElement(
341-
'mdc-top-app-bar__navigation-icon',
342-
navigationIcon
343-
);
344-
}
345-
346-
/**
347-
* @deprecated since 0.11.0. Will be deleted in 0.13.0
348-
*/
349-
renderActionItems /* istanbul ignore next */() {
350-
const {actionItems} = this.props;
351-
if (!actionItems) {
352-
return;
353-
}
354-
return (
355-
<section
356-
className='mdc-top-app-bar__section mdc-top-app-bar__section--align-end'
357-
role='toolbar'
358-
>
359-
{actionItems.map((item, key) => {
360-
const elementWithClasses = this.addClassesToElement(
361-
'mdc-top-app-bar__action-item',
362-
item
363-
);
364-
return React.cloneElement(elementWithClasses, {key});
365-
})}
366-
</section>
367-
);
368-
}
369263
}
370264

371265
export default TopAppBar;

0 commit comments

Comments
 (0)