Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
kurudrive committed Jan 22, 2024
1 parent b0be5ab commit 77bb77f
Showing 1 changed file with 47 additions and 11 deletions.
58 changes: 47 additions & 11 deletions src/blocks/_pro/outer/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,14 +322,14 @@ export default function OuterEdit(props) {
};
}

const setAttributesByUnit = ( key, value, unit, min, max ) => {
if('px' === unit) {
const setAttributesByUnit = (key, value, unit, min, max) => {
if ('px' === unit) {
value = parseInt(value);
}
setAttributes({
[key]: toNumber(value, min, max),
})
}
});
};

const blockProps = useBlockProps({
className: classnames(
Expand Down Expand Up @@ -850,23 +850,47 @@ export default function OuterEdit(props) {
<RangeControl
label={__('Mobile', 'vk-blocks-pro')}
value={innerSideSpaceValueMobile}
onChange={(value) => setAttributesByUnit('innerSideSpaceValueMobile', value, innerSideSpaceUnit, 0, 100)}
onChange={(value) =>
setAttributesByUnit(
'innerSideSpaceValueMobile',
value,
innerSideSpaceUnit,
0,
100
)
}
min="0"
max="100"
step={'px' === innerSideSpaceUnit ? 1 : 0.1}
/>
<RangeControl
label={__('Tablet', 'vk-blocks-pro')}
value={innerSideSpaceValueTablet}
onChange={(value) => setAttributesByUnit('innerSideSpaceValueTablet', value, innerSideSpaceUnit, 0, 200)}
onChange={(value) =>
setAttributesByUnit(
'innerSideSpaceValueTablet',
value,
innerSideSpaceUnit,
0,
200
)
}
min="0"
max="200"
step={'px' === innerSideSpaceUnit ? 1 : 0.1}
/>
<RangeControl
label={__('PC', 'vk-blocks-pro')}
value={innerSideSpaceValuePC}
onChange={(value) => setAttributesByUnit('innerSideSpaceValuePC', value, innerSideSpaceUnit, 0, 300)}
onChange={(value) =>
setAttributesByUnit(
'innerSideSpaceValuePC',
value,
innerSideSpaceUnit,
0,
300
)
}
min="0"
max="300"
step={'px' === innerSideSpaceUnit ? 1 : 0.1}
Expand All @@ -875,12 +899,24 @@ export default function OuterEdit(props) {
label={__('Unit Type', 'vk-blocks-pro')}
value={innerSideSpaceUnit}
onChange={(value) => {
setAttributes({innerSideSpaceValueMobile: parseInt(innerSideSpaceValueMobile)});
setAttributes({innerSideSpaceValueTablet: parseInt(innerSideSpaceValueTablet)});
setAttributes({innerSideSpaceValuePC: parseInt(innerSideSpaceValuePC)});
setAttributes({
innerSideSpaceValueMobile: parseInt(
innerSideSpaceValueMobile
),
});
setAttributes({
innerSideSpaceValueTablet: parseInt(
innerSideSpaceValueTablet
),
});
setAttributes({
innerSideSpaceValuePC: parseInt(
innerSideSpaceValuePC
),
});
setAttributes({
innerSideSpaceUnit: value,
})
});
}}
options={[
{
Expand Down

0 comments on commit 77bb77f

Please sign in to comment.