Hover state for form placement component

[MAILPOET-2738]
This commit is contained in:
Pavel Dohnal
2020-03-16 13:02:12 +01:00
committed by Veljko V
parent c9a2a44970
commit 15df4ec37c
2 changed files with 58 additions and 16 deletions

View File

@@ -123,10 +123,21 @@ $form-placement-option-oval-border: #969ca1;
justify-content: space-between;
margin: 0 16px 16px 0;
padding: 6px;
position: relative;
text-align: center;
width: 116px;
}
.form-placement-settings-overlay {
background-color: rgba(0, 0, 0, .3);
height: 142px;
left: 0;
position: absolute;
top: 0;
width: 116px;
z-index: 3;
}
.form-placement-option-label {
align-items: center;
color: $form-placement-option-text-color;
@@ -135,6 +146,7 @@ $form-placement-option-oval-border: #969ca1;
height: 40px;
justify-content: center;
width: 100%;
z-index: 2;
p {
margin-bottom: 0;
@@ -147,6 +159,7 @@ $form-placement-option-oval-border: #969ca1;
height: 25px;
justify-content: space-between;
width: 100%;
z-index: 4;
}
.form-placement-settings-oval {
@@ -163,6 +176,13 @@ $form-placement-option-oval-border: #969ca1;
}
height: 14px;
width: 14px;
z-index: 4;
}
.form-placement-settings-icon-hover {
svg {
fill: white;
}
}
.form-placement-option-icon {
@@ -176,4 +196,5 @@ $form-placement-option-oval-border: #969ca1;
margin: 0 auto;
object-fit: contain;
width: 76px;
z-index: 2;
}

View File

@@ -1,4 +1,5 @@
import React from 'react';
import React, { useState } from 'react';
import classnames from 'classnames';
import SettingsIcon from './settings_icon';
@@ -7,15 +8,30 @@ type Props = {
icon: JSX.Element,
}
const FormPlacementOption = ({ label, icon }: Props) => (
<div className="form-placement-option">
const FormPlacementOption = ({ label, icon }: Props) => {
const [hover, setHover] = useState(false);
return (
<div
className="form-placement-option"
onMouseEnter={() => setHover(true)}
onMouseLeave={() => setHover(false)}
>
<div>
<div className="form-placement-option-settings">
<div className="form-placement-settings-icon">
<div
className={
classnames(
'form-placement-settings-icon',
{ 'form-placement-settings-icon-hover': hover }
)
}
>
{SettingsIcon}
</div>
{/* todo next line only show on hover */}
<div className="form-placement-settings-oval" />
{
hover
&& <div className="form-placement-settings-oval" />
}
</div>
<div className="form-placement-option-icon">
{icon}
@@ -24,7 +40,12 @@ const FormPlacementOption = ({ label, icon }: Props) => (
<div className="form-placement-option-label">
<p>{label}</p>
</div>
{
hover
&& <div className="form-placement-settings-overlay" />
}
</div>
);
);
};
export default FormPlacementOption;