Skip to content

Commit

Permalink
chore: fix format
Browse files Browse the repository at this point in the history
  • Loading branch information
hdJerry committed Aug 18, 2023
1 parent 8286304 commit 5604154
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,22 @@ import { IssuePRCardWrapper } from './IssuePRCard.styles';
import { State } from '../../types/types';
import IssuePRCardInfo from './IssuePRCardInfo';
import { Issue } from '../repo-issues/Issues/Issue.type';
import { ClosedPRIcon } from '../icons';
import OpenPRIcon from '../icons/OpenPRIcon';

interface Props {
data: Issue | any;
type: 'pr' | 'issue';
}

export default function IssuePRCard({data}: Props) {
export default function IssuePRCard({ data, type }: Props) {
const getIssueIcon = (state: State) => {
switch (state) {
case 'closed':
return <ClosedIssueIcon />;
return type === 'issue' ? <ClosedIssueIcon /> : <ClosedPRIcon />;
case 'open':
default:
return <OpenIssueIcon />;
return type === 'issue' ? <OpenIssueIcon /> : <OpenPRIcon />;
}
};
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ OpenPullRequests.args = {
merged_at: null,
repository_url: '/',
comments: '',
labels: [{name: 'dependency', color: '633bcc'}],
labels: [{ name: 'dependency', color: '633bcc' }],
},
{
title: '[Nuxt - Pinia - Tailwind] Get PRs comments',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export type PullRequest = {
merged_at: string | null;
repository_url: string;
comments: any;
labels: {name: string; color: string}[];
labels: { name: string; color: string }[];
};

export type PullRequests = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export default function PullRequestView({
{pullRequests.map((pr, index) => (
<IssuePRCard
key={pr.number}
type="pr"
data={{
title: pr.title,
number: pr.number,
Expand All @@ -89,22 +90,24 @@ export default function PullRequestView({
</Content>

<PaginationContainer>
{ pageCount > 1 && (<ReactPaginate
breakLabel="..."
nextLabel="Next >"
marginPagesDisplayed={1}
onPageChange={handlePageClick}
pageRangeDisplayed={7}
pageCount={pageCount}
previousLabel="< Previous"
renderOnZeroPageCount={() => null}
containerClassName={'pagination'}
pageClassName={'pagination__item'}
previousClassName={'pagination__link_end'}
nextClassName={'pagination__link_end'}
disabledClassName={'pagination__link--disabled'}
activeClassName={'pagination__link--active'}
/>)}
{pageCount > 1 && (
<ReactPaginate
breakLabel="..."
nextLabel="Next >"
marginPagesDisplayed={1}
onPageChange={handlePageClick}
pageRangeDisplayed={7}
pageCount={pageCount}
previousLabel="< Previous"
renderOnZeroPageCount={() => null}
containerClassName={'pagination'}
pageClassName={'pagination__item'}
previousClassName={'pagination__link_end'}
nextClassName={'pagination__link_end'}
disabledClassName={'pagination__link--disabled'}
activeClassName={'pagination__link--active'}
/>
)}
</PaginationContainer>
</Wrapper>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export default function IssueView({
/>
)}
{issues.map((issue, index) => (
<IssuePRCard data={issue} key={index} />
<IssuePRCard type="issue" data={issue} key={index} />
))}
</Content>
<PaginationContainer>
Expand Down
30 changes: 15 additions & 15 deletions cra-rxjs-styled-components/src/helpers/dynamicColor.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
function getRGB(c: string | number) {
return typeof c === 'string' ? parseInt(c, 16) : c;
return typeof c === 'string' ? parseInt(c, 16) : c;
}

function getsRGB(c: string | number) {
return getRGB(c) / 255 <= 0.03928
? getRGB(c) / 255 / 12.92
: Math.pow((getRGB(c) / 255 + 0.055) / 1.055, 2.4);
return getRGB(c) / 255 <= 0.03928
? getRGB(c) / 255 / 12.92
: Math.pow((getRGB(c) / 255 + 0.055) / 1.055, 2.4);
}

function getLuminance(hexColor: string) {
return (
0.2126 * getsRGB(hexColor.substr(1, 2)) +
0.7152 * getsRGB(hexColor.substr(3, 2)) +
0.0722 * getsRGB(hexColor.substr(-2))
);
return (
0.2126 * getsRGB(hexColor.substr(1, 2)) +
0.7152 * getsRGB(hexColor.substr(3, 2)) +
0.0722 * getsRGB(hexColor.substr(-2))
);
}

function getContrast(f: string, b: string) {
const L1 = getLuminance(f);
const L2 = getLuminance(b);
return (Math.max(L1, L2) + 0.1) / (Math.min(L1, L2) + 0.1);
const L1 = getLuminance(f);
const L2 = getLuminance(b);
return (Math.max(L1, L2) + 0.1) / (Math.min(L1, L2) + 0.1);
}

export function getTextColor(bgColor: string) {
const whiteContrast = getContrast(bgColor, '#ffffff');
const blackContrast = getContrast(bgColor, '#000000');
const whiteContrast = getContrast(bgColor, '#ffffff');
const blackContrast = getContrast(bgColor, '#000000');

return whiteContrast > blackContrast ? '#ffffff' : '#000000';
return whiteContrast > blackContrast ? '#ffffff' : '#000000';
}

0 comments on commit 5604154

Please sign in to comment.