mirror of
https://github.com/strapi/strapi.git
synced 2025-11-03 11:25:17 +00:00
Merge branch 'front-media-lib-search' of github.com:strapi/strapi into front/media-lib-filters
Signed-off-by: Virginie Ky <virginie.ky@gmail.com>
This commit is contained in:
commit
8da7bd21a0
@ -1,26 +1,21 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { FormattedMessage } from 'react-intl';
|
||||
|
||||
import getTrad from '../../utils/getTrad';
|
||||
|
||||
import Wrapper from './Wrapper';
|
||||
import SortListItem from './SortListItem';
|
||||
import SortListItem from '../SortListItem';
|
||||
|
||||
const SortList = ({ list, onClick, selected }) => {
|
||||
const SortList = ({ list, onClick, selectedItem }) => {
|
||||
return (
|
||||
<Wrapper>
|
||||
{Object.keys(list).map(item => {
|
||||
return (
|
||||
<SortListItem
|
||||
key={item}
|
||||
isActive={list[item] === selected}
|
||||
onClick={() => {
|
||||
onClick(list[item]);
|
||||
}}
|
||||
>
|
||||
<FormattedMessage id={getTrad(`sort.${item}`)} />
|
||||
</SortListItem>
|
||||
label={item}
|
||||
value={list[item]}
|
||||
onClick={onClick}
|
||||
selectedItem={selectedItem}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
</Wrapper>
|
||||
@ -30,13 +25,13 @@ const SortList = ({ list, onClick, selected }) => {
|
||||
SortList.defaultProps = {
|
||||
list: {},
|
||||
onClick: () => {},
|
||||
selected: null,
|
||||
selectedItem: null,
|
||||
};
|
||||
|
||||
SortList.propTypes = {
|
||||
list: PropTypes.object,
|
||||
onClick: PropTypes.func,
|
||||
selected: PropTypes.string,
|
||||
selectedItem: PropTypes.string,
|
||||
};
|
||||
|
||||
export default SortList;
|
||||
|
||||
@ -0,0 +1,35 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { FormattedMessage } from 'react-intl';
|
||||
|
||||
import getTrad from '../../utils/getTrad';
|
||||
|
||||
import Wrapper from './Wrapper';
|
||||
|
||||
const SortListItem = ({ onClick, selectedItem, label, value }) => {
|
||||
const handleClick = () => {
|
||||
onClick(value);
|
||||
};
|
||||
|
||||
return (
|
||||
<Wrapper isActive={selectedItem === value} onClick={handleClick}>
|
||||
<FormattedMessage id={getTrad(`sort.${label}`)} />
|
||||
</Wrapper>
|
||||
);
|
||||
};
|
||||
|
||||
SortListItem.defaultProps = {
|
||||
selectedItem: null,
|
||||
label: '',
|
||||
onClick: () => {},
|
||||
value: null,
|
||||
};
|
||||
|
||||
SortListItem.propTypes = {
|
||||
selectedItem: PropTypes.string,
|
||||
label: PropTypes.string,
|
||||
onClick: PropTypes.func,
|
||||
value: PropTypes.string,
|
||||
};
|
||||
|
||||
export default SortListItem;
|
||||
@ -40,7 +40,12 @@ const SortPicker = ({ onChange, value }) => {
|
||||
<Carret isUp={!isOpen} />
|
||||
</DropdownButton>
|
||||
<DropdownSection isOpen={isOpen}>
|
||||
<SortList list={orders} selected={value} onClick={handleChange} />
|
||||
<SortList
|
||||
isShown={isOpen}
|
||||
list={orders}
|
||||
selectedItem={value}
|
||||
onClick={handleChange}
|
||||
/>
|
||||
</DropdownSection>
|
||||
</Wrapper>
|
||||
);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user