Skip to content

Commit

Permalink
Merge pull request #29 from UniqueClone/main
Browse files Browse the repository at this point in the history
Adding tooltip to view savings required breakdown.
  • Loading branch information
UniqueClone authored Jul 16, 2024
2 parents 4621c6e + d4e0339 commit bbef4ba
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 23 deletions.
4 changes: 4 additions & 0 deletions src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@
margin: 0 auto;
padding: 2rem;
}

.tooltip {
border: 1px solid white;
}
10 changes: 0 additions & 10 deletions src/components/FeesPanel/FeesPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,16 +111,6 @@ export const FeesPanel: React.FC<FeesPanelProps> = (props: FeesPanelProps) => {
})
}
/>

<br />

{/* <PrimaryButton
onClick={() => {
setIsPanelOpen(false);
}}
>
Close
</PrimaryButton> */}
</Stack>
</Panel>
);
Expand Down
5 changes: 4 additions & 1 deletion src/components/MortgageComparison/MortgageComparison.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@ export const MortgageComparison: React.FC<MortgageComparisonProps> = () => {
<MortgageOption
fees={fees}
id={3}
{...{ interestRate, useGlobalInterestRate, maxLoan, term }}
interestRate={interestRate}
useGlobalInterestRate={useGlobalInterestRate}
maxLoan={maxLoan}
term={term}
/>
</Stack>

Expand Down
43 changes: 31 additions & 12 deletions src/components/MortgageDetails/MortgageDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ export const MortgageDetails: React.FC<MortgageDetailsProps> = (
props: MortgageDetailsProps
) => {
const { fees, interestRate, maxLoan, term } = props;
console.log(interestRate);
const [localInterestRate, setLocalInterestRate] = React.useState<number>(
interestRate ?? 4.0
);
Expand All @@ -45,7 +44,7 @@ export const MortgageDetails: React.FC<MortgageDetailsProps> = (
return;
} else if (isNaN(parseFloat(newValue))) {
return;
} else if (parseFloat(newValue) > maxLoan) {
} else if (parseFloat(newValue) > maxLoan && maxLoan > 0) {
setLoanAmount(maxLoan);
return;
} else if (parseFloat(newValue) < 0) {
Expand All @@ -60,7 +59,6 @@ export const MortgageDetails: React.FC<MortgageDetailsProps> = (
<Stack styles={containerStackStyles} tokens={containerStackTokens}>
<Stack.Item grow>
<TextField
defaultValue={"0"}
label="House Price"
onChange={(_e, newValue) => {
if (newValue === undefined) {
Expand Down Expand Up @@ -109,6 +107,7 @@ export const MortgageDetails: React.FC<MortgageDetailsProps> = (

<Stack.Item grow>
<TooltipHost
className="tooltip"
content="The maximum loan amount you can borrow is 90% of the house value, or the max loan amount you have set."
directionalHint={5}
>
Expand All @@ -131,15 +130,35 @@ export const MortgageDetails: React.FC<MortgageDetailsProps> = (
</Stack.Item>

<Stack.Item grow>
<Text variant="xLarge" style={{ color: "lightgreen" }}>
{formatter.format(
savingsRequired(
houseValue,
houseValue - loanAmount,
fees
)
)}
</Text>
<TooltipHost
className="tooltip"
tooltipProps={{
onRenderContent: () => (
<Stack tokens={{ childrenGap: 10 }}>
<Text variant="medium">
Deposit:{" "}
{formatter.format(houseValue - loanAmount)}
</Text>
<Text variant="medium">
Fees:{" "}
{formatter.format(
savingsRequired(0, 0, fees)
)}
</Text>
</Stack>
),
}}
>
<Text variant="xLarge" style={{ color: "lightgreen" }}>
{formatter.format(
savingsRequired(
houseValue,
houseValue - loanAmount,
fees
)
)}{" "}
</Text>
</TooltipHost>
</Stack.Item>

<Stack.Item grow>
Expand Down

0 comments on commit bbef4ba

Please sign in to comment.