Skip to content

Instantly share code, notes, and snippets.

@joshblack
Created March 1, 2015 03:20
Show Gist options
  • Select an option

  • Save joshblack/dc590ed95e81eb08ece4 to your computer and use it in GitHub Desktop.

Select an option

Save joshblack/dc590ed95e81eb08ece4 to your computer and use it in GitHub Desktop.
Fun Parsing challenge for JavaScript Style Sheets
'use strict';
import Parser from './parser';
import styles from './styles';
Parser(styles);
// Output:
{
h1: {
background: 'blue',
minWidth: { '320': [Object] }
},
button: {
background: 'blue',
'border-radius': '15px',
padding: '25px',
'.open': {
background: 'darkblue',
minWidth: [Object],
maxWidth: [Object]
}
}
}
// Style Examples
// You can even use variables in the template string.
// Just define/import the variables above and use them
// like background: ${backgroundColor} in the string.
module.exports = `
h1 {
background: blue;
minWidth {
320 {
background: lightblue
}
}
}
button {
background: blue;
border-radius: 15px;
padding: 25px;
.open {
background: darkblue;
minWidth {
640 {
margin: 15px;
}
}
maxWidth {
480 {
margin: 30px
}
}
}
}`;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment