Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added default MagicMirror table layout #76

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ If you also like this module and want to thank, please rate this repository with
maxWidth: "100%",
numberDecimalsPercentages: 1,
numberDecimalsValues: 2,
displayMode: "vertical", // One of ["none", "vertical", "horizontal", "table"]
displayMode: "vertical", // One of ["none", "vertical", "horizontal", "table", "default-table"]
showColors: true,
showCurrency: true,
showChangePercent: true,
Expand Down Expand Up @@ -113,9 +113,9 @@ If you also like this module and want to thank, please rate this repository with
### Options

| Option | Description |
| --------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| --------------------------------- |----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `currencyStyle` | Style of currency. <br><br>**Type:** `String` <br>**Allowed values:** `"code"` (EUR), `"symbol"` (€) or `"name"` (Euro)<br> **Default value:** `code` |
| `displayMode` | Display mode for ticker. <br><br>**Type:** `String`<br>**Allowed Values:** `"none"`, `"vertical"`, `"horizontal"` or `"table"` <br>**Default value:** `"vertical"` |
| `displayMode` | Display mode for ticker. <br><br>**Type:** `String`<br>**Allowed Values:** `"none"`, `"vertical"`, `"horizontal"`, `"table"` or `"default-table"` <br>**Default value:** `"vertical"` |
| `fadeSpeedInSeconds` | Animation speed for ticker. <br><br>**Type:** `Number`<br> **Default value:** `3.5` |
| `lastUpdateFormat` | Define dateformat, if the last update should be displayed. <br><br>**Type:** `String`<br> **Default value:** `"HH:mm"` |
| `locale` | Option to override the global/system locale for value formatting. <br><br>**Type:** `String`<br> **Default value:** `undefined` (system locale) |
Expand Down
2 changes: 1 addition & 1 deletion src/types/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export type Config = {
maxWidth: string
numberDecimalsPercentages: number
numberDecimalsValues: number
displayMode: 'vertical' | 'horizontal' | 'none' | 'table'
displayMode: 'vertical' | 'horizontal' | 'none' | 'table' | 'default-table'
scroll?: 'vertical' | 'horizontal' | 'none' | 'table'
showCurrency: boolean
showColors: boolean
Expand Down
26 changes: 26 additions & 0 deletions templates/DefaultTableStockList.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{% macro render() %}
<table class="{{ config.tableClass }}">
{% for stock in stocks %}
<tr>
<td class="bright"><span>{{ utils.getStockName(stock) }}</span></td>
<td>
{% if utils.getStockChange(stock) > 0 %}
{% set colorStyle = "green" %}
{% elif utils.getStockChange(stock) < 0 %}
{% set colorStyle = "red" %}
{% else %}
{% set colorStyle = "" %}
{% endif %}
<span>{{ utils.getCurrentValueAsString(stock, config) }}</span>
</td>
<td>
<span>
<span>
<span style="{% if colorStyle != "" %} color:{{ colorStyle }}{%endif%}">{% if colorStyle == "green" %}+{%endif%}{{ utils.getStockChangePercentAsString(stock, config) }}</span>
</span>
</span>
</td>
</tr>
{% endfor %}
</table>
{% endmacro %}
25 changes: 15 additions & 10 deletions templates/MMM-Jast.njk
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
{% import "templates/VerticalStockList.njk" as verticalStockList with context %}
{% import "templates/HorizontalStockList.njk" as horizontalStockList with context %}
{% import "templates/TableStockList.njk" as tableStockList with context %}
{% import "templates/DefaultTableStockList.njk" as defaultTableStockList with context %}
{% if stocks.length > 0 %}
<div class="normal medium jast-wrapper {{ config.displayMode }}{% if not config.showColors %} monochrome{% endif %}" style="max-width: {{config.maxWidth}};">
{% if config.displayMode == "horizontal" %}
{{ horizontalStockList.render() }}
{{ horizontalStockList.render("2") }}
{% elif config.displayMode == "table" %}
{{ tableStockList.render() }}
{% else %}
{{ verticalStockList.render() }}
{% endif %}
</div>
{% if config.displayMode == "default-table" %}
{{ defaultTableStockList.render() }}
{% else %}
<div class="normal medium jast-wrapper {{ config.displayMode }}{% if not config.showColors %} monochrome{% endif %}" style="max-width: {{config.maxWidth}};">
{% if config.displayMode == "horizontal" %}
{{ horizontalStockList.render() }}
{{ horizontalStockList.render("2") }}
{% elif config.displayMode == "table" %}
{{ tableStockList.render() }}
{% else %}
{{ verticalStockList.render() }}
{% endif %}
</div>
{% endif %}
{% else %}
<div class="dimmed light small">
{{ "LOADING" | translate | safe }}
Expand Down