@@ -40,6 +40,10 @@ export function cameraCaptureControl (
4040 const div = dom . createElement ( 'div' )
4141 let destination , imageBlob , player , canvas
4242
43+ const setButtonVisible = ( button : HTMLElement , visible : boolean ) => {
44+ button . style . display = visible ? 'inline-flex' : 'none'
45+ }
46+
4347 const table = div . appendChild ( dom . createElement ( 'table' ) )
4448 const mainTR = table . appendChild ( dom . createElement ( 'tr' ) )
4549 const main = mainTR . appendChild ( dom . createElement ( 'td' ) )
@@ -61,23 +65,26 @@ export function cameraCaptureControl (
6165 retakeButton . addEventListener ( 'click' , _event => {
6266 retake ( )
6367 } )
64- retakeButton . style . visibility = 'collapse' // Hide for now
68+ retakeButton . textContent = 'Retake'
69+ setButtonVisible ( retakeButton , false )
6570
6671 const shutterButton = buttons
6772 . appendChild ( dom . createElement ( 'td' ) ) // Trigger capture button
6873 . appendChild (
6974 widgets . button ( dom , icons . iconBase + 'noun_10636.svg' , 'Snap' )
7075 )
7176 shutterButton . addEventListener ( 'click' , grabCanvas )
72- shutterButton . style . visibility = 'collapse' // Hide for now
77+ shutterButton . textContent = 'Take Photo'
78+ setButtonVisible ( shutterButton , false )
7379
7480 const sendButton = buttons
7581 . appendChild ( dom . createElement ( 'td' ) ) // Confirm and save button
7682 . appendChild ( widgets . continueButton ( dom ) ) // @@ or send icon??
7783 sendButton . addEventListener ( 'click' , _event => {
7884 saveBlob ( imageBlob , destination )
7985 } )
80- sendButton . style . visibility = 'collapse' // Hide for now
86+ sendButton . textContent = 'Use Photo'
87+ setButtonVisible ( sendButton , false )
8188
8289 function displayPlayer ( ) {
8390 player = main . appendChild ( dom . createElement ( 'video' ) )
@@ -89,9 +96,12 @@ export function cameraCaptureControl (
8996 }
9097 navigator . mediaDevices . getUserMedia ( constraints ) . then ( stream => {
9198 player . srcObject = stream
92- shutterButton . style . visibility = 'visible' // Enable
93- sendButton . style . visibility = 'collapse'
94- retakeButton . style . visibility = 'collapse'
99+ setButtonVisible ( shutterButton , true )
100+ setButtonVisible ( sendButton , false )
101+ setButtonVisible ( retakeButton , false )
102+ } ) . catch ( err => {
103+ console . error ( 'Unable to start camera preview' , err )
104+ doneCallback ( null )
95105 } )
96106 }
97107
@@ -128,9 +138,9 @@ export function cameraCaptureControl (
128138 }
129139
130140 function reviewImage ( ) {
131- sendButton . style . visibility = 'visible'
132- retakeButton . style . visibility = 'visible'
133- shutterButton . style . visibility = 'collapse' // Hide for now
141+ setButtonVisible ( sendButton , true )
142+ setButtonVisible ( retakeButton , true )
143+ setButtonVisible ( shutterButton , false )
134144 }
135145
136146 function stopVideo ( ) {
0 commit comments