File tree Expand file tree Collapse file tree 4 files changed +39
-0
lines changed
javascripts/discourse/initializers Expand file tree Collapse file tree 4 files changed +39
-0
lines changed Original file line number Diff line number Diff line change 11import { dasherize } from " @ember/string" ;
22import concatClass from " discourse/helpers/concat-class" ;
33import { withPluginApi } from " discourse/lib/plugin-api" ;
4+ import { escapeExpression } from " discourse/lib/utilities" ;
45import icon from " discourse-common/helpers/d-icon" ;
56import isValidUrl from " ../lib/isValidUrl" ;
67
@@ -40,6 +41,11 @@ export default {
4041 const isLastLink =
4142 index === links .length - 1 ? " last-custom-icon" : " " ;
4243
44+ let style = " " ;
45+ if (link .width ) {
46+ style = ` width: ${ escapeExpression (link .width )} px` ;
47+ }
48+
4349 const iconComponent = <template >
4450 <li
4551 class ={{concatClass
@@ -55,6 +61,7 @@ export default {
5561 title ={{link.title }}
5662 target ={{target }}
5763 rel ={{rel }}
64+ style ={{style }}
5865 >
5966 {{iconTemplate }}
6067 </a >
Original file line number Diff line number Diff line change 1414 url :
1515 label : URL
1616 description : The URL for the link
17+ width :
18+ label : Width
19+ description : Allows to set the width of the icon
1720 view :
1821 label : View
1922 description : |
Original file line number Diff line number Diff line change @@ -50,6 +50,9 @@ header_links:
5050 - vdm
5151 - vdo
5252 - vmo
53+ width :
54+ type : integer
55+ required : false
5356 target :
5457 type : enum
5558 choices :
Original file line number Diff line number Diff line change 2525 end
2626 end
2727
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+
2854 context "when in mobile" , mobile : true do
2955 it "renders the correct icon" do
3056 visit ( "/" )
You can’t perform that action at this time.
0 commit comments