Active state for form placement component
[MAILPOET-2738]
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
$gutenberg-control-border-color: #7e8993;
|
$gutenberg-control-border-color: #7e8993;
|
||||||
|
$gutenberg-control-active-color: #ff5301;
|
||||||
$gutenberg-control-border-color-focus: #007cba;
|
$gutenberg-control-border-color-focus: #007cba;
|
||||||
$form-placement-option-base-color: #e5e9f8;
|
$form-placement-option-base-color: #e5e9f8;
|
||||||
$form-placement-option-text-color: #23282d;
|
$form-placement-option-text-color: #23282d;
|
||||||
@@ -130,14 +131,24 @@ $form-placement-option-oval-border: #969ca1;
|
|||||||
|
|
||||||
.form-placement-settings-overlay {
|
.form-placement-settings-overlay {
|
||||||
background-color: rgba(0, 0, 0, .3);
|
background-color: rgba(0, 0, 0, .3);
|
||||||
height: 142px;
|
border-radius: 2px;
|
||||||
|
height: 140px; // width of the parent element minus border on both sides
|
||||||
left: 0;
|
left: 0;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0;
|
top: 0;
|
||||||
width: 116px;
|
width: 114px;
|
||||||
z-index: 3;
|
z-index: 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.form-placement-option-active {
|
||||||
|
border: solid 2px $gutenberg-control-active-color;
|
||||||
|
|
||||||
|
.form-placement-settings-overlay {
|
||||||
|
height: 138px;
|
||||||
|
width: 112px; // width of the parent element minus border on both sides
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.form-placement-option-label {
|
.form-placement-option-label {
|
||||||
align-items: center;
|
align-items: center;
|
||||||
color: $form-placement-option-text-color;
|
color: $form-placement-option-text-color;
|
||||||
|
@@ -1,14 +1,28 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import MailPoet from 'mailpoet';
|
import MailPoet from 'mailpoet';
|
||||||
|
import { useSelect } from '@wordpress/data';
|
||||||
|
|
||||||
import FormPlacementOption from './form_placement_option';
|
import FormPlacementOption from './form_placement_option';
|
||||||
import Icon from './below_pages_icon';
|
import Icon from './below_pages_icon';
|
||||||
|
|
||||||
const BelowPages = () => (
|
const BelowPages = () => {
|
||||||
<FormPlacementOption
|
const placeFormBellowAllPages = useSelect(
|
||||||
label={MailPoet.I18n.t('placeFormBellowPages')}
|
(select) => select('mailpoet-form-editor').placeFormBellowAllPages(),
|
||||||
icon={Icon}
|
[]
|
||||||
/>
|
);
|
||||||
);
|
|
||||||
|
const placeFormBellowAllPosts = useSelect(
|
||||||
|
(select) => select('mailpoet-form-editor').placeFormBellowAllPosts(),
|
||||||
|
[]
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<FormPlacementOption
|
||||||
|
label={MailPoet.I18n.t('placeFormBellowPages')}
|
||||||
|
icon={Icon}
|
||||||
|
active={placeFormBellowAllPages || placeFormBellowAllPosts}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
export default BelowPages;
|
export default BelowPages;
|
||||||
|
@@ -6,13 +6,19 @@ import SettingsIcon from './settings_icon';
|
|||||||
type Props = {
|
type Props = {
|
||||||
label: string,
|
label: string,
|
||||||
icon: JSX.Element,
|
icon: JSX.Element,
|
||||||
|
active: boolean,
|
||||||
}
|
}
|
||||||
|
|
||||||
const FormPlacementOption = ({ label, icon }: Props) => {
|
const FormPlacementOption = ({ label, icon, active }: Props) => {
|
||||||
const [hover, setHover] = useState(false);
|
const [hover, setHover] = useState(false);
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className="form-placement-option"
|
className={
|
||||||
|
classnames(
|
||||||
|
'form-placement-option',
|
||||||
|
{ 'form-placement-option-active': active }
|
||||||
|
)
|
||||||
|
}
|
||||||
onMouseEnter={() => setHover(true)}
|
onMouseEnter={() => setHover(true)}
|
||||||
onMouseLeave={() => setHover(false)}
|
onMouseLeave={() => setHover(false)}
|
||||||
>
|
>
|
||||||
|
Reference in New Issue
Block a user