Template:ElementTooltip

From Oxygen Not Included Wiki
Jump to navigation Jump to search
Template-info.svg Documentation Edit this documentation at Template:ElementTooltip/doc.

Description

With minimal code, this Template adds a picture with link in the same fashion as {{Pic}}, additionally it removes the regular hovertext and adds an infobox when the cursor hovers over the text.

Syntax

Simply place {{ElementTooltip |Elementname}}, or {{ElementTooltip |Elementname |Display text}} onto a page. It is possible to suppress the picture by using {{ElementTooltip |Elementname |showPic = no}}

Examples

The Tooltip for Elements like {{ElementTooltip |Copper}} for Copper.pngCopper Molten Copper.png, also in it's Molten Copper.pngdrinkable Copper Gas.png Copper.png and Copper Gas.pngbreathable Form Molten Copper.png, can easily be inserted into any Paragraph. This should work for all Elements, even those that split into multiple elements on phase Transition such as Salt Water.pngSalt Water Steam.png Salt.png Brine.png Ice.png. Further Examples for this Tempalte are Regolith.pngRegolith Magma.png who notable changes in SHC upon phase change, or Natural Gas.pngNatural Gas Liquid Methane.png whose element ID is actually Methane, while Liquid Methane.pngMethane Natural Gas.png Solid Methane.png itself is correctly recognized as the liquid version. Water Steam.png Ice.png does not show the Pic

Upon Failure to provide the proper elementname like Steam Turbine.pngSteam Turbine (which is a Building, not an element) the Text will be displayed normally, but no special Tooltip.

Explanation

The contents of the Infobox is fetched with the Lua module ElementTooltip, which returns the data as a <span> with data attributes such as data-specificheatcapacity="4.179" or data-caption="(CO--2--) Carbon Dioxide is an atomically heavy chemical compound in a Gaseous state.\nIt tends to sink below other gases."

The styling for this template can be found in a /styles.css subpage.

The Gadget Advanced Tooltip reads the data-* attributes on the <span> (which was provided with Lua), and replaces the entire span with an infobox-like structure like shown below.

example html of infobox-like structure
<div class="advanced-tooltip--content element-tooltip--content"">
    <h2>Copper</h2>
    <div class="element-tooltip--caption">
        (Cu) Copper is a conductive Metal. It is suitable for building Power systems.
    </div>

    <div class="element-tooltip--row">
        <div class="element-tooltip--label">
            Specific Heat Capacity
        </div>
        <div class="element-tooltip--data">
            0.385(DTU/g)/°C
        </div>
    </div>
    
    <div class="element-tooltip--row">
        <div class="element-tooltip--label">
            Thermal Conductivity
        </div>
        <div class="element-tooltip--data">
            60(DTU/(m*s))/°C
        </div>
    </div>

    <div class="element-tooltip--row">
        <div class="element-tooltip--label">
            Hardness
        </div>
        <div class="element-tooltip--data">
            25 (Firm)
        </div>
    </div>

    <div class="element-tooltip--row">
        <div class="element-tooltip--label">
            Max Mass
        </div>
        <div class="element-tooltip--data">
            3870kg
        </div>
    </div>
    
    <div class="element-tooltip--row">
        <div class="element-tooltip--label">
            at 1083.85°C melts into
        </div>
        <div class="element-tooltip--data">
            Liquid Copper(SHC: 0.386)
        </div>
    </div>
</div>