From ae10f3d21f72a84fca3e8b8f9aad7f11f77a6e93 Mon Sep 17 00:00:00 2001 From: Mads Rasmussen Date: Thu, 26 Oct 2017 20:10:22 +0200 Subject: [PATCH] calculate progress circle font size instead of manually setting it + align colors --- .../components/umbprogresscircle.directive.js | 25 +++++------- .../less/components/umb-progress-circle.less | 40 ++++++------------- .../src/views/common/drawers/help/help.html | 4 +- .../views/components/umb-progress-circle.html | 6 +-- 4 files changed, 26 insertions(+), 49 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/umbprogresscircle.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/umbprogresscircle.directive.js index 22e6b9dd77..ad79cb2e3b 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/components/umbprogresscircle.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/umbprogresscircle.directive.js @@ -9,28 +9,22 @@ Use this directive to render a circular progressbar.

Markup example

-	
- +
+ + color="secondary">
- @param {string} size (attribute): This parameter defines the width and the height of the circle in pixels. @param {string} percentage (attribute): Takes a number between 0 and 100 and applies it to the circle's highlight length. -@param {string} strokeColor (attribute): the color of the highlight (green, purple, red, yellow). Green by default. -@param {string} fontSize (attribute): Defines the size of the number in the center (xs, s, m, l, xl) +@param {string} color (attribute): the color of the highlight (primary, secondary, success, warning, danger). Success by default. **/ - - - (function (){ 'use strict'; @@ -44,10 +38,10 @@ Use this directive to render a circular progressbar. var percent = scope.percentage; if (percent > 100) { - percent = 100 + percent = 100; } else if (percent < 0) { - percent = 0 + percent = 0; } // calculating the circle's highlight @@ -63,7 +57,9 @@ Use this directive to render a circular progressbar. // Distance for the highlight dash's offset scope.strokeDashOffset = strokeDashOffset; - var coloring = circle.attr('stroke'); + + // set font size + scope.percentageSize = (scope.size * 0.3) + "px"; } @@ -78,8 +74,7 @@ Use this directive to render a circular progressbar. scope: { size: "@?", percentage: "@", - strokeColor: "@", - fontSize: "@" + color: "@" }, link: link diff --git a/src/Umbraco.Web.UI.Client/src/less/components/umb-progress-circle.less b/src/Umbraco.Web.UI.Client/src/less/components/umb-progress-circle.less index ef799ca77e..e7c669054e 100644 --- a/src/Umbraco.Web.UI.Client/src/less/components/umb-progress-circle.less +++ b/src/Umbraco.Web.UI.Client/src/less/components/umb-progress-circle.less @@ -19,20 +19,24 @@ stroke: @green; } -.umb-progress-circle__highlight--green { +.umb-progress-circle__highlight--primary { + stroke: @turquoise; +} + +.umb-progress-circle__highlight--secondary { + stroke: @purple; +} + +.umb-progress-circle__highlight--success { stroke: @green; } -.umb-progress-circle__highlight--red { - stroke: @red; -} - -.umb-progress-circle__highlight--yellow { +.umb-progress-circle__highlight--warning { stroke: @yellow; } -.umb-progress-circle__highlight--purple { - stroke: @purple; +.umb-progress-circle__highlight--danger { + stroke: @red; } // circle progressbar bg @@ -46,23 +50,3 @@ font-weight: 700; text-align: center; } - -.umb-progress-circle__percentage--xs{ - font-size: 12px; -} - -.umb-progress-circle__percentage--s{ - font-size: 14px; -} - -.umb-progress-circle__percentage--m{ - font-size: 16px; -} - -.umb-progress-circle__percentage--l{ - font-size: 18px; -} - -.umb-progress-circle__percentage--xl{ - font-size: 20px; -} diff --git a/src/Umbraco.Web.UI.Client/src/views/common/drawers/help/help.html b/src/Umbraco.Web.UI.Client/src/views/common/drawers/help/help.html index 75ad97db83..b26486af73 100644 --- a/src/Umbraco.Web.UI.Client/src/views/common/drawers/help/help.html +++ b/src/Umbraco.Web.UI.Client/src/views/common/drawers/help/help.html @@ -20,9 +20,7 @@
{{key}}
+ size="40"> diff --git a/src/Umbraco.Web.UI.Client/src/views/components/umb-progress-circle.html b/src/Umbraco.Web.UI.Client/src/views/components/umb-progress-circle.html index bc690dc843..9c23d2e89c 100644 --- a/src/Umbraco.Web.UI.Client/src/views/components/umb-progress-circle.html +++ b/src/Umbraco.Web.UI.Client/src/views/components/umb-progress-circle.html @@ -1,7 +1,7 @@ -
+
- + -
{{ percentage }}%
+
{{ percentage }}%
\ No newline at end of file