View raw

1 Class { 2 #name : 'MFTNavbarComponent', 3 #superclass : 'WAComponent', 4 #instVars : [ 5 'mainNavLinks' 6 ], 7 #category : 'MyFitnessTracker-Web-Components', 8 #package : 'MyFitnessTracker-Web', 9 #tag : 'Components' 10 } 11 12 { #category : 'instance creation' } 13 MFTNavbarComponent class >> newFrom: anOrderedDictionary [ 14 15 ^ self new 16 mainNavLinks: anOrderedDictionary; 17 yourself 18 ] 19 20 { #category : 'initialization' } 21 MFTNavbarComponent >> initialize [ 22 23 super initialize. 24 mainNavLinks := OrderedDictionary new 25 ] 26 27 { #category : 'initialization' } 28 MFTNavbarComponent >> mainNavLinks: anOrderedDictionary [ 29 30 mainNavLinks := anOrderedDictionary 31 ] 32 33 { #category : 'rendering' } 34 MFTNavbarComponent >> renderContentOn: html [ 35 36 html navigation: [ 37 html 38 unorderedList: [ 39 mainNavLinks keysAndValuesDo: [ :titleKey :callback | 40 html listItem: [ 41 html anchor 42 callback: callback; 43 with: titleKey capitalized ] ] ]; 44 unorderedList: [ 45 html listItem: [ 46 html anchor 47 callback: [ mainNavLinks at: #logout ]; 48 with: 'Logout' ] ] ] 49 ] 50