From 1903ea07a27dd6c044a65568a639380736bb4513 Mon Sep 17 00:00:00 2001 From: DUDEbehindDUDE Date: Sun, 14 Apr 2024 01:36:09 -0400 Subject: [PATCH] Add tooltips to clicking power + bps counter, fix grammar --- src/App.js | 134 ++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 108 insertions(+), 26 deletions(-) diff --git a/src/App.js b/src/App.js index 4e994a3..6764c54 100644 --- a/src/App.js +++ b/src/App.js @@ -162,16 +162,47 @@ function MainCounters({ total, bps }) { bps = Intl.NumberFormat("en", {}).format(bps); } + const bpsCounter =

per second: {bps}

; + const bpsCounterAddContent = [ + "Bitcoin per second (BPS) represents how many Bitcoins you are passively" + + " earning each second.", + "BPS can be increased by purchasing systems and overclocks.", + "You can view the BPS of each system in the bottom right of each card in" + + " the systems panel." + ] + return (

Bitcoin: {total}

-

per second: {bps}

+
); } +// Clicking Power Counter function SecondaryCounters({ bpc }) { - return

Clicking Power: {bpc} bitcoin per click

; + const element = ( +

Clicking Power: {bpc} Bitcoin per click

+ ); + const addContent = [ + "Clicking Power represents how much Bitcoin you earn from each click.", + "For example, if your clicking power was 2, you would earn 2 Bitcoin" + + " each time you manually clicked the Bitcoin.", + "To increase your clicking power, upgrade the RAM in your systems.", + ]; + + return ( + + ); } // Everything you can buy is part of this component @@ -568,7 +599,7 @@ function Systems({ : []; return ( -

Upgrades for {selected}

- } mainItem={{ - descriptors: [], title: ownedItems.systems[selected].items.gpu.name, desc: ownedItems.systems[selected].items.gpu.desc, }} @@ -700,10 +730,10 @@ function SystemUpgrades({ selected, buyItem, calcItemPrice }) { "gpu" )} time(s), resulting in +${format( getLevel("gpu") * ownedItems.systems[selected].baseBps - )} bps (${getLevel("gpu")}x increase)`, + )} BPS (${getLevel("gpu")}x increase)`, ]} /> - } mainItem={{ - descriptors: [], title: ownedItems.systems[selected].items.cpu.name, desc: ownedItems.systems[selected].items.cpu.desc, }} @@ -732,7 +761,7 @@ function SystemUpgrades({ selected, buyItem, calcItemPrice }) { }x production boost`, ]} /> - } mainItem={{ - descriptors: [], title: getLevel("ram") + " GB", desc: "It's random (haha get it because it stands for RANDOM Access Memory?!?)", }} @@ -787,8 +815,47 @@ function ItemButton({ ); } -// Renders a tooltip over the provided element when the element is hovered over -function TooltipItem({ element, mainItem, additionalContent = [] }) { +// Tooltips for descriptions +function DescriptionTooltip({ + element, + title, + additionalContent = [], + placement = "top", +}) { + // add separator between additional content and title/desc + // if there is additional content + const separator = + additionalContent.length > 0 ?
: null; + + const _additionalContent = additionalContent.map((item) => { + return
  • {item}
  • ; + }); + + const tooltipContent = ( + <> +
    +

    {title}

    +
    + {separator} +
      {_additionalContent}
    + + ); + + return ( + + {element} + + ); +} + +// Renders tooltips for store items +function StoreItemTooltip({ element, mainItem, additionalContent = [] }) { /* Examples * mainItem = { * descriptors: [ @@ -802,29 +869,44 @@ function TooltipItem({ element, mainItem, additionalContent = [] }) { // Format tooltip content const tooltip = () => { - const descriptors = mainItem.descriptors.map((descriptor) => ( - - {descriptor.text} - - )); - const title = mainItem.title; - const desc = `"${mainItem.desc}"`; + // get descriptors if present + let descriptors = []; + if (mainItem.descriptors != undefined) { + descriptors = mainItem.descriptors.map((descriptor) => ( + + {descriptor.text} + + )); + } + + // if desc is undefined, don't render anything + const desc = + mainItem.desc === undefined ? ( + "" + ) : ( + + ); + + // add separator between additional content and title/desc + // if there is additional content const separator = additionalContent.length > 0 ?
    : null; + const _additionalContent = additionalContent.map((item) => { return
  • {item}
  • ; }); + return ( <>
    {descriptors}
    -

    {title}

    - +

    {mainItem.title}

    + {desc}
    {separator}
      {_additionalContent}