Skip to content

Commit 29793b0

Browse files
committed
fix: export theme
1 parent 9d1c32b commit 29793b0

File tree

8 files changed

+75
-60
lines changed

8 files changed

+75
-60
lines changed
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
export type Article = {
2+
url: string;
3+
title: string;
4+
};
5+
6+
export type AttractionProps = {
7+
description: string;
8+
title: string;
9+
location: string;
10+
articles?: Article[];
11+
Image: any;
12+
Link?: React.ElementType;
13+
};

src/components/Attraction/index.tsx

+7-19
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,6 @@
1-
import React from "react";
21
import { Grid, Typography } from "@mui/material";
32
import EnhancedLink from "../EnhancedLink";
4-
5-
type Article = {
6-
url: string;
7-
title: string;
8-
};
9-
10-
type AttractionProps = {
11-
description: string;
12-
title: string;
13-
location: string;
14-
articles?: Article[];
15-
Image: any;
16-
Link?: React.ElementType;
17-
};
3+
import type { AttractionProps } from "./Attraction";
184

195
function Attraction(props: AttractionProps) {
206
const { description, title, location, articles, Image, Link } = props;
@@ -39,9 +25,11 @@ function Attraction(props: AttractionProps) {
3925
},
4026
}}
4127
>
42-
<Grid item xs={12} sm={3}>
43-
<Image />
44-
</Grid>
28+
{Image !== undefined && (
29+
<Grid item xs={12} sm={3}>
30+
<Image />
31+
</Grid>
32+
)}
4533

4634
<Grid
4735
container
@@ -66,14 +54,14 @@ function Attraction(props: AttractionProps) {
6654
sx={{
6755
marginTop: {
6856
xs: `10px`,
69-
// sm: `0`
7057
},
7158
}}
7259
>
7360
<Typography>立刻探索{location}</Typography>
7461
<ul
7562
style={{
7663
paddingInlineStart: 0,
64+
listStyleType: `none`,
7765
}}
7866
>
7967
{articles &&

src/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
export * from "./components";
2+
export * from "./themes";

src/themes/components/MuiTypography.js

-28
This file was deleted.

src/themes/components/index.js

-7
This file was deleted.

src/themes/dark.theme.ts

+24-2
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,34 @@
22

33
import { createTheme } from "@mui/material";
44
import { blueGrey, cyan, pink } from "@mui/material/colors";
5-
import components from "./components";
5+
import typography from "./typography";
6+
7+
declare module "@mui/material/styles" {
8+
interface Palette {
9+
blue: Palette["primary"];
10+
navbar: Palette["primary"];
11+
}
12+
13+
interface PaletteOptions {
14+
blue: PaletteOptions["primary"];
15+
navbar: PaletteOptions["primary"];
16+
}
17+
}
618

719
export const darkTheme = createTheme({
8-
components,
20+
// components,
21+
typography,
922
palette: {
1023
mode: "dark",
24+
navbar: {
25+
main: "#f5f5f5",
26+
// contrastText: '#999'
27+
},
28+
blue: {
29+
light: "#337ab7",
30+
main: "#0056b3",
31+
dark: "#0f457f",
32+
},
1133
primary: {
1234
main: pink["A200"],
1335
},

src/themes/light.theme.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
// src/themes/dark.theme.js
1+
// src/themes/light.theme.ts
22

33
import { createTheme } from "@mui/material";
4-
import components from "./components";
5-
4+
import typography from "./typography";
65
declare module "@mui/material/styles" {
76
interface Palette {
87
blue: Palette["primary"];
@@ -16,7 +15,7 @@ declare module "@mui/material/styles" {
1615
}
1716

1817
export const lightTheme = createTheme({
19-
components,
18+
typography,
2019
palette: {
2120
mode: "light",
2221
navbar: {

src/themes/typography.ts

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { TypographyOptions } from "@mui/material/styles/createTypography";
2+
3+
const typographyOptions: TypographyOptions = {
4+
fontSize: 16,
5+
h1: {
6+
fontSize: 24,
7+
fontWeight: 600,
8+
},
9+
h2: {
10+
fontSize: 22,
11+
fontWeight: 600,
12+
},
13+
h3: {
14+
fontSize: 20,
15+
fontWeight: 600,
16+
},
17+
h4: {
18+
fontSize: 18,
19+
fontWeight: 600,
20+
},
21+
h5: {
22+
fontSize: 16,
23+
fontWeight: 600,
24+
},
25+
};
26+
27+
export default typographyOptions;

0 commit comments

Comments
 (0)