Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

		th Name
		th Pieces Needed
		th Sets That You Can Use
              @import url('https://fonts.googleapis.com/css?family=Roboto');

body {
	font-family: 'Roboto', sans-serif;
	background: black;
	color: white;
	font-size: 14px;

table {
	border-collapse: collapse;

tr {
	&:not(:last-child) {
		border-bottom: 1px solid hsla(0, 0%, 100%, 0.2);

td, th {
	vertical-align: top;
	padding: 4px;
	&:not(:last-child) {
		border-right: 1px solid hsla(0, 0%, 100%, 0.2);
	div {
		padding: 3px 4px;
		&:hover {
			background-color: hsla(0, 0%, 100%, 0.05);
		&:not(:last-child) {
			border-bottom: 1px solid hsla(0, 0%, 100%, 0.075);
              let data;

function preload() {
	data = loadJSON('https://alca.tv/static/codepen/pens/GvZdJY/magformers.js');

function makeName(key, count) {
	let name = key.split('_')
		.reduce((p, n) => `${p} ${n[0].toUpperCase() + n.slice(1)}`, '');
	if(count > 1) {
		name += (name[name.length - 1] === 's' ? 'e' : '') + 's';
	return name;

function setup() {
	// Select the implicit tbody inside of the table
	let table = select('tbody');
	// Loop over the models
	data.models.forEach(model => {
		// Set up our elements
		let tr = createElement('tr').parent(table);
		let tdName = createElement('td', model.name).parent(tr);
		let tdPieces = createElement('td').parent(tr);
		let tdSets = createElement('td').parent(tr);
		// Loop over the model's key
		Object.keys(model).forEach(key => {
			// Avoid the 'name' key, this causes trouble
			if(key === 'name') {
			// Get the count for this key
			let count = model[key];
			// Check the the key is not 0
			if(!count) {
			// Make a readable version of the key
			let piece = makeName(key, count);
			// Add the data to the second column
			createDiv(`${piece}: ${count}`).parent(tdPieces);
		// Loop over the sets for each model
		data.sets.forEach(set => {
			// Check if the set can be used to create the model, automatically
			// return true if the key is 'name'
			let canUse = Object.keys(set)
					.every(key => key === 'name' || model[key] <= set[key]);
			if(canUse) {
				// Add the set to the third column
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.