Skip to content

Commit ecd5179

Browse files
committed
fix: align start in issue page
1 parent aabb7df commit ecd5179

File tree

3 files changed

+102
-44
lines changed

3 files changed

+102
-44
lines changed

src/Pages/IssuePage/IssuePage.jsx

Lines changed: 47 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useContext } from "react";
22
import { IssueContext } from "../../context/issueContext";
3-
import { Center } from "../../style/Center.styled";
3+
import { NoAlignCenter, RemoveMinHeight } from "../../style/Center.styled";
44
import IssueSearch from "./IssuePageSearch";
55
import IssuePageHeader from "./IssuePageHeader";
66
import IssuePageList from "./IssuePageList";
@@ -39,49 +39,54 @@ const IssuePage = () => {
3939
};
4040

4141
return (
42-
<Center>
43-
<IssueSearch
44-
handleSearchClick={handleSearchClick}
45-
labelNum={labels.length}
46-
owner={owner}
47-
repoName={repoName}
48-
/>
49-
<IssueAllContainer>
50-
{!isDefaultState() && (
51-
<Button
52-
leadingVisual={XCircleFillIcon}
53-
variant="invisible"
54-
onClick={handleClearAll}
55-
>
56-
Clear current search query, filters, and sorts
57-
</Button>
58-
)}
59-
<IssuePageHeader
60-
openCount={allIssues.openCount}
61-
closedCount={allIssues.closedCount}
62-
stateOpenOrClosed={stateOpenOrClosed}
63-
setStateOpenOrClosed={setStateOpenOrClosed}
64-
authors={authors}
65-
labels={labels}
66-
handleAuthorChange={(author) => handleFilterChange("author", author)}
67-
handleLabelChange={(labels) => {
68-
const formattedString =
69-
labels.length > 0
70-
? labels.map((label) => `label:"${label}"`).join(" ")
71-
: "all";
72-
handleFilterChange("label", formattedString);
73-
}}
74-
/>
75-
<IssuePageList
76-
issuesToDisplay={apiResult}
77-
stateOpenOrClosed={stateOpenOrClosed}
78-
repoName={repoName}
79-
handleCheckboxChange={handleCheckboxChange}
42+
<>
43+
<RemoveMinHeight />
44+
<NoAlignCenter>
45+
<IssueSearch
46+
handleSearchClick={handleSearchClick}
47+
labelNum={labels.length}
8048
owner={owner}
49+
repoName={repoName}
8150
/>
82-
<IssuePagePagination />
83-
</IssueAllContainer>
84-
</Center>
51+
<IssueAllContainer>
52+
{!isDefaultState() && (
53+
<Button
54+
leadingVisual={XCircleFillIcon}
55+
variant="invisible"
56+
onClick={handleClearAll}
57+
>
58+
Clear current search query, filters, and sorts
59+
</Button>
60+
)}
61+
<IssuePageHeader
62+
openCount={allIssues.openCount}
63+
closedCount={allIssues.closedCount}
64+
stateOpenOrClosed={stateOpenOrClosed}
65+
setStateOpenOrClosed={setStateOpenOrClosed}
66+
authors={authors}
67+
labels={labels}
68+
handleAuthorChange={(author) =>
69+
handleFilterChange("author", author)
70+
}
71+
handleLabelChange={(labels) => {
72+
const formattedString =
73+
labels.length > 0
74+
? labels.map((label) => `label:"${label}"`).join(" ")
75+
: "all";
76+
handleFilterChange("label", formattedString);
77+
}}
78+
/>
79+
<IssuePageList
80+
issuesToDisplay={apiResult}
81+
stateOpenOrClosed={stateOpenOrClosed}
82+
repoName={repoName}
83+
handleCheckboxChange={handleCheckboxChange}
84+
owner={owner}
85+
/>
86+
<IssuePagePagination />
87+
</IssueAllContainer>
88+
</NoAlignCenter>
89+
</>
8590
);
8691
};
8792

src/components/Header.jsx

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import { Header, Avatar, Octicon } from "@primer/react";
2+
import { MarkGithubIcon } from "@primer/octicons-react";
3+
import { useParams } from "react-router-dom";
4+
5+
const PageHeader = () => {
6+
const { owner, repoName } = useParams();
7+
return (
8+
<Header>
9+
<Header.Item>
10+
<Header.Link
11+
href="#"
12+
sx={{
13+
fontSize: 2,
14+
}}
15+
>
16+
<Octicon
17+
icon={MarkGithubIcon}
18+
size={32}
19+
sx={{
20+
mr: 2,
21+
}}
22+
/>
23+
<span>
24+
{owner}/{repoName}
25+
</span>
26+
</Header.Link>
27+
</Header.Item>
28+
<Header.Item full></Header.Item>
29+
<Header.Item
30+
sx={{
31+
mr: 0,
32+
}}
33+
>
34+
<Avatar
35+
src="https://github.com/octocat.png"
36+
size={20}
37+
square
38+
alt="@octocat"
39+
/>
40+
</Header.Item>
41+
</Header>
42+
);
43+
};
44+
45+
export default PageHeader;

src/style/Center.styled.jsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
1-
import styled from "styled-components";
1+
import styled, { createGlobalStyle } from "styled-components";
22

3-
export const Center = styled.div`
3+
export const NoAlignCenter = styled.div`
44
display: flex;
55
width: 100vw;
66
flex-wrap: wrap;
77
justify-content: center;
8+
align-items: flex-start;
9+
margin-top: 30px;
10+
`;
11+
12+
export const RemoveMinHeight = createGlobalStyle`
13+
body {
14+
min-height: auto !important; /* 覆蓋全局樣式 */
15+
}
816
`;

0 commit comments

Comments
 (0)