Skip to content

Commit

Permalink
Panel: better spacing
Browse files Browse the repository at this point in the history
  • Loading branch information
oandregal committed Nov 19, 2024
1 parent c724251 commit 179696f
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions packages/dataviews/src/dataforms-layouts/panel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
__experimentalSpacer as Spacer,
Dropdown,
Button,
BaseControl,
} from '@wordpress/components';
import { sprintf, __, _x } from '@wordpress/i18n';
import { useState, useMemo, useContext } from '@wordpress/element';
Expand Down Expand Up @@ -200,9 +199,14 @@ export default function FormPanelField< Item >( {

if ( labelPosition === 'top' ) {
return (
<BaseControl __nextHasNoMarginBottom>
{ fieldLabel }
<div>
<VStack className="dataforms-layouts-panel__field" spacing={ 0 }>
<div
className="dataforms-layouts-panel__field-label"
style={ { paddingBottom: 0 } }
>
{ fieldLabel }
</div>
<div className="dataforms-layouts-panel__field-control">
<PanelDropdown
field={ field }
popoverAnchor={ popoverAnchor }
Expand All @@ -213,21 +217,23 @@ export default function FormPanelField< Item >( {
labelPosition={ labelPosition }
/>
</div>
</BaseControl>
</VStack>
);
}

if ( labelPosition === 'none' ) {
return (
<PanelDropdown
field={ field }
popoverAnchor={ popoverAnchor }
fieldDefinition={ fieldDefinition }
data={ data }
onChange={ onChange }
defaultLayout={ defaultLayout }
labelPosition={ labelPosition }
/>
<div className="dataforms-layouts-panel__field">
<PanelDropdown
field={ field }
popoverAnchor={ popoverAnchor }
fieldDefinition={ fieldDefinition }
data={ data }
onChange={ onChange }
defaultLayout={ defaultLayout }
labelPosition={ labelPosition }
/>
</div>
);
}

Expand All @@ -240,7 +246,7 @@ export default function FormPanelField< Item >( {
<div className="dataforms-layouts-panel__field-label">
{ fieldLabel }
</div>
<div>
<div className="dataforms-layouts-panel__field-control">
<PanelDropdown
field={ field }
popoverAnchor={ popoverAnchor }
Expand Down

0 comments on commit 179696f

Please sign in to comment.