Utility function to detect background colour and select either light or dark default hometown logo

This commit is contained in:
Emma Winston
2019-09-17 16:57:08 +01:00
parent 87ad6ac03a
commit 2ebe82c49b
3 changed files with 38 additions and 2 deletions

View File

@ -12,8 +12,10 @@ import Motion from '../ui/util/optional_motion';
import spring from 'react-motion/lib/spring';
import SearchResultsContainer from './containers/search_results_container';
import { changeComposing } from '../../actions/compose';
import elephantUIPlane from '../../../images/elephant_ui_plane.svg';
import defaultmascotlight from '../../../images/defaultmascotlight.svg';
import defaultmascotdark from '../../../images/defaultmascotdark.svg';
import { mascot } from '../../initial_state';
import {svgSelect} from './util/svg_select';
import Icon from 'mastodon/components/icon';
const messages = defineMessages({
@ -32,6 +34,13 @@ const mapStateToProps = (state, ownProps) => ({
showSearch: ownProps.multiColumn ? state.getIn(['search', 'submitted']) && !state.getIn(['search', 'hidden']) : ownProps.isSearchPage,
});
let instanceMascot;
if (mascot) {
instanceMascot = <img alt='' draggable='false' src={mascot} />;
} else {
instanceMascot = <img alt='' draggable='false' className="defaultmascot" src={svgSelect(defaultmascotlight, defaultmascotdark)} />;
}
export default @connect(mapStateToProps)
@injectIntl
class Compose extends React.PureComponent {
@ -110,7 +119,7 @@ class Compose extends React.PureComponent {
<ComposeFormContainer />
<div className='drawer__inner__mastodon'>
<img alt='' draggable='false' src={mascot || elephantUIPlane} />
{instanceMascot}
</div>
</div>}