tabs
Groups components into tabs; the selected tab is kept when the status bar refreshes.
Examples
Two tabs show market data and the account.
javascript
function main() {
var ticker = exchange.GetTicker()
var account = exchange.GetAccount()
if (!ticker || !account) return
LogStatus({type: "tabs", items: [
{title: "Market", cols: 2, items: [
{type: "kpi", title: "Last", value: ticker.Last},
{type: "kpi", title: "24h volume", value: ticker.Volume, format: {compact: true}}
]},
{title: "Account", items: [{type: "stat", items: [
{label: "Available", value: account.Balance},
{label: "Frozen", value: account.FrozenBalance}
]}]}
]})
}
python
def main():
ticker = exchange.GetTicker()
account = exchange.GetAccount()
if not ticker or not account:
return
LogStatus({"type": "tabs", "items": [
{"title": "Market", "cols": 2, "items": [
{"type": "kpi", "title": "Last", "value": ticker["Last"]},
{"type": "kpi", "title": "24h volume", "value": ticker["Volume"],
"format": {"compact": True}}
]},
{"title": "Account", "items": [{"type": "stat", "items": [
{"label": "Available", "value": account["Balance"]},
{"label": "Frozen", "value": account["FrozenBalance"]}
]}]}
]})
rust
fn main() {
let Ok(t) = exchange.GetTicker(None) else { return };
let Ok(a) = exchange.GetAccount() else { return };
let market = format!(
r#"{{"title": "Market", "cols": 2, "items": [
{{"type": "kpi", "title": "Last", "value": {}}},
{{"type": "kpi", "title": "24h volume", "value": {},
"format": {{"compact": true}}}}]}}"#,
t.Last, t.Volume
);
let account = format!(
r#"{{"title": "Account", "items": [{{"type": "stat", "items": [
{{"label": "Available", "value": {}}}, {{"label": "Frozen", "value": {}}}]}}]}}"#,
a.Balance, a.FrozenBalance
);
// When this JSON is the whole status bar it may span several lines
LogStatus!(format!(r#"{{"type": "tabs", "items": [{}, {}]}}"#, market, account));
}Attributes
| Name | Type | Description |
type | string | Required. Always |
items | object array | Required. One entry per tab. |
items[].title | string | Tab label. |
items[].items | array | Components of the tab, laid out as a |
items[].cols | number | Number of columns of the tab. Default |
id | string | Stable identifier. Set it when the number or order of components changes, so refreshes do not rebuild the component. |
span | number | Number of columns it spans in the enclosing |
See Also
Remarks
tabs has no title of its own. The content of each tab drops columns with the container width like grid; nesting is limited to 6 levels.
An array of tables wrapped in backticks (the old style) is also shown as tabs; see LogStatus-table.