Skip to content

Commit

Permalink
feat(project): add logo component
Browse files Browse the repository at this point in the history
  • Loading branch information
RCVZ committed Apr 29, 2021
1 parent b793979 commit bb67fe3
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 0 deletions.
47 changes: 47 additions & 0 deletions src/components/Logo/Logo.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
@use '../../styles/variables';
@use '../../styles/theme';
@use '../../styles/mixins/responsive';

//
// Logo
// --------------------------------

.brand {
align-self: center;
text-align: center;
}

.logo {
max-width: 100%;
max-height: variables.$header-height - 10px;
max-height: 36px;
vertical-align: middle;
cursor: pointer;
}

//
// mediaQueries
// --------------------------------

@include responsive.mobile-and-tablet() {
.brand {
flex: 1;

.logo {
max-height: variables.$header-height-mobile - 20px;
}
}
}

@include responsive.mobile-only() {
.brand {
transition: opacity 0.2s ease;
}
}

@include responsive.desktop-only() {
.brand {
width: 180px;
text-align: left;
}
}
13 changes: 13 additions & 0 deletions src/components/Logo/Logo.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React from 'react';

import { render } from '../../testUtils';

import Logo from './Logo';

describe('<Logo/>', () => {
it('renders and matches snapshot', () => {
const { container } = render(<Logo src="123" />);

expect(container).toMatchSnapshot();
});
});
24 changes: 24 additions & 0 deletions src/components/Logo/Logo.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import React from 'react';
import { useHistory } from 'react-router-dom';

import styles from './Logo.module.scss';

type LogoProps = {
src: string;
};

const Logo: React.FC<LogoProps> = ({ src }: LogoProps) => {
const history = useHistory();

const handleClick = () => {
history.push('/');
};

return (
<div className={styles.brand}>
<img className={styles.logo} alt="logo" src={src} onClick={handleClick} />
</div>
);
};

export default Logo;
12 changes: 12 additions & 0 deletions src/components/Logo/__snapshots__/Logo.test.tsx.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`<Logo/> renders and matches snapshot 1`] = `
<div>
<div>
<img
alt="logo"
src="123"
/>
</div>
</div>
`;

0 comments on commit bb67fe3

Please sign in to comment.