Skip to content

Commit 37f3897

Browse files
committed
refactor: use function-type component syntax
1 parent f4e5e5f commit 37f3897

File tree

1 file changed

+15
-27
lines changed
  • packages/components/src/separator

1 file changed

+15
-27
lines changed

packages/components/src/separator/index.js

Lines changed: 15 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,6 @@
22
* Separator
33
*/
44

5-
/**
6-
* WordPress dependencies
7-
*/
8-
import { Component } from '@wordpress/element';
9-
105
/**
116
* Internal dependencies
127
*/
@@ -17,27 +12,20 @@ import './style.scss';
1712
*/
1813
import classNames from 'classnames';
1914

20-
class Separator extends Component {
21-
/**
22-
* Render
23-
*/
24-
render() {
25-
const { alignment = 'full-width', className, marginBottom = 64, marginTop = 64, variant = 'tertiary', ...otherProps } = this.props;
26-
27-
const classes = classNames(
28-
'newspack-separator',
29-
className,
30-
alignment && `newspack-separator--alignment-${ alignment }`,
31-
variant && `newspack-separator--variant-${ variant }`
32-
);
33-
34-
const style = {
35-
'--separator-margin-bottom': typeof marginBottom === 'number' ? `${ marginBottom }px` : marginBottom,
36-
'--separator-margin-top': typeof marginTop === 'number' ? `${ marginTop }px` : marginTop,
37-
};
38-
39-
return <hr className={ classes } style={ style } { ...otherProps } />;
40-
}
41-
}
15+
const Separator = ( { alignment = 'full-width', className, marginBottom = 64, marginTop = 64, variant = 'tertiary', ...otherProps } ) => {
16+
const classes = classNames(
17+
'newspack-separator',
18+
className,
19+
alignment && `newspack-separator--alignment-${ alignment }`,
20+
variant && `newspack-separator--variant-${ variant }`
21+
);
22+
23+
const style = {
24+
'--separator-margin-bottom': typeof marginBottom === 'number' ? `${ marginBottom }px` : marginBottom,
25+
'--separator-margin-top': typeof marginTop === 'number' ? `${ marginTop }px` : marginTop,
26+
};
27+
28+
return <hr className={ classes } style={ style } { ...otherProps } />;
29+
};
4230

4331
export default Separator;

0 commit comments

Comments
 (0)