-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cra rxjs issue pr card style fix (#1943)
* chore: in progress * chore: issue PR card styled * chore: fix format * chore: fix Sonar bug * chore: fix Sonar bug * chore: fix Sonar bug * chore: fix Sonar code smells * chore: fix Sonar code duplicate
- Loading branch information
Showing
16 changed files
with
228 additions
and
330 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
41 changes: 41 additions & 0 deletions
41
cra-rxjs-styled-components/src/components/issue-pr-card/IssuePRCard.tsx
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,41 @@ | ||
import ClosedIssueIcon from '../icons/ClosedIssueIcon'; | ||
import MessageIcon from '../icons/MessageIcon'; | ||
import OpenIssueIcon from '../icons/OpenIssueIcon'; | ||
import { IssuePRCardWrapper } from './IssuePRCard.styles'; | ||
import { IssuePRData, State } from '../../types/types'; | ||
import IssuePRCardInfo from './IssuePRCardInfo'; | ||
import { ClosedPRIcon } from '../icons'; | ||
import OpenPRIcon from '../icons/OpenPRIcon'; | ||
|
||
interface Props { | ||
data: IssuePRData; | ||
type: 'pr' | 'issue'; | ||
} | ||
|
||
export default function IssuePRCard({ data, type }: Props) { | ||
const getIssueIcon = (state: State) => { | ||
switch (state) { | ||
case 'closed': | ||
return type === 'issue' ? <ClosedIssueIcon /> : <ClosedPRIcon />; | ||
case 'open': | ||
default: | ||
return type === 'issue' ? <OpenIssueIcon /> : <OpenPRIcon />; | ||
} | ||
}; | ||
return ( | ||
<IssuePRCardWrapper> | ||
<div className="left"> | ||
{getIssueIcon(data.state)} | ||
<IssuePRCardInfo {...data} /> | ||
</div> | ||
<div className="right"> | ||
{data.comments > 0 && ( | ||
<div className="message"> | ||
<MessageIcon /> | ||
<span className="count">{data.comments}</span> | ||
</div> | ||
)} | ||
</div> | ||
</IssuePRCardWrapper> | ||
); | ||
} |
46 changes: 46 additions & 0 deletions
46
cra-rxjs-styled-components/src/components/issue-pr-card/IssuePRCardInfo.tsx
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,46 @@ | ||
import { IssuePRData } from '@/types/types'; | ||
import { getTextColor } from '../../helpers/dynamicColor'; | ||
import { FormatDistance } from '../../helpers/format-distance'; | ||
|
||
export default function IssuePRCardInfo(data: IssuePRData) { | ||
const baseDate = new Date(); | ||
const formatDistance = FormatDistance; | ||
|
||
return ( | ||
<div className="info"> | ||
<div className="card_top"> | ||
<a className="heading" href={data.url} target="_blank" rel="noreferrer"> | ||
{data.title} | ||
</a> | ||
{(data.labels || []).map((label) => ( | ||
<span | ||
key={label.name} | ||
className="card_label" | ||
style={{ | ||
backgroundColor: `#${label.color || 'ccc'}`, | ||
color: getTextColor(`#${label.color || 'ccc'}`), | ||
}} | ||
> | ||
{label.name} | ||
</span> | ||
))} | ||
</div> | ||
<div className="sub_heading"> | ||
<span className="opened_num">#{data.number}</span> | ||
{data.state === 'open' ? ( | ||
<span className="opened_day"> | ||
opened{' '} | ||
{formatDistance({ | ||
date: data.created_at, | ||
dateToCompare: baseDate, | ||
})}{' '} | ||
ago | ||
</span> | ||
) : ( | ||
<span className="opened_day">closed {data.closed_at} ago</span> | ||
)} | ||
{data.user && <span className="opened_by">by {data.user.login}</span>} | ||
</div> | ||
</div> | ||
); | ||
} |
35 changes: 0 additions & 35 deletions
35
...rxjs-styled-components/src/components/pull-request-issue-info/PullRequestInfo.stories.tsx
This file was deleted.
Oops, something went wrong.
33 changes: 0 additions & 33 deletions
33
cra-rxjs-styled-components/src/components/pull-request-issue-info/PullRequestIssueInfo.tsx
This file was deleted.
Oops, something went wrong.
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.