Created
January 21, 2016 20:34
-
-
Save mattborn/612d4671ee2c1a8c4d7f to your computer and use it in GitHub Desktop.
Metalcore UI with Riot.js
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
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
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
| <html> | |
| <head> | |
| <title>riotjs</title> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <link rel="stylesheet" href="styles.css"> | |
| </head> | |
| <body> | |
| <albums></albums> | |
| <script src="https://cdn.jsdelivr.net/riot/2.3/riot+compiler.min.js"></script> | |
| <script type="riot/tag"> | |
| <albums> | |
| <div class="album" each="{ opts.data }" style="background-image: url({ image });"> | |
| <div class="album-meta"> | |
| <div class="album-name">{ album }</div> | |
| <div class="album-artist">{ artist }</div> | |
| </div> | |
| <a class="album-play" href="https://open.spotify.com/album/{ spotify }" target="_blank"></a> | |
| </div> | |
| </albums> | |
| </script> | |
| <script> | |
| var x = new XMLHttpRequest(); | |
| x.onreadystatechange = function () { | |
| if (x.readyState === 4 && x.status === 200) { | |
| riot.mount('albums', JSON.parse(x.responseText)); | |
| } else { | |
| // server error | |
| } | |
| }; | |
| x.onerror = function () { | |
| // network error | |
| }; | |
| x.open('GET', 'http://rawgit.com/mattborn/data/master/metalcore.json', true); | |
| x.send(null); | |
| </script> | |
| </body> | |
| </html> |
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
| @import url(https://fonts.googleapis.com/css?family=Montserrat); | |
| body { | |
| background: #111; | |
| font: 14px/1 Montserrat, sans-serif; | |
| margin: 0; | |
| -webkit-font-smoothing: antialiased; | |
| } | |
| .album { | |
| background-position: center; | |
| background-size: cover; | |
| cursor: pointer; | |
| float: left; | |
| height: calc(100vw / 5); | |
| position: relative; | |
| width: 20%; | |
| } | |
| .album-meta { | |
| background: rgba(0,0,0,.8); | |
| color: #fff; | |
| height: 100%; | |
| left: 0; | |
| opacity: 0; | |
| padding: 20px; | |
| position: absolute; | |
| top: 0; | |
| transition: opacity .4s; | |
| width: 100%; | |
| } | |
| .album:focus .album-meta, | |
| .album:hover .album-meta { opacity: 1; } | |
| .album-play { | |
| height: 100%; | |
| left: 0; | |
| position: absolute; | |
| top: 0; | |
| width: 100%; | |
| } | |
| .album-name { | |
| font-size: 20px; | |
| margin-bottom: 5px; | |
| } | |
| .album-artist { | |
| opacity: .5; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment