Skip to content

Commit 11c1bf6

Browse files
优化部分 ui;点击功能选项即可重置组件
1 parent 06fd5ce commit 11c1bf6

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

src/app/features/article/articleViewer.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,11 @@
1515
margin: 0 0 20px;
1616
border-left: 5px solid #eee;
1717
}
18+
.articleViewer a {
19+
color: #3498db;
20+
text-decoration: none;
21+
}
22+
.articleViewer a:hover {
23+
color: #0056b3;
24+
text-decoration: none;
25+
}

src/app/index.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ const theme: Theme = {
2323

2424
export default function App() {
2525
const [nowFeature, setNowFeature] = useState<number>(0);
26-
const NowFeatureComponent = Features[nowFeature][1];
26+
const NowFeatureComponent =
27+
nowFeature >= 0 ? Features[nowFeature][1] : React.Fragment;
2728

2829
const [myInfo, setMyInfo] = useState<UserSummary | null>(null);
2930
const [fetchError, setFetchError] = useState<unknown | undefined>(undefined);
@@ -38,6 +39,9 @@ export default function App() {
3839
});
3940
return () => void (ignore = true);
4041
}, []);
42+
useEffect(() => {
43+
if (nowFeature < 0) setNowFeature(-nowFeature - 1);
44+
});
4145

4246
return (
4347
<FluentProvider theme={theme}>
@@ -64,7 +68,8 @@ export default function App() {
6468
<div>
6569
{Features.map((s, i) => (
6670
<button
67-
onClick={() => setNowFeature(i)}
71+
type="button"
72+
onClick={() => setNowFeature(-i - 1)}
6873
key={i}
6974
className="nav-item"
7075
style={{ fontWeight: nowFeature === i ? 'bold' : 'normal' }}

src/app/style.css

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
a {
2-
color: #3498db;
3-
text-decoration: none;
4-
}
51
.root {
62
display: flex;
73
flex-direction: column;
@@ -13,7 +9,7 @@ a {
139
overflow: hidden;
1410
tab-size: 4;
1511
}
16-
nav {
12+
.root > nav {
1713
height: 4em;
1814
align-items: center;
1915
display: flex;
@@ -22,7 +18,7 @@ nav {
2218
border-bottom: 1px solid #f0f0f0;
2319
background-color: white;
2420
}
25-
.nav-item {
21+
.root > nav .nav-item {
2622
margin-left: 1em;
2723
margin-right: 1em;
2824
cursor: pointer;
@@ -32,7 +28,7 @@ nav {
3228
padding: unset;
3329
}
3430
.feature {
35-
flex: auto;
31+
flex: 1;
3632
overflow: hidden;
3733
}
3834
a:focus,
@@ -45,6 +41,7 @@ a:hover {
4541
font-size: 16px;
4642
font-weight: bold;
4743
text-align: center;
44+
text-decoration: none;
4845
}
4946
.username-badge {
5047
display: inline-block;

0 commit comments

Comments
 (0)