Skip to content

Commit

Permalink
refactor: switch Alert to JSX
Browse files Browse the repository at this point in the history
  • Loading branch information
fboulnois committed Nov 13, 2023
1 parent 942c86c commit cf91edf
Showing 1 changed file with 11 additions and 22 deletions.
33 changes: 11 additions & 22 deletions src/components/Alert.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,15 @@
import { Component } from 'react';
import { div, hh, h4, span } from 'react-hyperscript-helpers';
import React from 'react';
import './Alert.css';

export const Alert = hh(class Alert extends Component {
export const Alert = (props) => {
const { id, type, title, description } = props;

render() {
return (
<div id={`${id}_alert`} className={`alert-wrapper ${type}`}>
{title !== undefined && <h4 id={`${id}_title`} className='alert-title'>{title}</h4>}
{description !== undefined && <span id={`${id}_description`} className='alert-description'>{description}</span>}
</div>
);
}

return div({
id: this.props.id + '_alert',
className: 'alert-wrapper ' + (this.props.type)
}, [
h4({
id: this.props.id + '_title',
className: 'alert-title',
isRendered: this.props.title !== undefined
}, [this.props.title]),
span({
id: this.props.id + '_description',
className: 'alert-description',
isRendered: this.props.description !== undefined
}, [this.props.description]),
]);
}

});
export default Alert;

0 comments on commit cf91edf

Please sign in to comment.