@blocklet/list 0.8.21 → 0.8.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/base.js +40 -37
- package/lib/components/aside.js +53 -0
- package/lib/components/{filter-author.js → filter/custom-chip.js} +21 -28
- package/lib/components/{filter-mobile/content.js → filter/group.js} +10 -8
- package/lib/components/{filter-mobile/index.js → filter/icon.js} +37 -21
- package/lib/components/filter/index.js +31 -0
- package/lib/components/list/list.js +1 -1
- package/lib/components/search.js +1 -1
- package/lib/contexts/filter.js +4 -4
- package/lib/libs/utils.js +3 -3
- package/package.json +2 -2
- package/src/base.js +61 -61
- package/src/components/aside.js +36 -0
- package/src/components/filter/custom-chip.js +33 -0
- package/src/components/{filter-mobile/content.js → filter/group.js} +21 -11
- package/src/components/{filter-mobile/index.js → filter/icon.js} +33 -16
- package/src/components/filter/index.js +5 -0
- package/src/components/list/list.js +5 -0
- package/src/components/search.js +3 -11
- package/src/contexts/filter.js +8 -14
- package/src/libs/utils.js +2 -2
- package/lib/components/aside/aside.js +0 -64
- package/lib/components/aside/category-link-list.js +0 -78
- package/lib/components/aside/index.js +0 -13
- package/src/components/aside/aside.js +0 -90
- package/src/components/aside/category-link-list.js +0 -53
- package/src/components/aside/index.js +0 -3
- package/src/components/filter-author.js +0 -38
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Box, List, Checkbox, FormControlLabel } from '@mui/material';
|
|
3
|
-
import styled from 'styled-components';
|
|
4
|
-
|
|
5
|
-
import { useFilterContext } from '../../contexts/filter';
|
|
6
|
-
import { getPrices } from '../../libs/utils';
|
|
7
|
-
import Search from '../search';
|
|
8
|
-
import CategoryLinkList from './category-link-list';
|
|
9
|
-
|
|
10
|
-
const Aside = () => {
|
|
11
|
-
const { filters, handlePrice, t } = useFilterContext();
|
|
12
|
-
return (
|
|
13
|
-
<StyledAside>
|
|
14
|
-
<Search placeholder={t('common.searchStore')} />
|
|
15
|
-
<Box marginTop="24px">
|
|
16
|
-
{getPrices(t).map((item) => (
|
|
17
|
-
<FormControlLabel
|
|
18
|
-
className="payments"
|
|
19
|
-
key={item.value}
|
|
20
|
-
control={
|
|
21
|
-
<Checkbox
|
|
22
|
-
onClick={() => {
|
|
23
|
-
handlePrice(item.value);
|
|
24
|
-
}}
|
|
25
|
-
size="small"
|
|
26
|
-
checked={item.value === filters.price}
|
|
27
|
-
/>
|
|
28
|
-
}
|
|
29
|
-
label={item.name}
|
|
30
|
-
/>
|
|
31
|
-
))}
|
|
32
|
-
</Box>
|
|
33
|
-
<List component="nav" color="primary">
|
|
34
|
-
{/* 分割线 */}
|
|
35
|
-
<div style={{ border: '1px solid #dadce0', margin: '16px 16px' }} />
|
|
36
|
-
<CategoryLinkList />
|
|
37
|
-
</List>
|
|
38
|
-
</StyledAside>
|
|
39
|
-
);
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
const StyledAside = styled.aside`
|
|
43
|
-
width: 220px;
|
|
44
|
-
margin-right: 20px;
|
|
45
|
-
background-color: ${(props) => props.theme.palette.grey[50]};
|
|
46
|
-
height: 100%;
|
|
47
|
-
padding: 15px 0px;
|
|
48
|
-
border-radius: 8px;
|
|
49
|
-
.MuiListItemText-root {
|
|
50
|
-
width: 100%;
|
|
51
|
-
overflow: hidden;
|
|
52
|
-
white-space: nowrap;
|
|
53
|
-
text-overflow: ellipsis;
|
|
54
|
-
}
|
|
55
|
-
.payments {
|
|
56
|
-
display: flex;
|
|
57
|
-
padding: 0 16px;
|
|
58
|
-
.MuiFormControlLabel-label {
|
|
59
|
-
color: #5f6368;
|
|
60
|
-
font-size: 1rem;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
.MuiListItem-root {
|
|
64
|
-
text-transform: capitalize;
|
|
65
|
-
.category > span {
|
|
66
|
-
font-weight: ${(props) => props.theme.typography.fontWeightBold};
|
|
67
|
-
}
|
|
68
|
-
> :not(.category) {
|
|
69
|
-
.MuiListItemText-primary {
|
|
70
|
-
color: #5f6368;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
&.Mui-selected {
|
|
74
|
-
background-color: ${(props) => props.theme.palette.primary.main}!important;
|
|
75
|
-
border-radius: 4px;
|
|
76
|
-
.MuiListItemText-primary {
|
|
77
|
-
color: #fff !important;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
@media (max-width: ${(props) => props.theme.breakpoints.values.md}px) {
|
|
82
|
-
.MuiListItemText-primary {
|
|
83
|
-
font-size: 16px;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
`;
|
|
87
|
-
|
|
88
|
-
Aside.propTypes = {};
|
|
89
|
-
Aside.defaultProps = {};
|
|
90
|
-
export default Aside;
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { ListItem, ListItemText, Link } from '@mui/material';
|
|
3
|
-
import joinUrl from 'url-join';
|
|
4
|
-
|
|
5
|
-
import { useFilterContext } from '../../contexts/filter';
|
|
6
|
-
import { urlStringify } from '../../libs/utils';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* 宽屏幕下的分类列表
|
|
10
|
-
* @returns
|
|
11
|
-
*/
|
|
12
|
-
const CategoryLinkList = () => {
|
|
13
|
-
const { categoryList, selectedCategory, filters, baseUrl, handleCategory, t, locale } = useFilterContext();
|
|
14
|
-
|
|
15
|
-
const handleClick = (e, name) => {
|
|
16
|
-
handleCategory(name);
|
|
17
|
-
e.preventDefault();
|
|
18
|
-
return false;
|
|
19
|
-
};
|
|
20
|
-
const content = (
|
|
21
|
-
<div style={{ marginRight: '16px' }}>
|
|
22
|
-
<ListItem selected={!selectedCategory} button onClick={(e) => handleClick(e, 'all')}>
|
|
23
|
-
<ListItemText primary={t('category.all')} />
|
|
24
|
-
</ListItem>
|
|
25
|
-
{categoryList.map((item) => (
|
|
26
|
-
<ListItem
|
|
27
|
-
key={item._id}
|
|
28
|
-
title={item.locales[locale]}
|
|
29
|
-
component={Link}
|
|
30
|
-
to={`${joinUrl(baseUrl, '/search')}?${urlStringify({
|
|
31
|
-
...filters,
|
|
32
|
-
category: item.name,
|
|
33
|
-
})}`}
|
|
34
|
-
onClick={(e) => handleClick(e, item.name)}
|
|
35
|
-
button
|
|
36
|
-
selected={item.name === selectedCategory}>
|
|
37
|
-
<ListItemText primary={item.locales[locale]} />
|
|
38
|
-
</ListItem>
|
|
39
|
-
))}
|
|
40
|
-
</div>
|
|
41
|
-
);
|
|
42
|
-
|
|
43
|
-
return (
|
|
44
|
-
<>
|
|
45
|
-
<ListItem>
|
|
46
|
-
<ListItemText className="category" primary={t('common.category')} />
|
|
47
|
-
</ListItem>
|
|
48
|
-
{content}
|
|
49
|
-
</>
|
|
50
|
-
);
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
export default CategoryLinkList;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import styled from 'styled-components';
|
|
4
|
-
import { Chip } from '@mui/material';
|
|
5
|
-
import FaceIcon from '@mui/icons-material/Face';
|
|
6
|
-
|
|
7
|
-
import { useFilterContext } from '../contexts/filter';
|
|
8
|
-
|
|
9
|
-
const StyleDiv = styled.div`
|
|
10
|
-
.MuiChip-root {
|
|
11
|
-
border-radius: 4px;
|
|
12
|
-
height: initial;
|
|
13
|
-
text-transform: capitalize;
|
|
14
|
-
}
|
|
15
|
-
`;
|
|
16
|
-
const FilterAuthor = ({ user, deleteUserTag, ...containerProps }) => {
|
|
17
|
-
const { t } = useFilterContext();
|
|
18
|
-
if (!user) return null;
|
|
19
|
-
return (
|
|
20
|
-
<StyleDiv {...containerProps}>
|
|
21
|
-
<Chip
|
|
22
|
-
icon={<FaceIcon />}
|
|
23
|
-
label={t('blocklet.owner', { name: user })}
|
|
24
|
-
onDelete={() => {
|
|
25
|
-
deleteUserTag();
|
|
26
|
-
}}
|
|
27
|
-
/>
|
|
28
|
-
</StyleDiv>
|
|
29
|
-
);
|
|
30
|
-
};
|
|
31
|
-
FilterAuthor.propTypes = {
|
|
32
|
-
user: PropTypes.string.isRequired,
|
|
33
|
-
deleteUserTag: PropTypes.func,
|
|
34
|
-
};
|
|
35
|
-
FilterAuthor.defaultProps = {
|
|
36
|
-
deleteUserTag: () => {},
|
|
37
|
-
};
|
|
38
|
-
export default FilterAuthor;
|