import React from "react";
import PropTypes from "prop-types";
import {
SortableContainer,
SortableElement,
SortableHandle,
} from "react-sortable-hoc";
import ColorControl from "../color-control";
const { __ } = wp.i18n;
const DEFAULT_PROFILE_COLOR = "#9f9f9f";
const TrashIcon = ({ position, onDeleteProfile }) => (
onDeleteProfile(position)}
>
);
const DragHandle = SortableHandle(() => (
));
const SortableItem = SortableElement(
({
position,
profile,
onProfileClick,
onDeleteProfile,
onColorChange,
selectedIcon,
url,
onUrlChange,
onSubmit,
}) => (
onProfileClick(profile.icon)}
>
{profile.icon}
{selectedIcon === profile.icon && profile.isExpanded && (
onColorChange(color, position)}
/>
onUrlChange(event, profile.icon)}
/>
)}
)
);
const SortableList = SortableContainer((props) => {
const { profiles, ...rest } = props;
return (
{profiles.map((profile, index) => (
))}
);
});
const SortableComponent = ({ profiles, onSortEnd, ...rest }) => {
if (profiles.length === 0) return ;
return (
);
};
// Style objects
const trashStyle = {
fontSize: 14,
borderLeft: "1px solid #b4b4cb",
lineHeight: "2.5em",
flex: 2,
textAlign: "center",
display: "flex",
justifyContent: "center",
};
SortableComponent.propTypes = {
profiles: PropTypes.shape({
icon: PropTypes.string.isRequired,
link: PropTypes.string,
isExpanded: PropTypes.bool.isRequired,
}),
onProfileClick: PropTypes.func.isRequired,
onDeleteProfile: PropTypes.func.isRequired,
selectedIcon: PropTypes.string.isRequired,
url: PropTypes.string.isRequired,
onUrlChange: PropTypes.func.isRequired,
onSubmit: PropTypes.func.isRequired,
onProfileAdd: PropTypes.func.isRequired,
onSortEnd: PropTypes.func.isRequired,
onColorChange: PropTypes.func.isRequired,
};
export default SortableComponent;