Skip to content

Instantly share code, notes, and snippets.

View mattdanielbrown's full-sized avatar

Matt Daniel Brown mattdanielbrown

View GitHub Profile
@mattdanielbrown
mattdanielbrown / placeholder.scss
Created October 5, 2016 17:17 — forked from antsa/placeholder.scss
Placeholder mixin for Sass
// Placeholder @mixin for Sass
//
// A mixin to style placeholders in HTML5 form elements.
// Includes also a .placeholder class to be used with a polyfill e.g.
// https://github.com/mathiasbynens/jquery-placeholder
// Requires Sass 3.2.
//
// Example usage (.scss):
//
// input {

SCSS

Cool things you may not have known your stylesheets could do. I'd rather have kept it to a nice round number like 10, but they just kept coming. Sorry.

I've been using SCSS/SASS for most of my styling work since 2009, and I'm a huge fan of Compass (by the great @chriseppstein). It really helped many of us through the darkest cross-browser crap. Even though browsers are increasingly playing nice with CSS, another problem has become very topical: managing the complexity in stylesheets as our in-browser apps get larger and larger. SCSS is an indispensable tool for dealing with this.

This isn't an introduction to the language by a long shot; many things probably won't make sense unless you have some SCSS under your belt already. That said, if you're not yet comfy with the basics, check out the awesome CSS extensions you've always wished you had:

  • [Nested selectors
var touchingElement = false;
var startTime;
var startX = 0,
startY = 0;
var currentX = 0,
currentY = 0;
var isOpen = false;
var isMoving = false;
var menuWidth = 0;
@mixin for-size($range) {
$phone-upper-boundary: 600px;
$tablet-portrait-upper-boundary: 900px;
$tablet-landscape-upper-boundary: 1200px;
$desktop-upper-boundary: 1800px;
@if $range == phone-only {
@media (max-width: #{$phone-upper-boundary - 1}) { @content; }
} @else if $range == tablet-portrait-up {
@media (min-width: $phone-upper-boundary) { @content; }
@mixin for-phone-only {
@media (max-width: 599px) { @content; }
}
@mixin for-tablet-portrait-up {
@media (min-width: 600px) { @content; }
}
@mixin for-tablet-landscape-up {
@media (min-width: 900px) { @content; }
}
@mixin for-desktop-up {
@mixin for-size($size) {
@if $size == phone-only {
@media (max-width: 599px) { @content; }
} @else if $size == tablet-portrait-up {
@media (min-width: 600px) { @content; }
} @else if $size == tablet-landscape-up {
@media (min-width: 900px) { @content; }
} @else if $size == desktop-up {
@media (min-width: 1200px) { @content; }
} @else if $size == big-desktop-up {
// Three mostly separate examples: Adding, reading/listening, and removing multiple items from firebase
// Firebase V3.0.0
// one school has many courses and many studens
// one course has many students and is in only one school
// one student is in many courses and only one school
const db = firebase.database().ref('test');
const userId = firebase.auth().currentUser.uid;
/* -- ADDING -- */
// where `db` is a `Firebase` ref
export function checkIfUserExists(authData) {
return db
.child('users')
.child(authData.uid)
.once('value')
.then(dataSnapshot => {
return Promise.resolve({
authData,
{
"data" : {
"courses" : {
"-KIPudHADux41n04CCxE" : {
"name" : "An excellent course!",
"schoolKey" : "-KIPudH9ZmFi3cimtCTH"
},
"-KIPudHADux41n04CCxF" : {
"name" : "An second excellent course",
"schoolKey" : "-KIPudH9ZmFi3cimtCTH"
//This sets up listeners to listen to data in this structure: https://gist.github.com/davidgilbertson/283581dd10013848b0e7037e308db113
const db = firebase.database().ref('test');
const userId = firebase.auth().currentUser.uid;
const userRef = db.child('users').child(userId);
// a mock store
const store = {
dispatch: (action) => {
console.log(action);
}