Committed by
Gerrit Code Review
GUI -- Icon service work:
- Changed color of check and xmark icons for dark and light themes. - Only appends glyphs that don't have a "-" as the name. - Wrote unit tests for new icons. Change-Id: Ia21fa33673e3adcfd8717f899d226b0d24dfcc51
Showing
5 changed files
with
64 additions
and
6 deletions
... | @@ -61,10 +61,12 @@ | ... | @@ -61,10 +61,12 @@ |
61 | return { | 61 | return { |
62 | restrict: 'A', | 62 | restrict: 'A', |
63 | scope: { | 63 | scope: { |
64 | - iconId: '@' | 64 | + iconId: '@', |
65 | + iconSize: '@' | ||
65 | }, | 66 | }, |
66 | link: function (scope, element, attrs) { | 67 | link: function (scope, element, attrs) { |
67 | - is.loadEmbeddedIcon(d3.select(element[0]), scope.iconId); | 68 | + is.loadEmbeddedIcon(d3.select(element[0]), |
69 | + scope.iconId, scope.iconSize); | ||
68 | } | 70 | } |
69 | }; | 71 | }; |
70 | 72 | ... | ... |
... | @@ -28,15 +28,45 @@ svg.embeddedIcon .icon .glyph { | ... | @@ -28,15 +28,45 @@ svg.embeddedIcon .icon .glyph { |
28 | fill-rule: evenodd; | 28 | fill-rule: evenodd; |
29 | } | 29 | } |
30 | 30 | ||
31 | -svg.embeddedIcon .icon.deviceOnline { | 31 | +div.inline-icon { |
32 | + display: inline-block; | ||
33 | +} | ||
34 | + | ||
35 | +.light svg.embeddedIcon .icon.deviceOnline { | ||
32 | fill: green; | 36 | fill: green; |
33 | } | 37 | } |
38 | +.light svg.embeddedIcon .icon.deviceOffline { | ||
39 | + fill: darkred; | ||
40 | +} | ||
34 | 41 | ||
35 | -svg.embeddedIcon .icon.deviceOffline { | 42 | +.dark svg.embeddedIcon .icon.deviceOnline, |
43 | +.dark svg.embeddedIcon .icon.deviceOffline { | ||
44 | + fill: #ccc; | ||
45 | +} | ||
46 | +.dark svg.embeddedIcon .icon.deviceOnline .glyph { | ||
47 | + fill: green; | ||
48 | +} | ||
49 | +.dark svg.embeddedIcon .icon.deviceOffline .glyph { | ||
36 | fill: darkred; | 50 | fill: darkred; |
37 | } | 51 | } |
38 | 52 | ||
53 | +.light svg.embeddedIcon .icon.tableColSortAsc .glyph, | ||
54 | +.light svg.embeddedIcon .icon.tableColSortDesc .glyph { | ||
55 | + fill: black; | ||
56 | +} | ||
57 | +.dark svg.embeddedIcon .icon.tableColSortAsc .glyph, | ||
58 | +.dark svg.embeddedIcon .icon.tableColSortDesc .glyph { | ||
59 | + fill: #ccc; | ||
60 | +} | ||
61 | + | ||
62 | +svg.embeddedIcon .icon.tableColSortAsc rect { | ||
63 | + stroke: none; | ||
64 | + fill: none; | ||
65 | +} | ||
39 | svg.embeddedIcon .icon rect { | 66 | svg.embeddedIcon .icon rect { |
40 | stroke: black; | 67 | stroke: black; |
41 | stroke-width: 1px; | 68 | stroke-width: 1px; |
42 | } | 69 | } |
70 | +.dark svg.embeddedIcon .icon rect { | ||
71 | + stroke: #ccc; | ||
72 | +} | ... | ... |
... | @@ -89,6 +89,7 @@ | ... | @@ -89,6 +89,7 @@ |
89 | rx: cornerSize | 89 | rx: cornerSize |
90 | }); | 90 | }); |
91 | 91 | ||
92 | + if (gid !== '-') { | ||
92 | g.append('use').attr({ | 93 | g.append('use').attr({ |
93 | width: vboxSize, | 94 | width: vboxSize, |
94 | height: vboxSize, | 95 | height: vboxSize, |
... | @@ -96,6 +97,7 @@ | ... | @@ -96,6 +97,7 @@ |
96 | 'xlink:href': '#' + gid | 97 | 'xlink:href': '#' + gid |
97 | }); | 98 | }); |
98 | } | 99 | } |
100 | + } | ||
99 | 101 | ||
100 | function loadEmbeddedIcon(div, iconCls, size) { | 102 | function loadEmbeddedIcon(div, iconCls, size) { |
101 | loadIcon(div, iconCls, size, true); | 103 | loadIcon(div, iconCls, size, true); | ... | ... |
... | @@ -7,7 +7,12 @@ | ... | @@ -7,7 +7,12 @@ |
7 | <thead> | 7 | <thead> |
8 | <tr> | 8 | <tr> |
9 | <th></th> | 9 | <th></th> |
10 | - <th>URI</th> | 10 | + <th>URI |
11 | + <div class="inline-icon" | ||
12 | + icon icon-id="tableColSortAsc" | ||
13 | + icon-size="10"> | ||
14 | + </div> | ||
15 | + </th> | ||
11 | <th>Vendor</th> | 16 | <th>Vendor</th> |
12 | <th>Hardware Version</th> | 17 | <th>Hardware Version</th> |
13 | <th>Software Version</th> | 18 | <th>Software Version</th> | ... | ... |
... | @@ -65,12 +65,13 @@ describe('factory: fw/svg/icon.js', function() { | ... | @@ -65,12 +65,13 @@ describe('factory: fw/svg/icon.js', function() { |
65 | checkElemSize(rect, gsz); | 65 | checkElemSize(rect, gsz); |
66 | expect(rect.attr('rx')).toEqual('5'); | 66 | expect(rect.attr('rx')).toEqual('5'); |
67 | 67 | ||
68 | + if (useHref) { | ||
68 | var use = g.select('use'); | 69 | var use = g.select('use'); |
69 | expect(use.classed('glyph')).toBeTruthy(); | 70 | expect(use.classed('glyph')).toBeTruthy(); |
70 | expect(use.attr('xlink:href')).toEqual(useHref); | 71 | expect(use.attr('xlink:href')).toEqual(useHref); |
71 | checkElemSize(use, gsz); | 72 | checkElemSize(use, gsz); |
72 | } | 73 | } |
73 | - | 74 | + } |
74 | 75 | ||
75 | it('should load an icon into a div', function () { | 76 | it('should load an icon into a div', function () { |
76 | expect(d3Elem.html()).toEqual(''); | 77 | expect(d3Elem.html()).toEqual(''); |
... | @@ -84,4 +85,22 @@ describe('factory: fw/svg/icon.js', function() { | ... | @@ -84,4 +85,22 @@ describe('factory: fw/svg/icon.js', function() { |
84 | verifyIconStructure('deviceOffline', '#xMark', '32'); | 85 | verifyIconStructure('deviceOffline', '#xMark', '32'); |
85 | }); | 86 | }); |
86 | 87 | ||
88 | + it('should verify triangleUp icon', function () { | ||
89 | + expect(d3Elem.html()).toEqual(''); | ||
90 | + is.loadIcon(d3Elem, 'tableColSortAsc', 10); | ||
91 | + verifyIconStructure('tableColSortAsc', '#triangleUp', '10'); | ||
92 | + }); | ||
93 | + | ||
94 | + it('should verify triangleDown icon', function () { | ||
95 | + expect(d3Elem.html()).toEqual(''); | ||
96 | + is.loadIcon(d3Elem, 'tableColSortDesc', 10); | ||
97 | + verifyIconStructure('tableColSortDesc', '#triangleDown', '10'); | ||
98 | + }); | ||
99 | + | ||
100 | + it('should verify no icon is displayed', function () { | ||
101 | + expect(d3Elem.html()).toEqual(''); | ||
102 | + is.loadIcon(d3Elem, 'tableColSortNone', 10); | ||
103 | + verifyIconStructure('tableColSortNone', null, '10'); | ||
104 | + }); | ||
105 | + | ||
87 | }); | 106 | }); | ... | ... |
-
Please register or login to post a comment