-
-
Notifications
You must be signed in to change notification settings - Fork 218
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implemented the workspace issues table (#3340)
- Loading branch information
1 parent
c2e0aa2
commit ba1bc51
Showing
9 changed files
with
670 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { Meta, StoryObj } from "@storybook/react"; | ||
import { IssueStateAuthorIcon } from "../Issues/IssueStateAuthorIcon"; | ||
|
||
type Story = StoryObj<typeof IssueStateAuthorIcon>; | ||
|
||
const meta: Meta<typeof IssueStateAuthorIcon> = { | ||
title: "Components/Issues/IssueStateAuthorIcon", | ||
component: IssueStateAuthorIcon, | ||
args: { | ||
author: "brandonroberts", | ||
}, | ||
}; | ||
|
||
export default meta; | ||
|
||
export const OpenPR: Story = { | ||
args: { | ||
state: "open", | ||
}, | ||
}; | ||
|
||
export const ClosedPR: Story = { | ||
args: { | ||
state: "closed", | ||
}, | ||
}; | ||
|
||
export const Reopened: Story = { | ||
args: { | ||
state: "reopened", | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { IssueClosedIcon, IssueOpenedIcon, IssueReopenedIcon } from "@primer/octicons-react"; | ||
import Link from "next/link"; | ||
import { Avatar } from "components/atoms/Avatar/avatar-hover-card"; | ||
|
||
type IssueState = DbRepoIssueEvents["issue_state"]; | ||
|
||
function getPullRequestStateIcon(state: IssueState) { | ||
const size = 14; | ||
|
||
switch (state) { | ||
case "open": | ||
return <IssueOpenedIcon aria-label="open pull request" size={size} className="text-white" />; | ||
|
||
case "reopened": | ||
return <IssueReopenedIcon aria-label="open pull request" size={size} className="text-white" />; | ||
|
||
case "closed": | ||
return <IssueClosedIcon size={size} aria-label="closed pull request" className="text-white" />; | ||
} | ||
} | ||
|
||
export const IssueStateAuthorIcon = ({ state, author }: { state: IssueState; author: string }) => { | ||
let backgroundColor = ""; | ||
|
||
switch (state) { | ||
case "open": | ||
backgroundColor = "bg-green-600"; | ||
break; | ||
|
||
case "reopened": | ||
backgroundColor = "bg-green-600"; | ||
break; | ||
case "closed": | ||
backgroundColor = "bg-red-600"; | ||
break; | ||
} | ||
|
||
return ( | ||
<div className="relative w-max"> | ||
<Link href={`/user/${author}`} title={`User profile for ${author}`}> | ||
<Avatar contributor={author} size="medium" /> | ||
</Link> | ||
<div | ||
className={`absolute -bottom-[10px] -right-[12px] p-1 border-[2px] border-white rounded-full [&_svg]:absolute [&_svg]:top-[3.5px] [&_svg]:left-[3.5px] ${backgroundColor}`} | ||
style={{ width: "25px", height: "25px" }} | ||
> | ||
{getPullRequestStateIcon(state)} | ||
</div> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.