import React from 'react'; import styled from 'styled-components'; import { dim } from '@utils/dim'; import { RatingInterface } from './interface'; const RatingWrapper = styled.div` max-width: 77px; height: 16px; display: inline-block; overflow: hidden; position: relative; margin-top: ${dim(2)}; `; const RatingBackground = styled.span` ${({ rating }: RatingInterface) => ` position: absolute; top: 1px; left: 2px; width: 73px; height: 15px; z-index: -1; background: linear-gradient( 90deg, rgba(0, 0, 0, 1) ${(rating / 5) * 100}%, rgba(204, 204, 204, 1) ${(rating / 5) * 100}% ); `} `; export default ({ rating }: RatingInterface) => ( {`${rating} );