From 21c516ef3ec2cb4e3c2017ca0821a4539e8f78b3 Mon Sep 17 00:00:00 2001 From: Mariusz Klimek Date: Fri, 23 Oct 2020 18:12:38 +0200 Subject: [PATCH] Configurable font size --- README.md | 2 ++ dist/clock-card.js | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4fc589c..d4e7a0d 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ A simple analog clock card for Home Assistant. Colors are based on your current | type | string | **Required** | "custom:clock-card" | time_zone | string | **Optional** | The timezone you would like to display. If ommited your current device time will be used. Must be a valid [TZ database name](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) | size | number | **Optional** | The size of the clock in px. Default is 300 +| font_size | number | **Optional** | The size of the date string in px. Default is 20 | disable_seconds | boolean | **Optional** | Disable the seconds hand | show_continent | boolean | **Optional** | Display the timezone continent beneath the clock | show_city | boolean | **Optional** | Display the timezone city beneath the clock @@ -56,6 +57,7 @@ All theme options can be set with a CSS valid color option. - type: "custom:clock-card" time_zone: "America/Chicago" #OPTIONAL size: 250 #OPTIONAL + font_size: 100 #OPTIONAL disable_seconds: true #OPTIONAL caption: "Corporate" display_date: "MM/DD/YY" diff --git a/dist/clock-card.js b/dist/clock-card.js index 81c1ce8..cae9434 100644 --- a/dist/clock-card.js +++ b/dist/clock-card.js @@ -51,6 +51,7 @@ class ClockCard extends HTMLElement { var config = this.config; var theme = config.theme ? config.theme : {}; var clock_size = config.size ? config.size : 300; + var font_size = config.font_size ? config.font_size : 20; const card = document.createElement('ha-card'); this.content = document.createElement('div'); this.content.style.display = "flex"; @@ -70,9 +71,9 @@ class ClockCard extends HTMLElement { (config.show_city ? formatted_timezone : formatted_timezone.substr(0, formatted_timezone.indexOf("/"))) : (config.show_city ? formatted_timezone.substr(formatted_timezone.indexOf("/") + 1) : ""); } - var timezone_html = caption ? `

${caption}

` : ""; + var timezone_html = caption ? `

${caption}

` : ""; var now = config.time_zone ? timezoneTime(config.time_zone) : new Date(); - timezone_html = config.display_date ? timezone_html + `

${now.format(config.display_date)}

` : timezone_html; + timezone_html = config.display_date ? timezone_html + `

${now.format(config.display_date)}

` : timezone_html; this.content.innerHTML = `${timezone_html}`; card.appendChild(this.content); this.appendChild(card);