Skip to content

Commit 4b48159

Browse files
author
crisbeto
committed
add transclusion
1 parent d57571c commit 4b48159

File tree

7 files changed

+35
-15
lines changed

7 files changed

+35
-15
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ angular.module('someModule', ['angular-svg-round-progress'])
2626
* To edit the default values, change the options in the `roundProgressConfig` constant.
2727
* Since the `0.2.0` release this directive uses dynamic binding. For example, if you want to change the fill color at a certain value, you can use `color="{{ (current / max < 0.5) ? '#ff8080' : '#45ccce' }}"`.
2828

29-
| Name | Description | Required | Default value | Possible values |
29+
| Name | Description | Required | Default value | Possible values |
3030
| --- | --- | --- | --- | --- |
31-
| `current` | The current progress. Limited by the `max` option. | Yes | undefined | Integer |
32-
| `max` | The progress' maximum value. | Yes | undefined | Integer |
31+
| `current` | The current progress. Limited by the `max` option. | Yes | undefined | Integer |
32+
| `max` | The progress' maximum value. | Yes | undefined | Integer |
3333
| `radius` | Radius of the circle. | No | 50 | Integer |
34-
| `color` | The color of the `current` value on the circle. | No | #45ccce | Hex color |
35-
| `bgcolor` | Color of the circle's background. | No | #eaeaea | Hex color |
34+
| `color` | The color of the `current` value on the circle. | No | #45ccce | Hex color or string. Refer to [this example](https://github.com/crisbeto/angular-svg-round-progressbar/issues/29) for an example of using a gradient. |
35+
| `bgcolor` | Color of the circle's background. | No | #eaeaea | Hex color or string. Refer to [this example](https://github.com/crisbeto/angular-svg-round-progressbar/issues/29) for an example of using a gradient. |
3636
| `stroke` | Specifies the circle's thickness. | No | 15 | Integer |
3737
| `semi` | Whether the progressbar should be a full circle or a semicircle. | No | false | Boolean |
3838
| `clockwise` | Whether the progressbar should rotate clockwise or counter-clockwise. | No | true | Boolean |

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-svg-round-progressbar",
3-
"version": "0.2.7",
3+
"version": "0.2.8",
44
"homepage": "https://github.com/crisbeto/angular-svg-round-progressbar",
55
"authors": [
66
"crisbeto"

build/index.html

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ <h2>Sample progressbar</h2>
101101
round-progress
102102
max="max"
103103
current="current"
104-
color="{{ currentColor }}"
104+
color="{{ getColor() }}"
105105
bgcolor="{{ bgColor }}"
106106
radius="{{ radius }}"
107107
semi="isSemi"
@@ -110,6 +110,13 @@ <h2>Sample progressbar</h2>
110110
clockwise="clockwise"
111111
iterations="{{ iterations }}"
112112
animation="{{ currentAnimation }}">
113+
114+
<svg>
115+
<linearGradient id="gradient" x1="0" x2="0" y1="0" y2="1">
116+
<stop offset="5%" stop-color="green"/>
117+
<stop offset="95%" stop-color="gold"/>
118+
</linearGradient>
119+
</svg>
113120
</div>
114121
</div>
115122

@@ -137,6 +144,11 @@ <h3>Customize!</h3>
137144
<input id="clockwise" type="checkbox" ng-model="clockwise"/>
138145
</div>
139146

147+
<div class="cf">
148+
<label for="gradient">Gradient:</label>
149+
<input id="gradient" type="checkbox" ng-model="gradient"/>
150+
</div>
151+
140152
<div class="cf">
141153
<label for="current">Current:</label>
142154
<input id="current" type="number" ng-model="current"/>
@@ -187,7 +199,7 @@ <h2>Upload progress example</h2>
187199
round-progress
188200
max="100"
189201
current="uploadCurrent"
190-
color="{{ currentColor }}"
202+
color="{{ getColor() }}"
191203
bgcolor="{{ bgColor }}"
192204
radius="{{ radius }}"
193205
semi="isSemi"
@@ -266,6 +278,10 @@ <h2>Upload progress example</h2>
266278
$scope.getFontSize = function(){
267279
return $scope.radius/($scope.isSemi ? 3.5 : 3) + 'px';
268280
};
281+
282+
$scope.getColor = function(){
283+
return $scope.gradient ? 'url(#gradient)' : $scope.currentColor;
284+
};
269285
}]);
270286
</script>
271287
</body>

build/roundProgress.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,13 +270,14 @@ angular.module('angular-svg-round-progress')
270270

271271
var base = {
272272
restrict: "EA",
273-
replace: true
273+
replace: true,
274+
transclude: true
274275
};
275276

276277
if(!service.isSupported){
277278
return angular.extend(base, {
278279
// placeholder element to keep the structure
279-
template: '<div class="round-progress"></div>'
280+
template: '<div class="round-progress" ng-transclude></div>'
280281
});
281282
}
282283

@@ -402,6 +403,7 @@ angular.module('angular-svg-round-progress')
402403
'<svg class="round-progress" xmlns="http://www.w3.org/2000/svg">',
403404
'<circle fill="none"/>',
404405
'<path fill="none"/>',
406+
'<g ng-transclude></g>',
405407
'</svg>'
406408
].join('\n')
407409
});

build/roundProgress.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-svg-round-progressbar",
3-
"version": "0.2.7",
3+
"version": "0.2.8",
44
"description": "AngularJS module that uses SVG to create a circular progressar",
55
"main": "roundProgress.js",
66
"scripts": {},

src/roundProgress.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@ angular.module('angular-svg-round-progress')
55

66
var base = {
77
restrict: "EA",
8-
replace: true
8+
replace: true,
9+
transclude: true
910
};
1011

1112
if(!service.isSupported){
1213
return angular.extend(base, {
1314
// placeholder element to keep the structure
14-
template: '<div class="round-progress"></div>'
15+
template: '<div class="round-progress" ng-transclude></div>'
1516
});
1617
}
1718

@@ -137,6 +138,7 @@ angular.module('angular-svg-round-progress')
137138
'<svg class="round-progress" xmlns="http://www.w3.org/2000/svg">',
138139
'<circle fill="none"/>',
139140
'<path fill="none"/>',
141+
'<g ng-transclude></g>',
140142
'</svg>'
141143
].join('\n')
142144
});

0 commit comments

Comments
 (0)