This post described how to create an application with mithril 0.2.x. Now that ver 1.0 is out, some things are a little differnent.
The example is updated with the current version of mithril, though.
This post described how to create an application with mithril 0.2.x. Now that ver 1.0 is out, some things are a little differnent.
The example is updated with the current version of mithril, though.
var express = require('express'); | |
function base(content) { | |
return [ | |
'<!doctype html>', | |
'<html>', | |
'<head>', | |
'<link href="/index.css" media="all" rel="stylesheet" type="text/css">', | |
'<link href="/latin/firasans-bold,firasans-hair,firasans-light,firasans-book,firasans-italic,firamono-bold/fonts.css" type="text/css" rel="stylesheet"/ >', | |
'<script src="/index.js"></script>', |
var AmpersandState = require('ampersand-state'); | |
var Ingredient = AmpersandState.extend({ | |
props: { | |
name: 'string' | |
} | |
}); | |
var Meal = AmpersandState.extend({ | |
props: { |
// example using the raf module from npm. try changing some values! | |
var requestAnimationFrame = require("raf") | |
var canvas = document.createElement("canvas") | |
canvas.width = 500 | |
canvas.height = 500 | |
document.body.appendChild(canvas) | |
var context = canvas.getContext("2d") |
Icons have been part of applications since ages. Also most websites rely on icons. There were several ways to use them. First we used plain files then image sprites to reduce requests. Nowadays everyone uses icon fonts like font-awesome or glyphicons.
They are infinetly scaleable and styleable with css. The downside is they use pseudo elements for displaying. This is not only difficult to handle but also non-optimal for accessibilty.
A famous CSS-Tricks post brings SVG icons into play. The are also scalable and they behave like normal images. But we also want to have a sprite to not load any images seperatly and kill our servers and our sites performance. The proposed version is to create sprites with grunt or gulp using the symbol-trick. It's basically add every icon to a hidden sprite-image and give every icon an id-property.
<svg xmlns="http://www.w3.org/2000/svg" style="display: none;">
<symbol id="beaker" viewBox="214.7 0 182.6 792">
Just saw Douglas Crockfords talk at Craft Conference
http://www.ustream.tv/recorded/46640057
Just tried it and must say, it has a certain beauty in it.
No tangeling with prototypes and this/that fuckup.
var Animal = function(name, legs) {
(In a non prioritized order)