File tree 4 files changed +39
-0
lines changed
javascripts/discourse/initializers
4 files changed +39
-0
lines changed Original file line number Diff line number Diff line change 1
1
import { dasherize } from " @ember/string" ;
2
2
import concatClass from " discourse/helpers/concat-class" ;
3
3
import { withPluginApi } from " discourse/lib/plugin-api" ;
4
+ import { escapeExpression } from " discourse/lib/utilities" ;
4
5
import icon from " discourse-common/helpers/d-icon" ;
5
6
import isValidUrl from " ../lib/isValidUrl" ;
6
7
@@ -40,6 +41,11 @@ export default {
40
41
const isLastLink =
41
42
index === links .length - 1 ? " last-custom-icon" : " " ;
42
43
44
+ let style = " " ;
45
+ if (link .width ) {
46
+ style = ` width: ${ escapeExpression (link .width )} px` ;
47
+ }
48
+
43
49
const iconComponent = <template >
44
50
<li
45
51
class ={{concatClass
@@ -55,6 +61,7 @@ export default {
55
61
title ={{link.title }}
56
62
target ={{target }}
57
63
rel ={{rel }}
64
+ style ={{style }}
58
65
>
59
66
{{iconTemplate }}
60
67
</a >
Original file line number Diff line number Diff line change 14
14
url :
15
15
label : URL
16
16
description : The URL for the link
17
+ width :
18
+ label : Width
19
+ description : Allows to set the width of the icon
17
20
view :
18
21
label : View
19
22
description : |
Original file line number Diff line number Diff line change @@ -50,6 +50,9 @@ header_links:
50
50
- vdm
51
51
- vdo
52
52
- vmo
53
+ width :
54
+ type : integer
55
+ required : false
53
56
target :
54
57
type : enum
55
58
choices :
Original file line number Diff line number Diff line change 25
25
end
26
26
end
27
27
28
+ context "when using the width attribute" do
29
+ before do
30
+ component . update_setting (
31
+ :header_links ,
32
+ [
33
+ {
34
+ icon : "fab-facebook" ,
35
+ url : "https://facebook.com" ,
36
+ title : "Desktop and mobile link" ,
37
+ width : 200 ,
38
+ view : "vdm" ,
39
+ } ,
40
+ ] ,
41
+ )
42
+ component . save!
43
+ end
44
+
45
+ it "renders the icon with the correct width" do
46
+ visit ( "/" )
47
+
48
+ expect ( page . find ( ".custom-header-icon-link .icon" ) . style ( "width" ) ) . to eq (
49
+ { "width" => "200px" } ,
50
+ )
51
+ end
52
+ end
53
+
28
54
context "when in mobile" , mobile : true do
29
55
it "renders the correct icon" do
30
56
visit ( "/" )
You can’t perform that action at this time.
0 commit comments