Skip to content

Instantly share code, notes, and snippets.

View orbitbot's full-sized avatar

Patrik Johnson orbitbot

  • Helsinki, Finland
View GitHub Profile
import babel from "rollup-plugin-babel";
import eslint from "rollup-plugin-eslint";
import resolve from "rollup-plugin-node-resolve";
import commonjs from "rollup-plugin-commonjs";
import pathmodify from "rollup-plugin-pathmodify";
import postcss from 'rollup-plugin-postcss';
// PostCSS plugins
import simplevars from 'postcss-simple-vars';
import nested from 'postcss-nested';
console.time('build')
const fs = require('fs-extra')
, rollup = require('rollup')
, commonjs = require('rollup-plugin-commonjs')
, json = require('rollup-plugin-json')
, nodeResolve = require('rollup-plugin-node-resolve')
, buble = require('rollup-plugin-buble')
, uglify = require('rollup-plugin-uglify')
, stylus = require('stylus')
@flintinatux
flintinatux / component.js
Created July 23, 2016 18:12
Component wrapper for mithril 1.x. Registers lifecycle methods as streams, so that components may be contructed as single-closure factories that return view functions.
const m = require('mithril')
const stated = hook => vnode => vnode.state[hook](vnode)
const oninit = Comp => vnode => {
vnode.state.oncreate = m.prop()
vnode.state.onremove = m.prop()
vnode.state.view = Comp(vnode)
}
var gulp = require('gulp');
var bro = require('gulp-bro');
var babelify = require('babelify')
var uglify = require('gulp-uglify');
var sourceFile = 'js/mithril-app/app.js',
destFolder = './js/',
destFile = 'app.js';
gulp.task('build-js', function () {
gulp.src('./js/mithril-app/app.js')
@gilbert
gilbert / example.js
Last active August 3, 2016 21:19
Mithril.js - Avoiding m.props
// m.prop is a great pattern, but Plain-old JavaScript Objects (POJO) are
// much more pleasant to work with.
// Here's an example of using POJOs with one- and two-way data binding.
// First, the helper methods
m.setValue = function (obj, prop) {
return m.withAttr('value', function(value) { obj[prop] = value })
}
@paulirish
paulirish / what-forces-layout.md
Last active April 24, 2024 01:42
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@webcss
webcss / eventsmixin.js
Last active August 9, 2016 12:44
PubSub mixin using CustomEvents
// utilizes the browser eventsystem
// usefull in cases where you need communication between independent components
// registered events are automatically removed onunload with preserving any other onunload handler
var eventsMixin = function(target) {
var _subscriptions = [];
target.broadcast = function(type, payload) {
var ev = new CustomEvent(type, {
detail: payload,
@bobbygrace
bobbygrace / trello-css-guide.md
Last active April 22, 2024 10:15
Trello CSS Guide

Hello, visitors! If you want an updated version of this styleguide in repo form with tons of real-life examples… check out Trellisheets! https://github.com/trello/trellisheets


Trello CSS Guide

“I perfectly understand our CSS. I never have any issues with cascading rules. I never have to use !important or inline styles. Even though somebody else wrote this bit of CSS, I know exactly how it works and how to extend it. Fixes are easy! I have a hard time breaking our CSS. I know exactly where to put new CSS. We use all of our CSS and it’s pretty small overall. When I delete a template, I know the exact corresponding CSS file and I can delete it all at once. Nothing gets left behind.”

You often hear updog saying stuff like this. Who’s updog? Not much, who is up with you?

@StephanHoyer
StephanHoyer / gist:de107b794c43f28ffd75
Last active August 10, 2023 17:16
SVG Icons with mithril.js

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">
// Example
// app.js
document.addEventListener("DOMContentLoaded", function (e) {
m.route.mode = "hash";
m.route(document.getElementById("application"), "/", {
"/": m.resolve("pages.home"),
"/findus": m.resolve("pages.findus")
});
});