update Fav button to fav icon

This commit is contained in:
Abhinav 2022-06-26 12:43:23 +05:30
parent c963d5f014
commit ae1e532446
2 changed files with 30 additions and 23 deletions

View file

@ -1,23 +0,0 @@
import React from 'react';
import { styled } from '@mui/material';
const HeartUI = styled('button')<{
isClick: boolean;
size: number;
}>`
width: ${(props) => props.size}px;
height: ${(props) => props.size}px;
float: right;
background: url('/fav-button.png') no-repeat;
cursor: pointer;
background-size: cover;
border: none;
${({ isClick, size }) =>
isClick &&
`background-position: -${
28 * size
}px;transition: background 1s steps(28);`}
`;
export default function FavButton({ isClick, onClick, size }) {
return <HeartUI isClick={isClick} onClick={onClick} size={size} />;
}

View file

@ -0,0 +1,30 @@
import React from 'react';
import { styled } from '@mui/material';
const HeartUI = styled('div')<{
isActive: boolean;
size: number;
}>(
({ isActive, size }) => `
width: ${size}px;
height: ${size}px;
float: right;
background: url('/fav-button.png') no-repeat;
cursor: pointer;
background-size: cover;
border: none;
${
isActive &&
`background-position: -${
size * 44
}px;transition: background 1s steps(28);`
}
`
);
export default function FavIcon({ isActive, size }) {
return <HeartUI isActive={isActive} size={size} />;
}
FavIcon.defaultProps = {
size: 44,
};