Created
August 8, 2018 04:36
-
-
Save colingourlay/f5f5c0bb1ddbc00dca4b1fa8c9961bb9 to your computer and use it in GitHub Desktop.
Playing with JSDoc-based TypeScript definitions in a preact component
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { h } = require('preact'); | |
const Button = require('../Button'); | |
const styles = require('./styles.css'); | |
/** | |
* CreditsNav | |
* | |
* @typedef Props | |
* @property {string} creditsHTML | |
* @property {boolean} isUnavailable | |
* @property {function(any): void} navigate | |
* | |
* @param {Props} props | |
* @return {object} | |
*/ | |
const CreditsNav = ({ creditsHTML, isUnavailable, navigate }) => ( | |
<nav className={styles.root} aria-hidden={isUnavailable ? 'true' : 'false'}> | |
<Button transparent tabindex={isUnavailable ? -1 : 0} onClick={() => navigate(creditsHTML)}> | |
Credits | |
</Button> | |
</nav> | |
); | |
// Trying it out... | |
CreditsNav({ creditsHTML: 'd', isUnavailable: false, navigate: () => {} }); | |
module.exports = CreditsNav; | |
module.exports.displayName = 'CreditsNav'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment