| 1 | import styled, { css, keyframes } from "styled-components"; |
| 2 | |
| 3 | const DEFAULT_DIAMETER = 6; |
| 4 | |
| 5 | const blink = keyframes` |
| 6 | 0%, 100% { |
| 7 | transform: scale(1); |
| 8 | opacity: 1; |
| 9 | } |
| 10 | 50% { |
| 11 | opacity: 0.25; |
| 12 | } |
| 13 | `; |
| 14 | |
| 15 | const blinkAnimation = css` |
| 16 | animation: ${blink} 3s infinite; |
| 17 | `; |
| 18 | |
| 19 | const BlinkingDot = styled.div<{ |
| 20 | color: string; |
| 21 | diameter?: number; |
| 22 | shouldBlink?: boolean; |
| 23 | }>` |
| 24 | background-color: ${(props) => props.color}; |
| 25 | box-shadow: 0px 0px 2px 1px ${(props) => props.color}; |
| 26 | width: ${(props) => props.diameter ?? DEFAULT_DIAMETER}px; |
| 27 | height: ${(props) => props.diameter ?? DEFAULT_DIAMETER}px; |
| 28 | border-radius: 50%; |
| 29 | border: 1px solid rgba(255, 255, 255, 0.75); |
| 30 | margin: 0 2px; |
| 31 | ${(props) => (props.shouldBlink ?? false) && blinkAnimation}; |
| 32 | `; |
| 33 | |
| 34 | export default BlinkingDot; |