@@ -44,72 +44,76 @@ export const ExternalResources: FunctionComponent = () => {
4444 return (
4545 < Collapsible title = "External resources" >
4646 < Stack direction = "vertical" gap = { 6 } >
47- < List >
48- { otherResources . map ( resource => (
49- < ListAction
50- key = { resource }
51- justify = "space-between"
52- css = { {
53- button : { opacity : 0 } ,
54- ':hover, :focus-within' : { button : { opacity : 1 } } ,
55- } }
56- >
57- < Link href = { resource } target = "_blank" >
58- { getName ( resource ) }
59- </ Link >
60- < Button
61- variant = "link"
62- css = { css ( { width : 'auto' } ) }
63- onClick = { ( ) => externalResourceRemoved ( resource ) }
47+ { otherResources . length || fonts . length ? (
48+ < List >
49+ { otherResources . map ( resource => (
50+ < ListAction
51+ key = { resource }
52+ justify = "space-between"
53+ css = { {
54+ button : { opacity : 0 } ,
55+ ':hover, :focus-within' : { button : { opacity : 1 } } ,
56+ } }
6457 >
65- < CrossIcon / >
66- </ Button >
67- </ ListAction >
68- ) ) }
69-
70- { fonts . map ( resource => (
71- < ListAction
72- key = { resource }
73- justify = "space-between"
74- css = { {
75- button : { opacity : 0 } ,
76- ':hover, :focus-within' : { button : { opacity : 1 } } ,
77- } }
78- >
79- < Link href = { resource } target = "_blank" >
80- { getFontFamily ( resource ) . name }
81- </ Link >
82- < Button
83- variant = "link"
84- css = { css ( { width : 'auto' } ) }
85- onClick = { ( ) => externalResourceRemoved ( resource ) }
58+ < Link href = { resource } target = "_blank" >
59+ { getName ( resource ) }
60+ </ Link >
61+ < Button
62+ variant = "link"
63+ css = { css ( { width : 'auto' } ) }
64+ onClick = { ( ) => externalResourceRemoved ( resource ) }
65+ >
66+ < CrossIcon />
67+ </ Button >
68+ </ ListAction >
69+ ) ) }
70+
71+ { fonts . map ( resource => (
72+ < ListAction
73+ key = { resource }
74+ justify = "space-between"
75+ css = { {
76+ button : { opacity : 0 } ,
77+ ':hover, :focus-within' : { button : { opacity : 1 } } ,
78+ } }
8679 >
87- < CrossIcon />
88- </ Button >
89- </ ListAction >
90- ) ) }
91- </ List >
80+ < Link href = { resource } target = "_blank" >
81+ { getFontFamily ( resource ) . name }
82+ </ Link >
83+ < Button
84+ variant = "link"
85+ css = { css ( { width : 'auto' } ) }
86+ onClick = { ( ) => externalResourceRemoved ( resource ) }
87+ >
88+ < CrossIcon />
89+ </ Button >
90+ </ ListAction >
91+ ) ) }
92+ </ List >
93+ ) : null }
9294
9395 < form
94- key = { otherResources . length }
9596 onSubmit = { event => {
9697 event . preventDefault ( ) ;
9798 const url = event . target [ 0 ] . value . trim ( ) ;
9899 externalResourceAdded ( url ) ;
99100 } }
100101 >
101102 < FormField label = "External URL" direction = "vertical" >
102- < Input type = "text" placeholder = "https://cdn.com/bootstrap.css" />
103+ < Input
104+ type = "text"
105+ placeholder = "https://cdn.com/bootstrap.css"
106+ key = { otherResources . length }
107+ />
103108 </ FormField >
104109 < SidebarRow marginX = { 2 } >
105- < Button variant = "secondary" type = "submit ">
110+ < Button type = "submit" variant = "secondary ">
106111 Add resource
107112 </ Button >
108113 </ SidebarRow >
109114 </ form >
110115
111116 < form
112- key = { fonts . length }
113117 onSubmit = { event => {
114118 event . preventDefault ( ) ;
115119 const fontName = event . target [ 0 ] . value . trim ( ) . replace ( / / g, '+' ) ;
@@ -118,14 +122,16 @@ export const ExternalResources: FunctionComponent = () => {
118122 } }
119123 >
120124 < FormField label = "Google Fonts" direction = "vertical" >
121- < Select placeholder = "Select a font family" >
125+ < Select placeholder = "Select a font family" key = { fonts . length } >
122126 { listOfFonts . sort ( ) . map ( name => (
123127 < option key = { name } > { name } </ option >
124128 ) ) }
125129 </ Select >
126130 </ FormField >
127131 < SidebarRow marginX = { 2 } >
128- < Button variant = "secondary" > Add font</ Button >
132+ < Button type = "submit" variant = "secondary" >
133+ Add font
134+ </ Button >
129135 </ SidebarRow >
130136 </ form >
131137 </ Stack >
0 commit comments