1.0.1 • Published 4 years ago

codepen-link v1.0.1

Weekly downloads
3
License
MIT
Repository
github
Last release
4 years ago

Built With Stencil

codepen-link

Codepen is an awesome tool to showcase a piece of front-end code. Did you know there is a way to dynamically create a pen with pre-filled code?

Codepen has an amazing API to allow developers do this, however the way to do it is via submitting a form. The codepen-link component simplifies this set up.

Usage

<codepen-link
  html="<h1>Hello world</h1>"
  title="Open in CodePen"
  pen-title="New demo pen"
  editors="110"
  css-preprocessor="scss"
  css="body{ font-family: 'Open Sans', sans-serif; }"
  css-external="//fonts.googleapis.com/css?family=Open+Sans:300,400,600,700"
  js-external="https://cdn.jsdelivr.net/npm/codepen-link/dist/codepen-link/codepen-link.js"
>
  <button type="button">Click me view in Codepen</button>
</codepen-link>

Installation

CDN

<script type="module" src="https://cdn.jsdelivr.net/npm/codepen-link/dist/codepen-link/codepen-link.esm.js"></script>
<script nomodule src="https://cdn.jsdelivr.net/npm/codepen-link/dist/codepen-link/codepen-link.js"></script>

add the script tags in your html and the component will get lazy loaded when it's used on the page.

Framework integration

Please see framework integration in the Stencil documentation.

Node Modules

  • Run npm install codepen-link --save
  • Put a script tag similar to this <script src='node_modules/codepen-link/dist/codepen-link.js'></script> in the head of your index.html
  • Then you can use the element anywhere in your template, JSX, html etc

In a stencil-starter app

  • Run npm install codepen-link --save
  • Add an import to the npm packages import 'codepen-link';
  • Then you can use the element anywhere in your template, JSX, html etc

Properties

PropertyAttributeDescriptionTypeDefault
csscssCSS codestring''
cssExternalcss-externalsemi-colon separate multiple filesstring''
cssPreProcessorcss-pre-processorCSS preprocessor"less" \| "none" \| "sass" \| "scss" \| "stylus"'none'
cssPrefixcss-prefixCSS prefix"autoprefixer" \| "neither" \| "prefixfree"'neither'
cssStartercss-starterCSS reset or normalisation"neither" \| "normalize" \| "reset"'neither'
descriptiondescriptionDescription of new penstring''
editorseditorsSet which editors are open. In this example HTML open, CSS closed, JS openstring'111'
headheadCode that should go inside string''
htmlhtmlHTML codestring'<p>Generated by &lt;codepen-link&gt;</p>'
htmlClasseshtml-classesHTML classesstring''
htmlPreProcessorhtml-pre-processorHTML preprocessor"haml" \| "markdown" \| "none" \| "slim"'none'
isPrivateis-privateWhen the Pen is saved, it will save as Private if logged in user has that privledge, otherwise it will save as publicbooleanfalse
jsjsJavaScript codestring''
jsExternaljs-externalsemi-colon separate multiple filesstring''
jsPreProcessorjs-pre-processorJavaScript preprocessor"babel" \| "coffeescript" \| "livescript" \| "none" \| "typescript"'none'
layoutlayoutLayout of the new pen"left" \| "right" \| "top"'top'
parentparentIf supplied, the Pen will save as a fork of this id. Note it's not the slug, but ID. You can find the ID of a Pen with window.CP.pen.id in the browser console.string''
penTitlepen-titleTitle of new penstring'New Pen'
tags--an array of stringsstring[][]

1.0.1

4 years ago

1.0.0

4 years ago

0.0.2

4 years ago