Issue.tsx 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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 xmlns="http://www.w3.org/2000/svg" width={size} height={size} viewBox="0 0 16 16" fill="currentColor">
  22. <rect x="1" y="8" width="3" height="6" rx="1" />
  23. <rect x="6" y="5" width="3" height="9" rx="1" fillOpacity={priority < 4 ? "1" : "0.4"} />
  24. <rect x="11" y="2" width="3" height="12" rx="1" fillOpacity={priority < 3 ? "1" : "0.4"} />
  25. </svg>
  26. )
  27. export const ChevronRight = () => (
  28. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" className="w-[1em] h-[1em] inline-block">
  29. <path fillRule="evenodd" 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" clipRule="evenodd" />
  30. </svg>
  31. )
  32. export const Issue = ({ id, title, priority, state, parent }: IssueProps) => {
  33. return (
  34. <div className="relative b2 p-2">
  35. <div className="absolute -left-4 md:-left-8 top-1/2 top-0 origin-center -translate-y-1/2 -translate-x-1/2 w-3 h-3 rounded-lg bg-eggplant">
  36. {(state === "started" && priority === PRIORITY_URGENT) && <div className="absolute animate-ping h-full w-full rounded-full bg-eggplant opacity-75" />}
  37. </div>
  38. <div className="flex gap-1 md:gap-3 items-center">
  39. <div className="hidden md:block flex-shrink-0 text-nightshade-300 w-[16px]">{priority !== PRIORITY_UNSET && <BarIcon priority={priority} size={16} />}</div>
  40. <div className="flex-shrink-0 w-20 text-gray-2 truncate">{id}</div>
  41. <div className="text-black flex-auto gap-1">
  42. <span>{title}</span>
  43. {parent && (
  44. <span className="hidden md:block">
  45. <span className="text-gray-2 flex-shrink-0"><ChevronRight /></span>
  46. <span className="text-gray-2 truncate">{parent.title}</span>
  47. </span>
  48. )}
  49. </div>
  50. </div>
  51. </div>
  52. )
  53. }
  54. export default Issue