mirror of
https://github.com/strapi/strapi.git
synced 2025-11-14 09:07:59 +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 React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { FormattedMessage } from 'react-intl';
|
|
||||||
|
|
||||||
import getTrad from '../../utils/getTrad';
|
|
||||||
|
|
||||||
import Wrapper from './Wrapper';
|
import Wrapper from './Wrapper';
|
||||||
import SortListItem from './SortListItem';
|
import SortListItem from '../SortListItem';
|
||||||
|
|
||||||
const SortList = ({ list, onClick, selected }) => {
|
const SortList = ({ list, onClick, selectedItem }) => {
|
||||||
return (
|
return (
|
||||||
<Wrapper>
|
<Wrapper>
|
||||||
{Object.keys(list).map(item => {
|
{Object.keys(list).map(item => {
|
||||||
return (
|
return (
|
||||||
<SortListItem
|
<SortListItem
|
||||||
key={item}
|
key={item}
|
||||||
isActive={list[item] === selected}
|
label={item}
|
||||||
onClick={() => {
|
value={list[item]}
|
||||||
onClick(list[item]);
|
onClick={onClick}
|
||||||
}}
|
selectedItem={selectedItem}
|
||||||
>
|
/>
|
||||||
<FormattedMessage id={getTrad(`sort.${item}`)} />
|
|
||||||
</SortListItem>
|
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</Wrapper>
|
</Wrapper>
|
||||||
@ -30,13 +25,13 @@ const SortList = ({ list, onClick, selected }) => {
|
|||||||
SortList.defaultProps = {
|
SortList.defaultProps = {
|
||||||
list: {},
|
list: {},
|
||||||
onClick: () => {},
|
onClick: () => {},
|
||||||
selected: null,
|
selectedItem: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
SortList.propTypes = {
|
SortList.propTypes = {
|
||||||
list: PropTypes.object,
|
list: PropTypes.object,
|
||||||
onClick: PropTypes.func,
|
onClick: PropTypes.func,
|
||||||
selected: PropTypes.string,
|
selectedItem: PropTypes.string,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default SortList;
|
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} />
|
<Carret isUp={!isOpen} />
|
||||||
</DropdownButton>
|
</DropdownButton>
|
||||||
<DropdownSection isOpen={isOpen}>
|
<DropdownSection isOpen={isOpen}>
|
||||||
<SortList list={orders} selected={value} onClick={handleChange} />
|
<SortList
|
||||||
|
isShown={isOpen}
|
||||||
|
list={orders}
|
||||||
|
selectedItem={value}
|
||||||
|
onClick={handleChange}
|
||||||
|
/>
|
||||||
</DropdownSection>
|
</DropdownSection>
|
||||||
</Wrapper>
|
</Wrapper>
|
||||||
);
|
);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user