Skip to content

Commit

Permalink
fix(formula): fix hovering style
Browse files Browse the repository at this point in the history
Signed-off-by: Diana Lease <dianarlease@gmail.com>
  • Loading branch information
DianaLease committed Aug 26, 2020
1 parent a1a2d5e commit 16cebce
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 26 deletions.
4 changes: 2 additions & 2 deletions packages/ui-contract-editor/src/lib/ContractEditor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ const contractProps = {
*/
const ContractEditor = (props) => {
const [hoveringFormulaContract, setHoveringFormulaContract] = useState(false);
const [formulaNode, setFormulaNode] = useState({});
const [formulaNode, setFormulaNode] = useState(null);
const withClausesProps = {
onClauseUpdated: props.onClauseUpdated,
pasteToContract: props.pasteToContract
Expand All @@ -87,7 +87,7 @@ const ContractEditor = (props) => {
const isFormulaDependency = useCallback((editor, variableNode) => {
let formulaClauseName;
let isVariableFormulaDependency = false;
if (!hoveringFormulaContract) return isVariableFormulaDependency;
if (!hoveringFormulaContract || !formulaNode) return isVariableFormulaDependency;
const formulaPATH = ReactEditor.findPath(editor, formulaNode);
const variablePATH = ReactEditor.findPath(editor, variableNode);
// eslint-disable-next-line no-restricted-syntax
Expand Down
24 changes: 12 additions & 12 deletions packages/ui-contract-editor/src/lib/components/Formula/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,23 @@ import { FORMULA } from '../../ContractEditor/plugins/withClauseSchema';
// overflow-wrap: break-word; // NEEDS TO BE NONE
export const FormulaTooltip = styled.span`
visibility: ${props => (props.currentHover ? 'visible' : 'hidden')};
margin-top: -${props => props.tooltipHeight}em;
margin-top: -${props => (props.tooltipHeight + 1.35)}em;
white-space: normal;
&:before {
content: '';
position: absolute;
top: ${props => props.caretTop}px;
bottom: -6.7px;
left: ${props => props.caretLeft - 1}px;
border-top: 5px solid #141F3C;
border-left: 5px solid transparent;
border-right: 5px solid transparent;
border-top: 6px solid #141F3C;
border-left: 6px solid transparent;
border-right: 6px solid transparent;
}
&:after {
content: '';
position: absolute;
top: ${props => props.caretTop}px;
bottom: -6.7px;
left: ${props => props.caretLeft}px;
border-top: 4px solid #141F3C;
border-left: 4px solid transparent;
Expand Down Expand Up @@ -70,24 +70,24 @@ const Formula = React.forwardRef((props, ref) => {
const formulaProps = {
id: data.name,
className: FORMULA,
ref
ref,
...attributes
};

const formulaTooltip = {
className: 'variableTooltip',
currentHover: hoveringFormula,
caretTop: 21,
caretLeft: 2,
tooltipHeight: 1.85,
contentEditable: false
};

return (
<span {...wrapperProps}>
<FormulaTooltip {...formulaTooltip}>
{data.code}
</FormulaTooltip>
<span {...formulaProps}>{children}</span>
<FormulaTooltip {...formulaTooltip}>
{data.code}
</FormulaTooltip>
<span {...formulaProps}>{children}</span>
</span>
);
});
Expand Down
14 changes: 2 additions & 12 deletions packages/ui-contract-editor/src/lib/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,9 @@ a {
background-color: #d4d8e1;
}

.variableTooltip {
opacity: 1 !important;
border: 1px solid #141F3C;
border-radius: 2px;
background-color: #141F3C;
transition-duration: 0.25s;
color: #FFFFFF;
padding: 1px 3px;
position: absolute;
}

.conditionalTooltip,
.optionalTooltip {
.optionalTooltip,
.variableTooltip {
opacity: 1 !important;
border: 1px solid #141F3C;
border-radius: 2px;
Expand Down

0 comments on commit 16cebce

Please sign in to comment.