bigbuffet-rw/app/soapbox/features/ui/components/promo_panel.js

41 lines
1.2 KiB
JavaScript
Raw Normal View History

2020-03-27 13:59:38 -07:00
import React from 'react';
import PropTypes from 'prop-types';
2020-04-14 14:37:17 -07:00
import ImmutablePropTypes from 'react-immutable-proptypes';
2020-05-28 15:52:07 -07:00
import Icon from 'soapbox/components/icon';
2020-03-27 13:59:38 -07:00
import { connect } from 'react-redux';
import { getSettings } from 'soapbox/actions/settings';
import { getSoapboxConfig } from 'soapbox/actions/soapbox';
2020-03-27 13:59:38 -07:00
2020-04-11 15:50:42 -07:00
const mapStateToProps = state => ({
promoItems: getSoapboxConfig(state).getIn(['promoPanel', 'items']),
locale: getSettings(state).get('locale'),
2020-04-14 11:44:40 -07:00
});
2020-04-11 15:50:42 -07:00
export default @connect(mapStateToProps)
2020-03-27 13:59:38 -07:00
class PromoPanel extends React.PureComponent {
2020-04-14 14:37:17 -07:00
static propTypes = {
locale: PropTypes.string,
2020-04-14 14:37:17 -07:00
promoItems: ImmutablePropTypes.list,
}
2020-03-27 13:59:38 -07:00
render() {
const { locale, promoItems } = this.props;
2020-03-27 13:59:38 -07:00
if (!promoItems) return null;
return (
<div className='wtf-panel promo-panel'>
<div className='promo-panel__container'>
{promoItems.map((item, i) =>
2020-11-10 16:22:02 -08:00
(<a className='promo-panel-item' href={item.get('url')} target='_blank' key={i}>
<Icon id={item.get('icon')} className='promo-panel-item__icon' fixedWidth />
{item.getIn(['textLocales', locale]) || item.get('text')}
2020-11-10 16:22:02 -08:00
</a>),
2020-03-27 13:59:38 -07:00
)}
</div>
</div>
2020-04-14 11:44:40 -07:00
);
2020-03-27 13:59:38 -07:00
}
2020-04-14 11:44:40 -07:00
2020-03-27 13:59:38 -07:00
}