How can we help you today?

How to Use Code from CodePen in ShortPoint Code Design Element

With the ShortPoint Code Design Element, you can easily embed codes from CodePen, an online code editor with thousands of FREE code snippets, into your SharePoint page.


This tutorial will demonstrate how to properly use code from Codepen.io (like the one below) in the ShortPoint Code Design Element.


sample code snippet from CodePen


TABLE OF CONTENTS


Prerequisites

  • You must have the latest version of ShortPoint SPFx installed on your SharePoint environment.
  • You must be a ShortPoint Designer with an active license.

Step-by-step Tutorial

Code snippets found in Codepen.io are categorized into two: codes with preprocessors and codes without preprocessors. Codes with preprocessors must be converted into HTML, CSS, or JavaScript to work properly in the Code Design Element.


So, before proceeding with the steps below, you must first check if your code snippet has a preprocessor. To do this, simply check if a parenthesis is added to any of the code languages. For example, in the snippet below you will notice (SCSS). This means that the snippet uses SCSS preprocessor for CSS:


sample code snippet with preprocessor


Alternatively, you can click the cogwheel icon beside the code language. The preprocessor, if there are any, will be indicated.


Cogwheel icon


Once you have identified if your code snippet has preprocessors or not, you can now proceed to the option that best fits your needs.


Option 1: Code Snippets With Preprocessors

Follow this option if your code snippet has preprocessors.


Step 1: Convert Code Snippet

Go to Codepen.io and find the code snippet you want to use. For this guide, we will use Turning pages with CSS:


sample code snippet with preprocessor


NOTEThe Code Design Element does not support adding external script resources. If your snippet has external resources, it will not work. To check if there are any, click the cogwheel icon and check if there are any links in the Add External Scripts/Pens fields.

external scripts


Click the [1] down arrow icon of the code language with the preprocessor and select [2] View Compiled CSS:


down arrow icon and view compiled css


 You will see a green Compiled text once the conversion is successful:


green compiled text


NOTEIf more code languages have preprocessors, repeat the steps above.

Step 2: Edit the ShortPoint Web Part

In a separate tab, open the SharePoint page you want to use and click Edit:


Edit


Click the close icon to leave the Toolbox:


close icon


Select the ShortPoint tag:


ShortPoint tag


Click the Edit Properties icon:


Edit properties icon


Step 3: Insert the Code Design Element

Click the plus icon to see the library of Design Elements:


plus icon


Use the search bar to look for Code and select it:


Code design element


NOTEFor more details about the Code Design Element and all its features, check out Introducing ShortPoint Code Design Element.

Step 4: Paste the Code

Copy the codes from Step 1 and paste them into their respective fields:


copy and paste codes


NOTEIf you wish to change anything in the code snippet, you can directly do so in the Code Design Element. And to ensure that the code snippet works properly, make sure that Sandbox mode is enabled. To do this, go to the Design tab and ensure that the toggle under Sandbox mode is blue: 

sandbox mode enabled

Step 5: Save

Once done, click the green check mark:


green check mark


Click the eye icon to see your page in real-time:


eye icon


Click Save to apply all your changes:


Save


Option 2: Code Snippets Without Preprocessors

Follow this option if your code snippet has no preprocessors.


Step 1: Find the Code Snippet You Want To Use

Go to Codepen.io and find the code snippet you want to use. For this guide, we will use Animated CSS Gradient Text:


sample code snippet without preprocesor

NOTEThe Code Design Element does not support adding external script resources. If your snippet has external resources, it will not work. To check if there are any, click the cogwheel icon and check if there are any links in the Add External Scripts/Pens fields. 

external scripts

Step 2: Edit the ShortPoint Web Part

In a separate tab, open the SharePoint page you want to use and click Edit:


Edit


Click the close icon to leave the Toolbox:


close icon


Select the ShortPoint tag:


ShortPoint tag


Click the Edit Properties icon:


Edit properties icon


Step 3: Insert the Code Design Element

Click the plus icon to see the library of Design Elements:


plus icon


Use the search bar to look for Code and select it:


Code design element


NOTEFor more details about the Code Design Element and all its features, check out Introducing ShortPoint Code Design Element.

Step 4: Paste the Code

Copy the codes from Step 1 and paste them into their respective fields:

copy and paste codes


NOTEIf you wish to change anything in the code snippet, you can directly do so in the Code Design Element. And to ensure that the code snippet works properly, make sure that Sandbox mode is enabled. To do this, go to the Design tab and ensure that the toggle under Sandbox mode is blue: 

sandbox mode enabled

Step 5: Save

Once done, click the green check mark:


green check mark


Click the eye icon to see your page in real-time:


eye icon


Click Save to apply all your changes:

Save


That’s it! You can now use the Code Design Element to insert code snippets from CodePen. Enjoy trying this hack on your SharePoint pages.


NOTEYou can also use external stylesheets (for CSS) in the ShortPoint Code Element. Simply add them at the top of the CSS area using the string below and replace link/to/external/stylesheet.css with the external style sheet link: 
@import url (link/to/external/stylesheet.css);


external stylesheets


Related articles:

Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.

World's best intranet sites are designed using ShortPoint

Get started today! Learn more
See all 74 topics

Start a trial

Ignite your vision. Install ShortPoint directly on your site, or play in sandbox mode. No credit card required.

Get started today

World’s best intranet sites are designed using ShortPoint

Thousands of companies using ShortPoint everyday to design, brand and build award winning intranet sites.

Get started Learn more