Created
March 1, 2015 03:20
-
-
Save joshblack/dc590ed95e81eb08ece4 to your computer and use it in GitHub Desktop.
Fun Parsing challenge for JavaScript Style Sheets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| '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] | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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