ClusterTab.styled.ts 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. import styled, { css } from 'styled-components';
  2. import { ServerStatus } from 'generated-sources';
  3. export const Wrapper = styled.li.attrs({ role: 'menuitem' })<{
  4. isOpen: boolean;
  5. }>(
  6. ({ theme, isOpen }) => css`
  7. font-size: 14px;
  8. font-weight: 500;
  9. user-select: none;
  10. display: grid;
  11. grid-template-columns: min-content min-content auto min-content;
  12. grid-template-areas: 'title status . chevron';
  13. gap: 0 5px;
  14. padding: 0.5em 0.75em;
  15. cursor: pointer;
  16. text-decoration: none;
  17. margin: 0;
  18. line-height: 20px;
  19. align-items: center;
  20. color: ${isOpen ? theme.menu.color.isOpen : theme.menu.color.normal};
  21. background-color: ${theme.menu.backgroundColor.normal};
  22. &:hover {
  23. background-color: ${theme.menu.backgroundColor.hover};
  24. color: ${theme.menu.color.hover};
  25. }
  26. `
  27. );
  28. export const Title = styled.div`
  29. grid-area: title;
  30. white-space: nowrap;
  31. max-width: 110px;
  32. overflow: hidden;
  33. text-overflow: ellipsis;
  34. `;
  35. export const StatusIconWrapper = styled.svg.attrs({
  36. viewBox: '0 0 4 4',
  37. xmlns: 'http://www.w3.org/2000/svg',
  38. })`
  39. grid-area: status;
  40. fill: none;
  41. width: 4px;
  42. height: 4px;
  43. `;
  44. export const StatusIcon = styled.circle.attrs({
  45. cx: 2,
  46. cy: 2,
  47. r: 2,
  48. role: 'status-circle',
  49. })<{ status: ServerStatus }>(({ theme, status }) => {
  50. const statusColor: {
  51. [k in ServerStatus]: string;
  52. } = {
  53. [ServerStatus.ONLINE]: theme.menu.statusIconColor.online,
  54. [ServerStatus.OFFLINE]: theme.menu.statusIconColor.offline,
  55. [ServerStatus.INITIALIZING]: theme.menu.statusIconColor.initializing,
  56. };
  57. return css`
  58. fill: ${statusColor[status]};
  59. `;
  60. });
  61. export const ChevronWrapper = styled.svg.attrs({
  62. viewBox: '0 0 10 6',
  63. xmlns: 'http://www.w3.org/2000/svg',
  64. })`
  65. grid-area: chevron;
  66. width: 10px;
  67. height: 6px;
  68. fill: none;
  69. `;
  70. type ChevronIconProps = { $open: boolean };
  71. export const ChevronIcon = styled.path.attrs<ChevronIconProps>(({ $open }) => ({
  72. d: $open ? 'M8.99988 5L4.99988 1L0.999878 5' : 'M1 1L5 5L9 1',
  73. }))<ChevronIconProps>`
  74. stroke: ${({ theme }) => theme.menu.chevronIconColor};
  75. `;