Skip to content

Commit

Permalink
refactored location control implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
prconcepcion committed Mar 20, 2024
1 parent b32153b commit 7243445
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 26 deletions.
9 changes: 2 additions & 7 deletions src/block/map/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,10 @@
.stk-control__location-control {
display: flex;

> :not(.stk--has-dynamic-content) {
.stk-dynamic-content-control__button {
margin-top: 23px;
}
}

.stk-control__reset-button {
position: static;
margin-left: 2px;
margin-top: 2px;
margin-left: 60px;
margin-right: 2px;
}
}
Expand Down
40 changes: 21 additions & 19 deletions src/block/map/location-control.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { DynamicContentControl, useDynamicContentControlProps } from '~stackable
/**
* WordPress dependencies
*/
import { TextControl } from '@wordpress/components'
import { TextControl, BaseControl as GutBaseControl } from '@wordpress/components'
import { __ } from '@wordpress/i18n'
import {
useState, useEffect, useRef,
Expand Down Expand Up @@ -63,30 +63,32 @@ const LocationControl = props => {
}, [ ref.current, waitForGoogle ] )

return (
<div className="stk-control__location-control">
<DynamicContentControl
enable={ true }
hasPanelModifiedIndicator={ true }
{ ...dynamicContentProps }
>
<TextControl
label={ __( 'Location', i18n ) }
ref={ ref }
value={ props.value }
help={ __( 'Type in a pair of latitude longitude coordinates. You can also type in the name of the location if your API Key has Geocoding API and Places API enabled.', i18n ) }
onChange={ value => {
props.onTextChange( value )
} }
/>
</DynamicContentControl>
</div>
<GutBaseControl
label={ __( 'Location', i18n ) }
help={ __( 'Type in a pair of latitude longitude coordinates. You can also type in the name of the location if your API Key has Geocoding API and Places API enabled.', i18n ) }
>
<div className="stk-control__location-control">
<DynamicContentControl
enable={ true }
hasPanelModifiedIndicator={ true }
{ ...dynamicContentProps }
>
<TextControl
ref={ ref }
value={ props.value }
onChange={ value => {
props.onTextChange( value )
} }
/>
</DynamicContentControl>
</div>
</GutBaseControl>
)
}

LocationControl.defaultProps = {
onChange: null,
value: '',
hasPanelModifiedIndicator: true,
}

export default LocationControl

0 comments on commit 7243445

Please sign in to comment.