A number literal is a DSL AST object holding a numeric value. Its projection renders the value directly, or adds a dollar prefix or percent postfix according to the enclosing Data Attribute’s type. section 4.2.3
Projecting a number literal requires these steps:
- Pass the containing AST object as parent when projecting an initial value or attribute value. section 4.2.3
- Check whether parent is a Data Attribute and read parent.settings["type"]. section 4.2.3
- Render $ for amount, % for percentage, and no affix for other types. section 4.2.3
Context-sensitive projection
A Number with value 25 under an amount-typed Data Attribute renders as $25; under a percentage-typed attribute, it renders as 25%. section 4.2.3
case "Number": {
const type = parent && parent.concept === "Data Attribute"
&& parent.settings["type"]
return <div className="inline">
{type === "amount" && <span className="keyword">$</span>}
<span className="value">{settings["value"]}</span>
{type === "percentage"
&& <span className="keyword">%</span>}
</div>
}
The implementation combines parent-type detection with conditional JSX spans for the dollar prefix and percent postfix. section 4.2.3
