2021-02-04 19:15:23 +01:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
2020-10-06 20:28:38 +02:00
|
|
|
|
|
|
|
// Inspired by https://stackoverflow.com/a/28056903/4727685
|
2020-11-03 00:41:28 +01:00
|
|
|
function hexToRGB(hex, alpha) {
|
2021-02-04 19:15:23 +01:00
|
|
|
const r = parseInt(hex.slice(1, 3), 16);
|
|
|
|
const g = parseInt(hex.slice(3, 5), 16);
|
|
|
|
const b = parseInt(hex.slice(5, 7), 16);
|
2020-10-06 20:28:38 +02:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
return `rgba(${r}, ${g}, ${b}, ${alpha})`;
|
2020-10-06 20:28:38 +02:00
|
|
|
}
|
|
|
|
|
2021-08-03 21:09:39 +02:00
|
|
|
export default function AggregatorLogo({ name, icon, color }) {
|
2020-10-06 20:28:38 +02:00
|
|
|
return (
|
|
|
|
<div className="loading-swaps-quotes__logo">
|
2021-08-03 21:09:39 +02:00
|
|
|
{icon && color ? (
|
|
|
|
<div
|
|
|
|
style={{
|
|
|
|
background: color,
|
|
|
|
boxShadow: `0px 4px 20px ${hexToRGB(color, 0.25)}`,
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<img src={icon} alt="" />
|
|
|
|
</div>
|
|
|
|
) : (
|
|
|
|
name && (
|
|
|
|
<div>
|
|
|
|
<span>{name}</span>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
)}
|
2020-10-06 20:28:38 +02:00
|
|
|
</div>
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2020-10-06 20:28:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
AggregatorLogo.propTypes = {
|
2021-08-03 21:09:39 +02:00
|
|
|
name: PropTypes.string,
|
|
|
|
icon: PropTypes.string,
|
|
|
|
color: PropTypes.string,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|