Issue.tsx 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. export type IssueProps = {
  2. id: string
  3. title: string
  4. priority: number
  5. state: string
  6. parent?: {
  7. id: string
  8. title: string
  9. }
  10. }
  11. export type BarIconProps = {
  12. priority: number
  13. size: number
  14. }
  15. const PRIORITY_UNSET = 0
  16. const PRIORITY_URGENT = 1
  17. const PRIORITY_HIGH = 2
  18. const PRIORITY_MEDIUM = 3
  19. const PRIORITY_LOW = 4
  20. export const BarIcon = ({ priority, size }: BarIconProps) => (
  21. <svg
  22. xmlns="http://www.w3.org/2000/svg"
  23. width={size}
  24. height={size}
  25. viewBox="0 0 16 16"
  26. fill="currentColor"
  27. >
  28. <rect x="1" y="8" width="3" height="6" rx="1" />
  29. <rect
  30. x="6"
  31. y="5"
  32. width="3"
  33. height="9"
  34. rx="1"
  35. fillOpacity={priority < 4 ? "1" : "0.4"}
  36. />
  37. <rect
  38. x="11"
  39. y="2"
  40. width="3"
  41. height="12"
  42. rx="1"
  43. fillOpacity={priority < 3 ? "1" : "0.4"}
  44. />
  45. </svg>
  46. )
  47. export const ChevronRight = () => (
  48. <svg
  49. xmlns="http://www.w3.org/2000/svg"
  50. viewBox="0 0 20 20"
  51. fill="currentColor"
  52. className="inline-block h-[1em] w-[1em]"
  53. >
  54. <path
  55. fillRule="evenodd"
  56. d="M7.21 14.77a.75.75 0 01.02-1.06L11.168 10 7.23 6.29a.75.75 0 111.04-1.08l4.5 4.25a.75.75 0 010 1.08l-4.5 4.25a.75.75 0 01-1.06-.02z"
  57. clipRule="evenodd"
  58. />
  59. </svg>
  60. )
  61. export const Issue = ({ id, title, priority, state, parent }: IssueProps) => {
  62. return (
  63. <div className="b2 relative p-2">
  64. <div className="absolute -left-4 top-1/2 top-0 h-3 w-3 origin-center -translate-y-1/2 -translate-x-1/2 rounded-lg bg-eggplant md:-left-8">
  65. {state === "started" && priority === PRIORITY_URGENT && (
  66. <div className="absolute h-full w-full animate-ping rounded-full bg-eggplant opacity-75" />
  67. )}
  68. </div>
  69. <div className="flex items-center gap-1 md:gap-3">
  70. <div className="hidden w-[16px] flex-shrink-0 text-nightshade-300 md:block">
  71. {priority !== PRIORITY_UNSET && (
  72. <BarIcon priority={priority} size={16} />
  73. )}
  74. </div>
  75. <div className="w-20 flex-shrink-0 truncate text-gray-2">{id}</div>
  76. <div className="flex-auto gap-1 text-black">
  77. <span>{title}</span>
  78. {parent && (
  79. <span className="hidden md:block">
  80. <span className="flex-shrink-0 text-gray-2">
  81. <ChevronRight />
  82. </span>
  83. <span className="truncate text-gray-2">{parent.title}</span>
  84. </span>
  85. )}
  86. </div>
  87. </div>
  88. </div>
  89. )
  90. }
  91. export default Issue