Skip to content

Commit 4623f84

Browse files
committed
update trending page
1 parent 68f4e37 commit 4623f84

16 files changed

+355
-120
lines changed

babel.config.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ module.exports = {
1515
customName: name => {
1616
if(name === 'at-list-item'){
1717
name = 'at-list/item'
18+
} else if(name === 'at-action-sheet-item'){
19+
name = 'at-action-sheet/body/item'
1820
}
1921
return `taro-ui/lib/components/${name.slice(3)}`
2022
},
@@ -25,9 +27,12 @@ module.exports = {
2527
if(name === 'at-tabs-pane'){
2628
name = 'at-tabs'
2729
}
28-
if(name === 'at-list-item'){
30+
else if(name === 'at-list-item'){
2931
name = 'at-list'
3032
}
33+
else if(name === 'at-action-sheet-item'){
34+
name = 'at-action-sheet'
35+
}
3136
return `taro-ui/dist/style/components/${name.slice(3)}.scss`
3237
}
3338
},

src/components/empty/index.module.scss

+6-2
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
width: 100vw;
44
display: flex;
55
justify-content: center;
6-
align-items: center;
6+
77
background: $bg;
88
}
99
.inner {
10-
margin: auto;
10+
margin: 40px auto;
1111
}
1212

1313
.img {
@@ -20,3 +20,7 @@
2020
font-size: 35px;
2121
color: rgb(88, 88, 88);
2222
}
23+
24+
.tips {
25+
color: $primary;
26+
}

src/components/empty/index.tsx

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
import img from '@/assets/spidertocat.png';
2-
import { Image, View } from '@tarojs/components';
3-
import Taro from '@tarojs/taro';
2+
import { Image, Text, View } from '@tarojs/components';
43
import { FC } from 'react';
5-
import { AtButton } from 'taro-ui';
64
import styles from './index.module.scss';
75

86
const Empty: FC = () => {
97
return (
108
<View className={styles.wrap}>
119
<View className={styles.inner}>
1210
<Image src={img} className={styles.img}></Image>
13-
<View className={styles.desc}>没有数据</View>
14-
<View>
11+
<View className={styles.desc}>
12+
<Text>没有数据~</Text>
13+
<View>
14+
<Text className={styles.tips}>试试下拉刷新</Text>
15+
</View>
16+
</View>
17+
{/* <View>
1518
<AtButton
1619
size="small"
1720
type="primary"
@@ -21,7 +24,7 @@ const Empty: FC = () => {
2124
>
2225
重试
2326
</AtButton>
24-
</View>
27+
</View> */}
2528
</View>
2629
</View>
2730
);

src/components/fab-button/index.tsx

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,31 @@
11
import { View } from '@tarojs/components';
22
import { ITouchEvent } from '@tarojs/components/types/common';
3+
import { ReactNode } from 'react';
34
import { AtFab, AtIcon } from 'taro-ui';
45
import styles from './index.module.scss';
56

67
interface FabButtonProps {
78
icon?: string;
89
prefixClass?: string;
10+
children?: ReactNode;
11+
size?: 'small' | 'normal';
912
onClick: (e: ITouchEvent) => void;
1013
}
1114

1215
const FabButton = ({
1316
icon = 'filter',
1417
prefixClass = '',
1518
onClick,
19+
children,
20+
size = 'small',
1621
}: FabButtonProps) => {
1722
const props: any = { value: icon };
1823
if (prefixClass) {
1924
props.prefixClass = prefixClass;
2025
}
2126
return (
2227
<View className={styles['fab-btn']} onClick={onClick}>
23-
<AtFab size="small">
24-
<AtIcon {...props}></AtIcon>
25-
</AtFab>
28+
<AtFab size={size}>{children || <AtIcon {...props}></AtIcon>}</AtFab>
2629
</View>
2730
);
2831
};

src/constants.ts

+2
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,5 @@ export const PULL_DOWN_REFRESH_EVENT = 'pull_down_refresh_event';
1919
export const THROTTLE_DELAY = 1500;
2020

2121
export const TRENDING_URL = 'https://trending.stayin.cn';
22+
23+
export const CURRENT_LANGUAGE_STORAGE_KEY = 'current-language';

src/hooks/useTrending.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
import { TRENDING_URL } from '@/constants';
22
import { useQuery } from '@tanstack/react-query';
33
import Taro from '@tarojs/taro';
4-
import { TrendingRepoData, TrendingRequestParams } from 'types/trending';
4+
import {
5+
TrendingDeveloperData,
6+
TrendingRepoData,
7+
TrendingRequestParams,
8+
} from 'types/trending';
59

610
const useTrending = ({
711
type = 'repositories',
812
...params
913
}: TrendingRequestParams) => {
10-
return useQuery<TrendingRepoData[]>(
14+
return useQuery<(TrendingRepoData | TrendingDeveloperData)[]>(
1115
['trending', type, params],
1216
() => {
1317
// Taro.showLoading({ title: '努力加载中...' });

src/pages/my-languages/index.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ const MyLanguages = () => {
2121
const [optionsLangs, setOptionsLangs] =
2222
useState<OptionsLang[]>(LANGUAGE_LIST);
2323
const [selectedList, setSelectedList] = useState<string[]>(initSelectedList);
24-
const [fiterVal, setFilterVal] = useState<string>('');
24+
const [filterVal, setFilterVal] = useState<string>('');
2525
const dispatch = useDispatch();
2626

27-
const handleSeletedChange = (val) => {
27+
const handleSelectedChange = (val) => {
2828
setSelectedList(val);
2929
};
3030

@@ -62,15 +62,15 @@ const MyLanguages = () => {
6262
focus
6363
placeholder="Search"
6464
className={styles['filter-input']}
65-
value={fiterVal}
65+
value={filterVal}
6666
onInput={handleChangeInput}
6767
></Input>
6868
</View>
6969
<View>
7070
<AtCheckbox
7171
options={optionsLangs}
7272
selectedList={selectedList}
73-
onChange={handleSeletedChange}
73+
onChange={handleSelectedChange}
7474
></AtCheckbox>
7575
</View>
7676
<FabButton icon="check" onClick={handleFabClick}></FabButton>

src/pages/my-languages/languages.ts

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ export const LANGUAGE_LIST = [
22
{
33
value: '',
44
label: 'All Languages',
5+
disabled: true,
56
},
67
{
78
value: '1c-enterprise',

src/pages/trending/index.module.scss

+27
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,35 @@
22
}
33

44
.header {
5+
position: fixed;
6+
top: 0;
7+
left: 0;
8+
right: 0;
59
display: flex;
10+
background-color: white;
11+
padding: 0 20px;
12+
13+
:global(.at-tabs__item--active .at-tabs__item-underline) {
14+
width: 50%;
15+
transform: translate(-50%);
16+
left: 50%;
17+
transition: none;
18+
}
19+
}
20+
21+
.filterIcon {
22+
display: flex;
23+
justify-content: center;
24+
align-items: center;
25+
26+
&:active {
27+
color: $primary;
28+
}
629
}
730

831
.tabs {
932
}
33+
34+
.main {
35+
padding: 80px 0;
36+
}

0 commit comments

Comments
 (0)