Skip to content

Commit

Permalink
Setup deprecation message for <AppIcon>
Browse files Browse the repository at this point in the history
  • Loading branch information
MaksymDryha authored Feb 1, 2019
1 parent 8b517e9 commit 9f75b6f
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 49 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# stripes-components

Copyright (C) 2016-2018 The Open Library Foundation
Copyright (C) 2016-2019 The Open Library Foundation

This software is distributed under the terms of the Apache License,
Version 2.0. See the file "[LICENSE](LICENSE)" for more information.
Expand Down
108 changes: 62 additions & 46 deletions lib/AppIcon/AppIcon.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,27 @@ import classNames from 'classnames';
import { withStripes } from '@folio/stripes-core/src/StripesContext';
import css from './AppIcon.css';

const AppIcon = ({
iconAriaHidden,
size,
icon,
alt,
src,
style,
children,
className,
tag,
app,
iconKey,
stripes,
}) => {
const getIcon = () => {
class AppIcon extends React.Component {
constructor(props) {
super(props);

console.warn(
`[DEPRECATION] The "AppIcon" component from "stripes-components" is deprecated.
Use "AppIcon" component from "stripes-core" instead.`
);
}

getIcon() {
const {
stripes,
app,
iconKey,
size,
icon,
src,
alt,
} = this.props;

let appIconProps;

/**
Expand Down Expand Up @@ -78,37 +84,47 @@ const AppIcon = ({
alt={typeof alt !== 'undefined' ? alt : appIconProps.alt}
/>
);
};

/**
* Root CSS styles
*/
const rootStyles = classNames(
/* Base app icon styling */
css.appIcon,
/* Icon size */
css[size],
/* Custom ClassName */
className,
);

/**
* Element - changeable by prop
*/
const Element = tag;

/**
* Render
*/
return (
<Element className={rootStyles} style={style}>
<span className={css.icon} aria-hidden={iconAriaHidden}>
{getIcon()}
</span>
{ children && <span className={css.label}>{children}</span> }
</Element>
);
};
}

render() {
const {
size,
tag,
className,
style,
iconAriaHidden,
children,
} = this.props;
/**
* Root CSS styles
*/
const rootStyles = classNames(
/* Base app icon styling */
css.appIcon,
/* Icon size */
css[size],
/* Custom ClassName */
className,
);

/**
* Element - changeable by prop
*/
const Element = tag;

/**
* Render
*/
return (
<Element className={rootStyles} style={style}>
<span className={css.icon} aria-hidden={iconAriaHidden}>
{this.getIcon()}
</span>
{children && <span className={css.label}>{children}</span>}
</Element>
);
}
}

AppIcon.propTypes = {
alt: PropTypes.string,
Expand Down
6 changes: 4 additions & 2 deletions lib/PaneHeader/PaneHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ import { FormattedMessage } from 'react-intl';
import PropTypes from 'prop-types';
import classNames from 'classnames';

import css from './PaneHeader.css';
import AppIcon from '../AppIcon';

import IconButton from '../IconButton';
import { Dropdown } from '../Dropdown';
import DropdownMenu from '../DropdownMenu';
import Icon from '../Icon';
import AppIcon from '../AppIcon';

import css from './PaneHeader.css';

class PaneHeader extends Component {
static propTypes = {
Expand Down

0 comments on commit 9f75b6f

Please sign in to comment.