tilefolio How to build Français

How to build

Create a code tile

Tilefolio is hackable: you can write your own HTML, CSS and JavaScript. A code tile shows your own little web page: one HTML file with its CSS and JavaScript. A moving drawing, a shader, a 3D object, a sound toy, or just a hand-made layout. Your visitors see an image, click it, and your page opens large and comes alive.

A code tile's page opened over the site: a sketch of coloured circles moves, large, with the tile's title and text
On the site: after a click, the tile's page opens and its code runs.

Who can create one

Code tiles are for every site, during the free trial too: the site's owner and its editors create them, change their code and delete them. They are created from the site, in edit mode (Edit on my site), where the editor has its live preview. A code tile can't be put up for sale.

Create the tile

  1. Open your site in edit mode, then click + Code tile (next to + Add a tile).
  2. In Start from a template, pick an example (see the templates), or write your code straight in the editor.
  3. The preview shows your code as it is, unsaved, and runs again when you stop typing. The code's errors are listed below it, with their line.
  4. Tick the libraries your code needs (see below).
  5. Choose the still (see below), a title, a date and a size.
  6. Click Create the tile: nothing is online before, and the tile is published right after.
The code tile panel: the code of a shader template, the live preview, the libraries and the still
The panel: the code on the left, the live preview on the right.

To change the code later, select the tile on the site and click Edit the code: the same panel opens. The title and size are changed in the tile's toolbar, as for other tiles. You can also see the tile in the admin (Code tiles), but the site's editor is simpler: it has the preview and the templates.

Start from a template

Each template is one HTML file, short, commented in French and in English, with its CSS and JavaScript inside. It adapts to the tile's size. Picking a template fills the editor and ticks its libraries; if you already wrote code, you are asked to confirm before it is replaced.

Change a number, a colour, a text, and watch the preview: it is the best way to learn.

The libraries

Two libraries are offered, ticked tile by tile; only the ticked ones are loaded.

No other script address is accepted: you can't load a library from elsewhere. A library that fits in one file can, however, be pasted into your code (within the 200 KB).

The still

A code tile is always an image before the click: its cover, the one visitors see in the mosaic, search engines and sharing previews. Two ways to choose it:

Without a chosen image, Tilefolio makes one with the tile's title.

What your visitors see

The tile shows its still, like any tile, with the </> icon beside its title. As with the other tiles, a click opens its page over the site (/code/…, an address you can share): the code starts at once, as large as the screen allows, with the tile's text below. Nothing runs in the mosaic itself. Closing the page stops the code, which lets the computer or phone rest. The Full screen button, under the code, shows it on the whole screen (Esc or Exit full screen to leave): your code then gets the new size, as when a window is resized (windowResized in p5.js, the resize event; the templates already do it). On iPhones, whose browser doesn't allow it, there is no button.

A site's mosaic: code tiles with their still, the first one showing its title on hover
Before the click: each tile's still.

Reporting, stopping

Under a running code tile, on its page, a Report this content link lets a visitor warn the Tilefolio team: they pick a reason (shocking or illegal content, scam, disrupts the page, infringes rights, other) and may add a few words. They are asked for no name and no address. The report shows in your Tilefolio support log, with its reason.

The Tilefolio team can then stop the tile, or all the site's code tiles: they show only their still, at once, and the stop is noted in that log, with the reason if the team gave one. In edit mode, the tile's toolbar says so, to the owner and the editors alike. You can't start it again yourself: write to support to know why, or once the code is fixed. A stop is of the display only: a stopped tile's code can still be changed (it stays stopped), and while all the site's code tiles are stopped you can still create, change and delete them; visitors see only their stills until the team starts them again.

Combinations and sharing

The tile's page tells your code two things, in the address of its box, after the #: page, the address of the tile's page on your site (for example https://picasol.fr/code/remix-pinkasol), and preset, when the page's address ends with ?preset=… (up to 200 letters, digits and . _ ~ -). Your code reads them with location.hash, and does what it likes with the preset: a combination, a level, a colour. So a visitor can keep a link to this state of your tile: …/code/remix-pinkasol?preset=d07.2-p01.3.

const hash = new URLSearchParams(location.hash.slice(1));
const page = hash.get("page");     // https://your-site/code/your-tile
const preset = hash.get("preset"); // null without one
// a link to keep: page + "?preset=" + yourPreset

Your code can also ask the page to open the visitor's mail app with a message to you (your site's address: its E-mail profile link, else the footer's contact if it is just an address). After a click in the tile:

parent.postMessage({ tf: "code-share", preset: "d07.2-p01.3",
  title: "My combination", text: "Listen to this one!" }, "*");

The page writes the e-mail itself: the title (else the tile's), the text (500 characters at most), then the link to the tile's page with the preset. Nothing is sent: the visitor's mail app opens with a draft, they send it or not. The page answers your code with { tf: "code-share", ok: true } (false when your site has no address, or a second time within 3 seconds).

What the box can't do, and why

Your code doesn't run on your site, but in a "box": a separate page with an address of its own, in a closed frame. This is what lets Tilefolio let any artist write code without putting visitors, or your account, at risk. As a result:

The code can't exceed 200 KB either (the panel shows the size). That's a lot for text: a page, its styles and a drawing take only a few.

When it doesn't work

The code's errors are listed under the preview, with the line number when the browser gives it. Safari doesn't give the text of an error from the box, only that there is one: open the panel in Chrome or Firefox to read it. A "Blocked by the box" message means the code tries to do something the box forbids (see above).

A shader or a 3D scene needs the visitor's graphics chip: on a very old computer the tile may stay black. Try a lighter code.