Skip to content

Instantly share code, notes, and snippets.

@colingourlay
Created August 8, 2018 04:36
Show Gist options
  • Save colingourlay/f5f5c0bb1ddbc00dca4b1fa8c9961bb9 to your computer and use it in GitHub Desktop.
Save colingourlay/f5f5c0bb1ddbc00dca4b1fa8c9961bb9 to your computer and use it in GitHub Desktop.
Playing with JSDoc-based TypeScript definitions in a preact component
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