const html = require('choo/html'); const passwordInput = require('../passwordInput'); module.exports = function(state) { const checked = state.password ? 'checked' : ''; const label = state.password ? 'addPasswordLabel' : 'addPasswordMessage'; return html`
${passwordInput(state)}
`; function togglePasswordInput(e) { const unlockInput = document.getElementById('password-input'); const boxChecked = e.target.checked; document .querySelector('.passwordInput') .classList.toggle('passwordInput--hidden', !boxChecked); const label = document.querySelector('.checkbox__label'); if (boxChecked) { label.innerHTML = state.translate('addPasswordLabel'); unlockInput.focus(); } else { label.innerHTML = state.translate('addPasswordMessage'); unlockInput.value = ''; } } };