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
81 additions
and
23 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 | ... | ... |
... | @@ -23,20 +23,50 @@ svg#IconLibDefs { | ... | @@ -23,20 +23,50 @@ svg#IconLibDefs { |
23 | } | 23 | } |
24 | 24 | ||
25 | svg.embeddedIcon .icon .glyph { | 25 | svg.embeddedIcon .icon .glyph { |
26 | - stroke: none; | 26 | + stroke: none; |
27 | - fill: white; | 27 | + fill: white; |
28 | - fill-rule: evenodd; | 28 | + fill-rule: evenodd; |
29 | } | 29 | } |
30 | 30 | ||
31 | -svg.embeddedIcon .icon.deviceOnline { | 31 | +div.inline-icon { |
32 | - fill: green; | 32 | + display: inline-block; |
33 | } | 33 | } |
34 | 34 | ||
35 | -svg.embeddedIcon .icon.deviceOffline { | 35 | +.light svg.embeddedIcon .icon.deviceOnline { |
36 | - fill: darkred; | 36 | + fill: green; |
37 | +} | ||
38 | +.light svg.embeddedIcon .icon.deviceOffline { | ||
39 | + fill: darkred; | ||
40 | +} | ||
41 | + | ||
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 { | ||
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; |
69 | +} | ||
70 | +.dark svg.embeddedIcon .icon rect { | ||
71 | + stroke: #ccc; | ||
42 | } | 72 | } | ... | ... |
... | @@ -89,12 +89,14 @@ | ... | @@ -89,12 +89,14 @@ |
89 | rx: cornerSize | 89 | rx: cornerSize |
90 | }); | 90 | }); |
91 | 91 | ||
92 | - g.append('use').attr({ | 92 | + if (gid !== '-') { |
93 | - width: vboxSize, | 93 | + g.append('use').attr({ |
94 | - height: vboxSize, | 94 | + width: vboxSize, |
95 | - 'class': 'glyph', | 95 | + height: vboxSize, |
96 | - 'xlink:href': '#' + gid | 96 | + 'class': 'glyph', |
97 | - }); | 97 | + 'xlink:href': '#' + gid |
98 | + }); | ||
99 | + } | ||
98 | } | 100 | } |
99 | 101 | ||
100 | function loadEmbeddedIcon(div, iconCls, size) { | 102 | function loadEmbeddedIcon(div, iconCls, size) { | ... | ... |
... | @@ -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,13 +65,14 @@ describe('factory: fw/svg/icon.js', function() { | ... | @@ -65,13 +65,14 @@ 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 | - var use = g.select('use'); | 68 | + if (useHref) { |
69 | - expect(use.classed('glyph')).toBeTruthy(); | 69 | + var use = g.select('use'); |
70 | - expect(use.attr('xlink:href')).toEqual(useHref); | 70 | + expect(use.classed('glyph')).toBeTruthy(); |
71 | - checkElemSize(use, gsz); | 71 | + expect(use.attr('xlink:href')).toEqual(useHref); |
72 | + checkElemSize(use, gsz); | ||
73 | + } | ||
72 | } | 74 | } |
73 | 75 | ||
74 | - | ||
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(''); |
77 | is.loadIcon(d3Elem, 'deviceOnline'); | 78 | is.loadIcon(d3Elem, 'deviceOnline'); |
... | @@ -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