Skip to content

Instantly share code, notes, and snippets.

@pburtchaell
Last active January 17, 2020 17:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pburtchaell/92439b69aa40329e7d89493aa73a5de0 to your computer and use it in GitHub Desktop.
Save pburtchaell/92439b69aa40329e7d89493aa73a5de0 to your computer and use it in GitHub Desktop.
/**
* @public
* Returns all design components
* */
export default function useCanvas() {
let components = null
let canvas = null
try {
// @ts-ignore
canvas = require("./canvas.tsx")
components = canvas
.filter(key => key.endsWith("__"))
.map(key => ({
key,
displayName: key.replace(/_/g, " "),
}))
} catch (error) {
throw new Error("canvas.tsx can not be found")
}
return {
components,
canvas,
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment