styled.ts 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import styled, { css } from 'styled-components';
  2. const MarkupStyle: Record<string, any> = {
  3. Highlight: css<{isCovered: boolean; bdcolor: string}>`
  4. background-color: ${props => (props.isCovered ? '#297fb8' : props.bdcolor)};
  5. `,
  6. Underline: css<{isCovered: boolean; bdcolor: string}>`
  7. border-bottom: 2px solid ${props => (props.isCovered ? '#297fb8' : props.bdcolor)};
  8. `,
  9. Squiggly: css<{isCovered: boolean; bdcolor: string}>`
  10. overflow: hidden;
  11. &:before {
  12. content: '';
  13. position: absolute;
  14. background: radial-gradient(ellipse, transparent, transparent 8px, ${props => (props.isCovered ? '#297fb8' : props.bdcolor)} 9px, ${props => (props.isCovered ? '#297fb8' : props.bdcolor)} 10px, transparent 11px);
  15. background-size: 22px 26px;
  16. width: 100%;
  17. height: 5px;
  18. left: 0;
  19. bottom: 2px;
  20. }
  21. &:after {
  22. content: '';
  23. position: absolute;
  24. background: radial-gradient(ellipse, transparent, transparent 8px, ${props => (props.isCovered ? '#297fb8' : props.bdcolor)} 9px, ${props => (props.isCovered ? '#297fb8' : props.bdcolor)} 10px, transparent 11px);
  25. background-size: 22px 26px;
  26. width: 100%;
  27. height: 5px;
  28. bottom: -1px;
  29. left: 11px;
  30. background-position: 0px -22px;
  31. }
  32. `,
  33. StrikeOut: css<{isCovered: boolean; bdcolor: string}>`
  34. &:after {
  35. content: '';
  36. position: absolute;
  37. height: 2px;
  38. width: 100%;
  39. left: 0;
  40. top: 40%;
  41. background-color: ${props => (props.isCovered ? '#297fb8' : props.bdcolor)};
  42. };
  43. `,
  44. };
  45. export const Markup = styled('div')<{position: Record<string, any>; bdcolor: string; markupType: string; opacity: number; isCovered?: boolean}>`
  46. position: absolute;
  47. cursor: pointer;
  48. opacity: ${props => props.opacity};
  49. ${props => css`
  50. top: ${props.position.top};
  51. left: ${props.position.left};
  52. width: ${props.position.width};
  53. height: ${props.position.height};
  54. `}
  55. ${props => MarkupStyle[props.markupType]}
  56. `;