import React from "react"; import styled from "styled-components"; import { readableColorIsBlack } from "color2k"; const StyledCursor = styled.div.attrs(({ top, left }) => ({ style: { transform: `translate(${left}px, ${top}px)`, }, }))` top: 0; left: 0; position: fixed; display: flex; flex-direction: row; align-items: center; z-index: 210; `; const CursorName = styled.div` color: ${({ textColor }) => textColor}; font-weight: bold; padding: 0 0.5em; border-radius: 2px; max-width: 5em; overflow: hidden; text-overflow: ellipsis; margin-left: -0.5em; margin-top: 1.7em; whitespace: nowrap; background-color: ${({ color }) => color}; `; export const Cursor = ({ color = "#666", size = 40, pos, text }) => { const textColor = readableColorIsBlack(color) ? "#222" : "#EEE"; return ( {text} ); }; export default Cursor;