Skip to content

Instantly share code, notes, and snippets.


Glen Maddern geelen

View GitHub Profile
geelen / gist:2e314d9c547b752603fd
Last active Aug 29, 2015
Web Component design thoughts
View gist:2e314d9c547b752603fd

Web Component design thoughts

It feels like I'm facing the same thing the same problems writing the API of these components. In particular:

  • A component might have several distinct modes. As in, an <x-gif speed="1.0"> has a very different playback mode from <x-gif bpm="120">, so you shouldn't be allowed to have both speed and bpm. But it doesn't seem right to break them into separate components, so either one takes precedence or having both present causes an explosion.
  • A component might require more than one attribute to be valid. As in, . Until you have both the `channel` and `note` you can't make connection to the midi signal. But if you're driving the component with a framework like angular, it will first render incompletely (as ), then after a $digest will insert the right values. So a component may need to permit being in an invalid state temporarily, then when all attributes are set go and get

Global traits, local components

The idea is to combine the best bit of global styling (reuse, small payload) and local styling (total isolation, first-class React syntax)

This is combined with the concept of traits: you can think of them as permitted property/value pairs. Instead of every component being able to have every CSS property available to it, you can reduce your permitted set to X font families, Y font-size + line-height pairs, Z foreground/background colour pairs, W padding amounts. This is based off my work using amcss on real projects — traits were the single key feature that kept me using AM.

The one-sentence explanation: A site defines a set of permitted visual features, all components are simply a combination of those features


View 1_pi.rb
def distance(x,y)
Math.sqrt(x * x + y * y)
def in_circle(x,y)
distance(x,y) < 1
def random_point
rand * 2 - 1
kitten /
Last active Nov 17, 2020
ReactiveConf 2017 Lightning Talk CFP: With styled-components into the future

styled-components Logo

With styled-components into the future

Preprocessing is dead, long live preprocessing!

This is a CFP for ReactiveConf 2017's open call for Lightning talks. If you'd like to see this talk become a reality, please star this gist. #ReactiveConf

javivelasco /
Last active May 12, 2022
Proposal for lightning talk at Reactive Conf 2016

Please star ⭐️ the gist to help! This is a proposal for a ⚡️ talk at Reactive Conference.

Styling Components in React Toolbox 2

I wrote react-toolbox and presented it almost a year ago in lighning talk at Reactive Conf 2015 in Bratislava. At first it was just a proof of concept of a component library styled with CSS Modules and SASS. Now the project has grown quite a bit, and during this year there has been tons of changes and lessons learned.

Theming and customization is one of the most difficult and interesting problems to solve. For the first version we needed a custom Webpack loader to generate themes and doing simple style overrides was very painful. Today I'm working on a new playground that will allow you try CSS Modules live, and to create React Toolbox themes on the f