Pen Settings

HTML

CSS

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

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

Behavior

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                
              
            
!

CSS

              
                
              
            
!

JS

              
                const assets = ["list.json", "starwars.jpg"];
const path = "https://s3-us-west-2.amazonaws.com/s.cdpn.io/2104200/";

const frame = new Frame("fit", 1024, 768, black, black, assets, path);
frame.on("ready", ()=>{ // ES6 Arrow Function - similar to function(){}
	zog("ready from ZIM Frame"); // logs in console (F12 - choose console)

	// often need below - so consider it part of the template
	const stage = frame.stage;
	const stageW = frame.width;
	const stageH = frame.height;

	// REFERENCES for ZIM at https://zimjs.com
	// see https://zimjs.com/intro.html for an intro example
	// see https://zimjs.com/learn.html for video and code tutorials
	// see https://zimjs.com/docs.html for documentation

	// CODE HERE

	// Let user save an image - so prepare container to be captured
	const holder = new Container(stageW, stageH).addTo();
	const backing = new Rectangle(stageW, stageH).addTo(holder); // for file save background

	asset("starwars.jpg").alp(.1).center(holder).mov(0,-100);

	// will save data to localStorage
	// so next time, user choices can be retrieved
	let data = null;
	if (localStorage && localStorage.starwars) {
		data = JSON.parse(localStorage.starwars); // get the last data
	} else {
		data = asset("list.json"); // use the provided json data
	}

	const list = new List({
		titleBar:data.title,
		titleBarBackgroundColor:orange,
		list:data.values,
		align:LEFT,
		width:350,
		height:400,
		viewNum:9
	}).center(holder).mov(0,50);

	// create an Organizer to organize the list
	// do not show add or remove in organizer (two false parameters)
	// could pass an Organizer into the List above but looks odd with title and wide list
	const organizer = new Organizer(145, list, false, false)
		.pos(0,-37,RIGHT,TOP, list) // or set to 0 for inside bar
		.change(()=>{
			// when the organizer changes the list save the data
			data.values = list.itemsText;
			if (localStorage) localStorage.starwars = JSON.stringify(data);
		});

	// create a loader - we will not load a picture this time
	// but rather just use the Loader save method
	const loader = new Loader();
	new Button({
		label:"DOWNLOAD",
		width:300,
		height:80,
		backgroundColor:grey,
		corner:5,
		rollBackgroundColor:orange
	})
		.sca(.5)
		.pos(0,30,CENTER,BOTTOM) // do not add button to save container
		.tap(() => {
			loader.save(holder, "starwars")
		});
	
	new Label({
		text:"ZIM - List with JSON data and localStorage",
		color:white
	}).sca(.6).alp(.5).pos(30,30);


	stage.update(); // this is needed to show any changes

	// DOCS FOR ITEMS USED
	// https://zimjs.com/docs.html?item=Frame
	// https://zimjs.com/docs.html?item=Container
	// https://zimjs.com/docs.html?item=Rectangle
	// https://zimjs.com/docs.html?item=Label
	// https://zimjs.com/docs.html?item=Button
	// https://zimjs.com/docs.html?item=List
	// https://zimjs.com/docs.html?item=Organizer
	// https://zimjs.com/docs.html?item=Loader
	// https://zimjs.com/docs.html?item=tap
	// https://zimjs.com/docs.html?item=change
	// https://zimjs.com/docs.html?item=pos
	// https://zimjs.com/docs.html?item=mov
	// https://zimjs.com/docs.html?item=alp
	// https://zimjs.com/docs.html?item=sca
	// https://zimjs.com/docs.html?item=addTo
	// https://zimjs.com/docs.html?item=center
	// https://zimjs.com/docs.html?item=zog

	// FOOTER
	// call remote script to make ZIM icon - you will not need this
	createIcon(); 

}); // end of ready
              
            
!
999px

Console