Skip to content

Commit 0678c0d

Browse files
SoeckaTechQuery
andauthored
[refactor] replace React Bootstrap with MUI to optimize UX (#70)
Co-authored-by: South Drifted <[email protected]>
1 parent 5aa9782 commit 0678c0d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+4452
-2899
lines changed

.env

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
NEXT_PUBLIC_SITE_NAME = idea2app
22
NEXT_PUBLIC_SITE_SUMMARY = 全行业信息化转型专家
3-
NEXT_PUBLIC_LOGO = https://github.com/idea2app.png
3+
NEXT_PUBLIC_LOGO = /idea2app.svg
44

55
NEXT_PUBLIC_CACHE_HOST = https://cache.idea2.app
66

77
NEXT_PUBLIC_SENTRY_DSN = https://03e5d951172f411a04c1bab44022e22b@o4506471366852608.ingest.sentry.io/4506484563705856
88
SENTRY_ORG = idea2app
99
SENTRY_PROJECT = ows
1010

11-
LARK_API_HOST = https://open.larksuite.com/open-apis/
12-
NEXT_PUBLIC_LARK_BASE = McGRbzEInauTTOsWX1blxbN1grh
13-
NEXT_PUBLIC_CLIENT_TABLE = tblRNMvpJ1UZwJW2
14-
NEXT_PUBLIC_PROJECT_TABLE = tblwaxbQ35uX2lUS
15-
NEXT_PUBLIC_MEMBER_TABLE = tblD7p7XAcrinGqO
16-
NEXT_PUBLIC_MEMBER_VIEW = vewLspr5VK
11+
NEXT_PUBLIC_LARK_BASE = bascnFeH8Q37XWX0LLlBB9ojQzf
12+
NEXT_PUBLIC_CLIENT_TABLE = tblsb0vx4fqjSrGL
13+
NEXT_PUBLIC_PROJECT_TABLE = tblCxasoUUub3buB
14+
NEXT_PUBLIC_MEMBER_TABLE = tblJ98JHGEX0o6ij
15+
NEXT_PUBLIC_MEMBER_VIEW = vewLf4M0P8

.eslintrc.json

Lines changed: 0 additions & 10 deletions
This file was deleted.

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
vercel-org-id: ${{ secrets.VERCEL_ORG_ID }}
2929
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }}
3030
working-directory: ./
31-
vercel-args: --prod
31+
vercel-args: ${{ github.ref == 'refs/heads/main' && '--prod' || '' }}
3232

3333
- name: Lark notification
3434
uses: foxundermoon/feishu-action@v2

.github/workflows/pull-request.yml

Lines changed: 0 additions & 61 deletions
This file was deleted.

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM node:20-slim AS base
1+
FROM node:22-slim AS base
22
RUN apt-get update && \
33
apt-get install ca-certificates curl libjemalloc-dev -y --no-install-recommends && \
44
rm -rf /var/lib/apt/lists/*

babel.config.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ module.exports = {
55
'@babel/preset-react',
66
{
77
runtime: 'automatic',
8-
development: process.env.BABEL_ENV === 'development',
9-
},
10-
],
8+
development: process.env.BABEL_ENV === 'development'
9+
}
10+
]
1111
],
1212
plugins: [
1313
// https://github.com/babel/babel/issues/16262#issuecomment-1962832499
@@ -17,10 +17,10 @@ module.exports = {
1717
allowDeclareFields: true,
1818
allowNamespaces: true,
1919
allExtensions: true,
20-
isTSX: true,
21-
},
20+
isTSX: true
21+
}
2222
],
2323
// https://babeljs.io/docs/babel-plugin-proposal-decorators#note-compatibility-with-babelplugin-transform-class-properties
24-
['@babel/plugin-proposal-decorators', { version: '2023-05' }],
25-
],
24+
['@babel/plugin-proposal-decorators', { version: '2023-05' }]
25+
]
2626
};

components/Client/Partner.tsx

Lines changed: 52 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,66 @@
1-
import { FC } from 'react';
1+
import { Tooltip } from '@mui/material';
2+
import { FC, ReactNode } from 'react';
23

34
import { Client } from '../../models/Client';
4-
import { LarkImage } from '../Base/LarkImage';
5+
import { fileURLOf } from '../../pages/api/Lark/file/[id]';
6+
import { LarkImage } from '../LarkImage';
57

68
export interface PartnerProps extends Client {
79
className?: string;
810
}
911

10-
export const Partner: FC<PartnerProps> = ({
11-
className = '',
12+
export interface PartnerOverviewProps extends Record<'name' | 'logo' | 'address', string> {
13+
logoDark?: string;
14+
className?: string;
15+
tooltip?: ReactNode;
16+
}
17+
18+
export const Partner: FC<PartnerProps> = ({ className = '', name, image, summary, address }) => (
19+
<div className={`relative flex flex-col items-center justify-center gap-4 ${className}`}>
20+
<LarkImage className="h-20 object-fill" src={fileURLOf(String(image))} alt={String(name)} />
21+
<h3>
22+
<a className="stretched-link" target="_blank" href={String(address)} rel="noreferrer">
23+
{String(name)}
24+
</a>
25+
</h3>
26+
<p className="text-muted">{String(summary)}</p>
27+
</div>
28+
);
29+
30+
export const PartnerOverview: FC<PartnerOverviewProps> = ({ name, tooltip, ...rest }) =>
31+
tooltip ? (
32+
<Tooltip key={name} title={tooltip}>
33+
<LogoWithLink name={name} {...rest} />
34+
</Tooltip>
35+
) : (
36+
<LogoWithLink key={name} name={name} {...rest} />
37+
);
38+
39+
export const LogoWithLink: FC<Omit<PartnerOverviewProps, 'tooltip'>> = ({
1240
name,
13-
image,
14-
summary,
1541
address,
42+
logo,
43+
logoDark,
44+
className
1645
}) => (
17-
<div
18-
className={`d-flex flex-column align-items-center justify-content-center gap-3 position-relative ${className}`}
46+
<a
47+
key={name}
48+
href={address}
49+
className="flex items-center justify-center"
50+
target="_blank"
51+
rel="noreferrer"
1952
>
20-
<LarkImage
21-
fluid
22-
className="object-fit-contain"
23-
style={{ height: '5rem' }}
53+
<img
54+
className={`max-h-24 min-h-2 dark:hidden ${className}`}
2455
loading="lazy"
25-
src={image}
56+
src={logoDark ?? logo}
57+
alt={name}
2658
/>
27-
<h3>
28-
<a
29-
className="stretched-link"
30-
target="_blank"
31-
href={address?.toString()}
32-
rel="noreferrer"
33-
>
34-
{name + ''}
35-
</a>
36-
</h3>
37-
<p className="text-muted">{summary + ''}</p>
38-
</div>
59+
<img
60+
className={`hidden max-h-24 min-h-2 dark:block ${className}`}
61+
loading="lazy"
62+
src={logo}
63+
alt={name}
64+
/>
65+
</a>
3966
);

components/Git/Card.tsx

Lines changed: 36 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
import { text2color } from 'idea-react';
1+
import { Button, Chip } from '@mui/material';
22
import { GitRepository } from 'mobx-github';
33
import { observer } from 'mobx-react';
4+
import Link from 'next/link';
45
import { FC } from 'react';
5-
import { Badge, Button, Card, Col, Row } from 'react-bootstrap';
66

77
import { i18n } from '../../models/Translation';
8-
import { GitLogo } from './Logo';
98

109
export interface GitCardProps
1110
extends Pick<GitRepository, 'full_name' | 'html_url' | 'languages'>,
@@ -14,53 +13,39 @@ export interface GitCardProps
1413
}
1514

1615
export const GitCard: FC<GitCardProps> = observer(
17-
({
18-
className = 'shadow-sm',
19-
full_name,
20-
html_url,
21-
languages = [],
22-
topics = [],
23-
description,
24-
homepage,
25-
}) => (
26-
<Card className={className}>
27-
<Card.Body className="d-flex flex-column gap-3">
28-
<Card.Title as="h3" className="h5">
29-
<a target="_blank" href={html_url} rel="noreferrer">
30-
{full_name}
31-
</a>
32-
</Card.Title>
16+
({ className = '', full_name, html_url, topics = [], description, homepage }) => (
17+
<li
18+
className={`${className} grid grid-cols-1 grid-rows-10 gap-2 rounded-2xl border p-4 elevation-1 hover:elevation-8 dark:border-0`}
19+
>
20+
<h3 className="row-span-2 text-lg">
21+
<a target="_blank" href={html_url} rel="noreferrer">
22+
{full_name}
23+
</a>
24+
</h3>
3325

34-
<nav className="flex-fill">
35-
{topics.map(topic => (
36-
<Badge
37-
key={topic}
38-
className="me-1"
39-
bg={text2color(topic, ['light'])}
40-
as="a"
41-
target="_blank"
42-
href={`https://github.com/topics/${topic}`}
43-
>
44-
{topic}
45-
</Badge>
46-
))}
47-
</nav>
48-
<Row as="ul" className="list-unstyled g-4" xs={4}>
49-
{languages.map(language => (
50-
<Col key={language} as="li">
51-
<GitLogo name={language} />
52-
</Col>
53-
))}
54-
</Row>
55-
<Card.Text>{description}</Card.Text>
56-
</Card.Body>
57-
<Card.Footer className="d-flex justify-content-between align-items-center">
58-
{homepage && (
59-
<Button variant="success" target="_blank" href={homepage}>
60-
{i18n.t('home_page')}
61-
</Button>
62-
)}
63-
</Card.Footer>
64-
</Card>
65-
),
26+
<nav className="row-span-3 flex flex-row flex-wrap gap-2">
27+
{topics.map(topic => (
28+
<Chip
29+
key={topic}
30+
size="small"
31+
component="a"
32+
target="_blank"
33+
href={`https://github.com/topics/${topic}`}
34+
label={topic}
35+
/>
36+
))}
37+
</nav>
38+
39+
<p className="row-span-3 text-sm">{description}</p>
40+
41+
<Button
42+
className="row-span-2 place-self-center"
43+
component={Link}
44+
target="_blank"
45+
href={homepage ?? html_url}
46+
>
47+
{i18n.t('home_page')}
48+
</Button>
49+
</li>
50+
)
6651
);

components/Git/Logo.tsx

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,36 @@
11
import { observable } from 'mobx';
22
import { observer } from 'mobx-react';
3+
import Image from 'next/image';
34
import { PureComponent } from 'react';
4-
import { Image } from 'react-bootstrap';
55

6-
export interface GitLogoProps {
6+
export interface GitLogoProps extends Partial<Record<'width' | 'height', number>> {
77
name: string;
8+
className?: string;
89
}
910

1011
@observer
1112
export class GitLogo extends PureComponent<GitLogoProps> {
1213
@observable
1314
accessor path = '';
1415

15-
async componentDidMount() {
16+
componentDidMount() {
17+
void this.init();
18+
}
19+
20+
async init() {
1621
const { name } = this.props;
1722
const topic = name.toLowerCase();
1823

1924
try {
2025
const { src } = await this.loadImage(
21-
`https://raw.githubusercontent.com/github/explore/master/topics/${topic}/${topic}.png`,
26+
`https://raw.githubusercontent.com/github/explore/master/topics/${topic}/${topic}.png`
2227
);
28+
2329
this.path = src;
2430
} catch {
2531
const { src } = await this.loadImage(`https://github.com/${name}.png`);
2632

27-
this.path = src;
33+
return (this.path = src);
2834
}
2935
}
3036

@@ -41,8 +47,18 @@ export class GitLogo extends PureComponent<GitLogoProps> {
4147

4248
render() {
4349
const { path } = this;
44-
const { name } = this.props;
50+
const { name, width = 24, height = 24, className = '' } = this.props;
4551

46-
return path && <Image fluid loading="lazy" src={path} alt={name} />;
52+
return (
53+
path && (
54+
<Image
55+
className={`${className} object-fill`}
56+
width={width}
57+
height={height}
58+
src={path}
59+
alt={name}
60+
/>
61+
)
62+
);
4763
}
4864
}

0 commit comments

Comments
 (0)