@@ -22,6 +22,8 @@ export const App = () => {
2222
2323 const [ activeHex , setActiveHex ] = useState ( null ) ;
2424
25+ const [ activeHexInfo , setActiveHexInfo ] = useState ( null ) ;
26+
2527 const [ roll , setRoll ] = useState ( null ) ;
2628
2729 const [ showAnnotations , setShowAnnotations ] = useState ( true ) ;
@@ -59,6 +61,8 @@ export const App = () => {
5961 useEffect ( ( ) => {
6062 if ( currentEngine ) {
6163 setCurrentEngine ( { ...currentEngine , active : activeHex } ) ;
64+
65+ setActiveHexInfo ( currentEngine . nodes . find ( ( { id } ) => id === activeHex ) ) ;
6266 }
6367 } , [ activeHex ] ) ;
6468
@@ -107,11 +111,48 @@ export const App = () => {
107111 }
108112 } , [ roll ] ) ;
109113
114+ const renderStatus = ( ) => {
115+ if ( activeHexInfo ?. label ) {
116+ return (
117+ < h2 className = { styles . status } >
118+ < span class = "visually-hidden" > Status:</ span >
119+ { activeHexInfo . label }
120+ </ h2 >
121+ ) ;
122+ }
123+
124+ return < > </ > ;
125+ } ;
126+
127+ const renderModifiers = ( ) => {
128+ const renderModifier = ( [ stat , modifier ] ) => (
129+ < li key = { `modifier-for-${ stat } ` } >
130+ < strong > { stat } </ strong > : { modifier }
131+ </ li >
132+ ) ;
133+
134+ if ( activeHexInfo ?. modifiers ) {
135+ return (
136+ < div className = { styles . modifiers } >
137+ < h3 className = "visually-hidden" > Modifiers:</ h3 >
138+ < ul className = { styles . modifierList } >
139+ { Object . entries ( activeHexInfo . modifiers ) . map ( renderModifier ) }
140+ </ ul >
141+ </ div >
142+ ) ;
143+ }
144+
145+ return < > </ > ;
146+ } ;
147+
110148 return (
111149 < >
112150 { roll ? (
113151 < section className = { styles . roll } >
114- < p > { roll . total } </ p >
152+ < p >
153+ < span className = "visually-hidden" > You rolled:</ span >
154+ { roll . total }
155+ </ p >
115156 </ section >
116157 ) : (
117158 < > </ >
@@ -128,6 +169,9 @@ export const App = () => {
128169 ) : (
129170 < > </ >
130171 ) }
172+ < p className = "visually-hidden" > Active Hex: { activeHex } </ p >
173+ { renderStatus ( ) }
174+ { renderModifiers ( ) }
131175 </ section >
132176 < footer className = { styles . footer } >
133177 { currentEngine ?. id ? (
0 commit comments