Skip to content

Commit 8450a03

Browse files
committed
Fix missing icons
GitHub no longer uses an icon font, so embed the SVG directly (programmatically generated each time, probably not a great idea).
1 parent fed18fa commit 8450a03

File tree

3 files changed

+23
-7
lines changed

3 files changed

+23
-7
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
## next
22

3+
* Embed SVG icon directly as GitHub no longer uses an icon font.
4+
35
## [0.3.0][0.3.0] - 2015-09-02
46

57
* Now available for Firefox!

gitique.css

+10-5
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,28 @@
1717
}
1818

1919
.gitique-icon {
20-
color: #bdbdbd;
20+
fill: #bdbdbd;
21+
}
22+
23+
.gitique-icon svg {
24+
display: inline-block;
25+
vertical-align: bottom;
2126
}
2227

2328
.gitique-icon.gitique-reviewed {
24-
color: #999;
29+
fill: #999;
2530
}
2631

2732
.gitique-icon.gitique-basis {
28-
color: #000;
33+
fill: #000;
2934
}
3035

3136
.gitique-icon.gitique-new {
32-
color: #6cc644;
37+
fill: #6cc644;
3338
}
3439

3540
.gitique-icon.gitique-head {
36-
color: #48a220;
41+
fill: #48a220;
3742
}
3843

3944
.gitique-icon:not(.gitique-initial):not(.gitique-head) {

src/gitique/core.cljs

+11-2
Original file line numberDiff line numberDiff line change
@@ -174,12 +174,21 @@
174174
(util/add-class element "gitique-hidden"))))))
175175

176176
(defn- select-commit [event]
177-
(swap! state assoc :base-commit (commit-sha (.-parentElement (.-target event)))))
177+
(swap! state assoc :base-commit (commit-sha (.-parentElement (.-currentTarget event)))))
178178

179179
(defn- add-icon! [element override-class]
180180
(let [parent (.-parentElement (.-parentElement element))]
181181
(when-not (util/qs ".gitique-icon" parent)
182-
(let [icon (dom/createDom "span" #js["octicon octicon-diff-added gitique-icon"])]
182+
;; This is kind of a hack, but it works fine for now. If this extension used more
183+
;; than one icon then it would be better to include them as actual files.
184+
(let [svg-ns "http://www.w3.org/2000/svg"
185+
svg (js/document.createElementNS svg-ns "svg")
186+
path (js/document.createElementNS svg-ns "path")
187+
icon (dom/createDom "span" #js["gitique-icon"] svg)]
188+
(.setAttributeNS svg nil "width" "14")
189+
(.setAttributeNS svg nil "height" "16")
190+
(.setAttributeNS path nil "d" "M13 1H1C0.45 1 0 1.45 0 2v12c0 0.55 0.45 1 1 1h12c0.55 0 1-0.45 1-1V2c0-0.55-0.45-1-1-1z m0 13H1V2h12v12zM6 9H3V7h3V4h2v3h3v2H8v3H6V9z")
191+
(.appendChild svg path)
183192
(if override-class
184193
(util/add-class icon override-class)
185194
(.addEventListener icon "click" select-commit))

0 commit comments

Comments
 (0)