Fix reorder

This commit is contained in:
soupette 2019-07-26 12:24:15 +02:00
parent bdfcdb12b2
commit c718e15513
5 changed files with 20 additions and 9 deletions

View File

@ -28,7 +28,7 @@ const Carret = styled.div`
${({ right }) => { ${({ right }) => {
if (right) { if (right) {
return css` return css`
right: -4px; right: -5px;
`; `;
} }
@ -49,7 +49,7 @@ const FullWidthCarret = styled.div`
justify-content: space-around; justify-content: space-around;
height: 30px; height: 30px;
width: 100%; width: 100%;
padding: 0 10px; padding: 0 5px;
margin-bottom: 6px; margin-bottom: 6px;
border-radius: 2px; border-radius: 2px;
> div { > div {
@ -65,7 +65,7 @@ const NameWrapper = styled.div`
width: 100%; width: 100%;
display: flex; display: flex;
padding-left: 10px; padding-left: 5px;
justify-content: space-between; justify-content: space-between;
> div { > div {
width: calc(100% - 30px); width: calc(100% - 30px);
@ -115,7 +115,7 @@ const Wrapper = styled.div`
position: relative; position: relative;
.sub_wrapper { .sub_wrapper {
width: 100%; width: 100%;
padding: 0 10px; padding: 0 5px;
} }
`; `;

View File

@ -38,6 +38,7 @@ const FieldItem = forwardRef(
ref ref
) => { ) => {
const [isOver, setIsOver] = useState(false); const [isOver, setIsOver] = useState(false);
const [dragStart, setDragStart] = useState(false);
const isHidden = name === '_TEMP_'; const isHidden = name === '_TEMP_';
const withLongerHeight = [ const withLongerHeight = [
'json', 'json',
@ -71,13 +72,23 @@ const FieldItem = forwardRef(
return ( return (
<div <div
onClick={isHidden ? () => {} : onClickEdit} onClick={isHidden ? () => {} : onClickEdit}
onDrag={() => {
if (size === 12) {
setDragStart(true);
}
}}
onDragEnd={() => {
if (size === 12) {
setDragStart(false);
}
}}
onMouseEnter={() => setIsOver(true)} onMouseEnter={() => setIsOver(true)}
onMouseLeave={() => setIsOver(false)} onMouseLeave={() => setIsOver(false)}
style={{ width: `${(1 / 12) * size * 100}%`, ...style }} style={{ width: `${(1 / 12) * size * 100}%`, ...style }}
ref={ref} ref={ref}
> >
<Wrapper> <Wrapper>
{isDragging && size === 12 ? ( {dragStart && size === 12 ? (
<FullWidthCarret> <FullWidthCarret>
<div /> <div />
</FullWidthCarret> </FullWidthCarret>

View File

@ -2,7 +2,7 @@ import styled from 'styled-components';
const Wrapper = styled.div` const Wrapper = styled.div`
display: flex; display: flex;
margin-bottom: 24px; margin-bottom: 6px;
`; `;
export { Wrapper }; export { Wrapper };

View File

@ -40,7 +40,7 @@ const FieldsReorder = ({ className }) => {
return ( return (
<div className={className}> <div className={className}>
<SortWrapper> <SortWrapper style={{ paddingLeft: 5, paddingRight: 5 }}>
{layout.map((row, rowIndex) => { {layout.map((row, rowIndex) => {
return ( return (
<Wrapper key={row.rowId} style={{}}> <Wrapper key={row.rowId} style={{}}>
@ -69,7 +69,7 @@ const FieldsReorder = ({ className }) => {
<Add <Add
data={buttonData} data={buttonData}
onClick={onAddData} onClick={onAddData}
style={{ width: '100%', margin: '0 10px' }} style={{ width: '100%', margin: '0 5px' }}
pStyle={{ marginTop: '-2px' }} pStyle={{ marginTop: '-2px' }}
/> />
</Wrapper> </Wrapper>

View File

@ -33,7 +33,7 @@ function SelectWrapper({
} = useEditView(); } = useEditView();
const [state, setState] = useState({ const [state, setState] = useState({
_q: '', _q: '',
_limit: 8, _limit: 20,
_start: 0, _start: 0,
source: isEmpty(plugin) ? 'content-manager' : plugin, source: isEmpty(plugin) ? 'content-manager' : plugin,
}); });