Skip to content

Instantly share code, notes, and snippets.

View lvl99's full-sized avatar

Matt Scheurich lvl99

View GitHub Profile
@lvl99
lvl99 / scss-dynamic-breakpoint-media-queries.scss
Last active March 2, 2016 10:20
This is just a few ramshackle mixins I put together based on a theory. Don't know if they're suitable for production yet, but check it out. Please note that it's all only supported by `min/max-width`, no pixel density or orientation conditions, or even anything other than the `screen` media type.
/*
* SCSS Dynamic Breakpoint Media Queries
* Author: Matt Scheurich <matt@lvl99.com>
*
* This is just a few ramshackle mixins I put together based on a theory.
* Don't know if they're suitable for production yet, but check it out.
* Please note that it's all only supported by `min/max-width`, no pixel
* density or orientation, or even anything other than the `screen` media type.
*/
@lvl99
lvl99 / emoji.json
Last active August 27, 2016 11:27
A JSON array containing unicode/byte character info and description extracted from Tim Whitlock's "Emoji Unicode Tables" (http://apps.timwhitlock.info/emoji/tables/unicode), which is probably the best reference out there. From last count there are 842 characters listed.
[
{
"unicode": "U+1F601",
"bytes": "\\xF0\\x9F\\x98\\x81",
"description": "grinning face with smiling eyes",
"htmlchar": "&#x1F601;"
},
{
"unicode": "U+1F602",
"bytes": "\\xF0\\x9F\\x98\\x82",
@lvl99
lvl99 / components.filter-items.js
Last active February 15, 2017 14:44
New Twiddle
import Ember from 'ember';
export default Ember.Component.extend({
filteredItems: Ember.computed('items', function () {
// Imagine more than just one filter here
return this.get('items').filterBy('showMe', true)
}),
sortDirection: ['lastUpdated:desc', 'createdAt:desc'],
sortedItems: Ember.computed.sort('filteredItems', 'sortDirection'),
@lvl99
lvl99 / components.create-item.js
Last active February 23, 2017 07:01
Filtering and sorting via computed properties
import Ember from 'ember'
export default Ember.Component.extend({
store: Ember.inject.service(),
title: undefined,
location: undefined,
rating: undefined,
inputRatings: [{
label: 'Not rated',
@lvl99
lvl99 / 01-Example-of-ES6-class-extending.js
Created April 7, 2017 13:54
Object-oriented inspired composable LESS mixins. View the article on the blog: http://blog.lvl99.com
class Modal extends Toggleable {
  // … magic goes here …
}
@lvl99
lvl99 / 02-Example-of-HTML-when-declaring-CSS-classes-on-elements.html
Created April 7, 2017 13:55
Object-oriented inspired composable LESS mixins. View the article on the blog: http://blog.lvl99.com
<!-- Modal component HTML structure with modal and toggleable classes applied -->
<!-- This is usually the most basic way to combine multiple classes on an element -->
<div id=”example-a” class=”modal toggleable”>
<!-- … oh la la, magic~~~ … -->
</div>
@lvl99
lvl99 / 03-Example-Toggleable-composable-mixin-class.less
Created April 7, 2017 13:55
Object-oriented inspired composable LESS mixins. View the article on the blog: http://blog.lvl99.com
// Toggleable Mixin Class
// @param @ns Namespaces the custom state classes
// @param @-toggleable-display Sets the display property for showing the toggleable
.ui-lvl99-toggleable(@ns: ~"lvl99-toggleable"; @-toggleable-display: ~"block") {
// Uses the namespace to build custom state classes
@-toggleable-ns-class-show: ~".ui-@{ns}-show";
@-toggleable-ns-class-hide: ~".ui-@{ns}-hide";
// Class mixin which contain style definitions for `show` state
.-toggleable-class-show(@rules: {}) {
@lvl99
lvl99 / 04-Example-of-instantiating-Toggleable-mixin.less
Created April 7, 2017 13:55
Object-oriented inspired composable LESS mixins. View the article on the blog: http://blog.lvl99.com
// Import and apply the Toggleable Mixin Class to a specific class
.toggleable {
// Imports the mixin and its related mixins and variables
.ui-lvl99-toggleable(@ns: ~"toggleable");
// Initialise the default since we have no other modifications from the normal
.-toggleable-init-default();
}
// Let's do a parametric modification since spans should be displayed using `inline` or `inline-block`
span.toggleable {
@lvl99
lvl99 / 05-Composable-mixin-piece-declaration.less
Created April 7, 2017 13:56
Object-oriented inspired composable LESS mixins. View the article on the blog: http://blog.lvl99.com
.ui-lvl99-toggleable(@ns: ~"lvl99-toggleable"; @-toggleable-display: ~"block") {
// … magic beans follows ...
}
@lvl99
lvl99 / 06-Examples-showing-how-composable-mixins-are-instantiated-and-extended.less
Created April 7, 2017 13:56
Object-oriented inspired composable LESS mixins. View the article on the blog: http://blog.lvl99.com
// Modal component
.modal {
.ui-lvl99-toggleable(@ns: ~“modal”);
.-toggleable-init-default();
}
// ... would generate the following CSS
.modal.ui-modal-show {
display: block;
}