Skip to content

Commit

Permalink
Merge pull request #50 from AdeshGhadage/Updated-Lotengdev-logo
Browse files Browse the repository at this point in the history
updated Lotengdev logo according to background color
  • Loading branch information
ardianta authored Oct 27, 2024
2 parents 2de97d0 + b927ca2 commit 1748766
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 5 deletions.
14 changes: 14 additions & 0 deletions src/assets/lotengdev-logo-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions src/assets/lotengdev-logo-light.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 27 additions & 5 deletions src/components/Navbar/Brand.jsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,39 @@
import PropTypes from 'prop-types';
import { Link } from 'react-router-dom';
import LogtengDevLogo from '@/assets/lotengdev-logo.svg';
import { useEffect, useState, useRef } from 'react';
import LogtengDevLogoLight from '@/assets/lotengdev-logo-light.svg';
import LogtengDevLogoDark from '@/assets/lotengdev-logo-dark.svg';

export function Brand({ url }) {
const [isDarkBackground, setIsDarkBackground] = useState(false);
const brandRef = useRef(null);

useEffect(() => {
if (brandRef.current) {
const backgroundColor = window.getComputedStyle(brandRef.current).backgroundColor;
const rgb = backgroundColor.match(/\d+/g);

if (rgb) {
const brightness = (0.299 * rgb[0]) + (0.587 * rgb[1]) + (0.114 * rgb[2]);
setIsDarkBackground(brightness < 128);
}
}
}, []);

return (
<div className="pr-10 lg:border-r border-solid border-grey">
<Link to={url}>
<img className="h-7 lg:h-11" src={LogtengDevLogo} />
<img
className="h-7 lg:h-11"
src={isDarkBackground ? LogtengDevLogoDark : LogtengDevLogoLight}
alt="LogtengDev Logo"
/>
</Link>
</div>
)
);
}

Brand.propTypes = {
url: PropTypes.string.isRequired
}
url: PropTypes.string.isRequired,
isDarkBackground: PropTypes.bool
};

0 comments on commit 1748766

Please sign in to comment.