From 4c6888c587b8a3385c89a959b57ed5a901236b49 Mon Sep 17 00:00:00 2001 From: Zenoo Date: Thu, 10 Jun 2021 00:08:08 +0200 Subject: [PATCH] Fix display issues on mobile (#373) --- source/app/web/statics/app.placeholder.js | 1 + source/plugins/habits/README.md | 1 + source/plugins/habits/index.mjs | 4 ++-- source/plugins/habits/metadata.yml | 6 ++++++ source/plugins/habits/tests.yml | 1 + source/templates/classic/image.svg | 2 +- source/templates/classic/partials/followup.ejs | 2 +- source/templates/classic/partials/habits.ejs | 18 +++++++++++++----- source/templates/classic/style.css | 8 ++++++++ 9 files changed, 34 insertions(+), 9 deletions(-) diff --git a/source/app/web/statics/app.placeholder.js b/source/app/web/statics/app.placeholder.js index 62afa93c..211cc6fb 100644 --- a/source/app/web/statics/app.placeholder.js +++ b/source/app/web/statics/app.placeholder.js @@ -403,6 +403,7 @@ habits: { facts: options["habits.facts"], charts: options["habits.charts"], + trim: options["habits.trim"], lines: { average: { chars: faker.datatype.number(1000)/10, diff --git a/source/plugins/habits/README.md b/source/plugins/habits/README.md index 125778fd..f65c112b 100644 --- a/source/plugins/habits/README.md +++ b/source/plugins/habits/README.md @@ -34,5 +34,6 @@ By default, dates use Greenwich meridian (GMT/UTC). Be sure to set your timezone plugin_habits_days: 14 # Keep only events from last 14 days plugin_habits_facts: yes # Display facts section plugin_habits_charts: yes # Display charts section + plugin_habits_trim: yes # Trim unused hours on daily chart config_timezone: Europe/Paris # Set timezone ``` diff --git a/source/plugins/habits/index.mjs b/source/plugins/habits/index.mjs index 62b50f8f..6ba61e9a 100644 --- a/source/plugins/habits/index.mjs +++ b/source/plugins/habits/index.mjs @@ -10,10 +10,10 @@ export default async function({login, data, rest, imports, q, account}, {enabled return null //Load inputs - let {from, days, facts, charts} = imports.metadata.plugins.habits.inputs({data, account, q}, defaults) + let {from, days, facts, charts, trim} = imports.metadata.plugins.habits.inputs({data, account, q}, defaults) //Initialization - const habits = {facts, charts, lines:{average:{chars:0}}, commits:{fetched:0, hour:NaN, hours:{}, day:NaN, days:{}}, indents:{style:"", spaces:0, tabs:0}, linguist:{available:false, ordered:[], languages:{}}} + const habits = {facts, charts, trim, lines:{average:{chars:0}}, commits:{fetched:0, hour:NaN, hours:{}, day:NaN, days:{}}, indents:{style:"", spaces:0, tabs:0}, linguist:{available:false, ordered:[], languages:{}}} const pages = Math.ceil(from / 100) const offset = data.config.timezone?.offset ?? 0 diff --git a/source/plugins/habits/metadata.yml b/source/plugins/habits/metadata.yml index 8192692a..37b8ca32 100644 --- a/source/plugins/habits/metadata.yml +++ b/source/plugins/habits/metadata.yml @@ -43,3 +43,9 @@ inputs: description: Display coding habits charts based on recent activity type: boolean default: no + + # Trim unused hours on daily chart + plugin_habits_trim: + description: Trim unused hours on daily chart + type: boolean + default: no diff --git a/source/plugins/habits/tests.yml b/source/plugins/habits/tests.yml index 3116d420..d0407720 100644 --- a/source/plugins/habits/tests.yml +++ b/source/plugins/habits/tests.yml @@ -11,6 +11,7 @@ plugin_habits: yes plugin_habits_facts: no plugin_habits_charts: yes + plugin_habits_trim: yes config_timezone: Europe/Paris - name: Habits plugin (facts) diff --git a/source/templates/classic/image.svg b/source/templates/classic/image.svg index 80406cfe..c9c9287d 100644 --- a/source/templates/classic/image.svg +++ b/source/templates/classic/image.svg @@ -1,4 +1,4 @@ - + diff --git a/source/templates/classic/partials/followup.ejs b/source/templates/classic/partials/followup.ejs index 99e94e16..1c894110 100644 --- a/source/templates/classic/partials/followup.ejs +++ b/source/templates/classic/partials/followup.ejs @@ -2,7 +2,7 @@

- Overall issues and pull requests status + Overall issues and pull requests status

<% if (plugins.followup.error) { %> diff --git a/source/templates/classic/partials/habits.ejs b/source/templates/classic/partials/habits.ejs index fe3be6b0..6f00fcf1 100644 --- a/source/templates/classic/partials/habits.ejs +++ b/source/templates/classic/partials/habits.ejs @@ -1,6 +1,6 @@ <% if (plugins.habits) { %>
-

+

Recent coding habits <% if (plugins.habits.commits?.fetched) { %> @@ -41,11 +41,19 @@

Commit activity per hour of day

- <% for (let h = 0; h < 24; h++) { const p = (plugins.habits.commits.hours[h]??0)/(plugins.habits.commits.hours.max??1); %> + <% var displayedValues = []; %> + <% for (let h = 0; h < 24; h++) { displayedValues.push([h, (plugins.habits.commits.hours[h]??0)/(plugins.habits.commits.hours.max??1), plugins.habits.commits.hours[h]]) } %> + + <% if (plugins.habits.trim) { %> + <% while (displayedValues[0][1] === 0) { displayedValues.shift(); } %> + <% while (displayedValues[displayedValues.length-1][1] === 0){ displayedValues.pop(); } %> + <% } %> + + <% for(let i = 0; i < displayedValues.length; i++) { %>
- <%= plugins.habits.commits.hours[h] %> -
- <%= `${h}`.padStart(2, 0) %> + <%= displayedValues[i][2] %> +
+ <%= `${displayedValues[i][0]}`.padStart(2, 0) %>
<% } %>
diff --git a/source/templates/classic/style.css b/source/templates/classic/style.css index 5ac18d90..dd49015e 100644 --- a/source/templates/classic/style.css +++ b/source/templates/classic/style.css @@ -89,6 +89,9 @@ margin-bottom: 2px; white-space: nowrap; } + .field.wrap { + flex-wrap: wrap; + } .field svg { margin: 0 8px; fill: #959da5; @@ -104,6 +107,7 @@ /* Displays */ .row { display: flex; + flex-wrap: wrap; } .row section { flex: 1 1 0; @@ -227,6 +231,9 @@ .followup.legend svg:last-child { margin-right: 0; } + .followup-title{ + white-space: initial; + } /* Labels */ .label { @@ -1011,6 +1018,7 @@ border-radius: 16px; font-size: 10px; padding: 0 5px; + white-space: nowrap; } .achievement .gauge-base, .achievement .gauge-arc { stroke-width: 6;