new layout

This commit is contained in:
Koen Lageveen 2016-03-02 21:11:16 +01:00
parent 781745f4d9
commit f41b7f8ff9
1 changed files with 284 additions and 278 deletions

View File

@ -86,132 +86,121 @@
background: #F5F0E6;
}
body {
color:#444;
color: #fff;
background: #222;
font-family: "Lato", sans-serif;
font-size: 16px;
line-height: 2;
}
h1 {
font-family: 'Input Mono', serif;
font-weight: bold;
font-size: 64px;
line-height: 64px;
margin: 0 0 16px 0;
text-align: center;
padding-top: 64px;
font-size: 2em;
margin: 0;
padding: 0;
}
h1 + p {
font-weight: bold;
text-align: center;
margin: 0 0 48px 0;
font-size: 20px;
line-height: 1;
padding: 1em 0;
}
article {
max-width: 90%;
width: 800px;
margin: 0 auto;
margin-bottom: 64px;
background: white;
border: 0;
box-shadow: 0 0 2px rgba(0, 0, 0, 0.2);
position: fixed;
background: transparent;
bottom: 0;
right: 0;
margin-bottom: 2em;
margin-right: 2em;
text-align: right;
max-width: 50%;
}
article p {
text-align: center;
padding: 0 32px 16px 32px;
}
article p:last-child {
padding-bottom: 36px;
footer {
font-size: .8em;
}
#font-info p {
display: none;
padding-bottom: 36px;
}
article form {
margin-bottom: 32px;
}
select {
margin-right: 32px;
}
footer {
max-width: 90%;
width: 800px;
text-align: center;
margin: 64px auto;
}
footer form {
margin-top: 8px;
line-height: 1;
padding: 1em 0;
}
a,
a:link,
a:visited,
a:hover {
color: #44cc9a;
text-decoration: none;
color: inherit;
opacity: .7;
transition: opacity .2s;
}
a:hover {
opacity: .8;
transition: opacity .5s;
a:hover,
a:active {
opacity: 1;
}
select {
width: 12em;
margin-left: .5ex;
}
pre,
textarea,
.CodeMirror {
font-family: "Input Mono";
height: auto;
}
.CodeMirror {
border: none;
font-size:16px;
background: transparent;
box-shadow: none !important;
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
}
.CodeMirror-gutters {
background: transparent;
}
@media screen and (max-width:800px) {
.select {
display: block;
text-align: right;
margin: 0;
}
}
@media screen and (max-width:640px) {
h1 {
font-size: 48px;
line-height: 48px;
padding-top: 48px;
margin-bottom: 48px;
}
@media (max-width: 400px) {
body { line-height: 1.5; }
article { margin-bottom: 1.5em; max-width: none; }
label { display: block; }
h1 { font-size: 1em; }
h1 + p,
footer { display: none; }
}
</style>
</head>
<body>
<div class="background"></div>
<h1>Programming Fonts</h1>
<p class="description">What font looks best? Test drive over 50 free programming fonts and find out!</p>
<article>
<form>
<textarea id="code" name="code">
# Type some code:
function findSequence(goal) {
function find(start, history) {
if (start == goal)
return history;
else if (start > goal)
return null;
else
return find(start + 9, "(" + history + " + 9)") ||
find(start * 3, "(" + history + " * 3)");
function updateGutters(cm) {
var gutters = cm.display.gutters, specs = cm.options.gutters;
removeChildren(gutters);
for (var i = 0; i < specs.length; ++i) {
var gutterClass = specs[i];
var gElt = gutters.appendChild(elt("div", null, "CodeMirror-gutter " + gutterClass));
if (gutterClass == "CodeMirror-linenumbers") {
cm.display.lineGutter = gElt;
gElt.style.width = (cm.display.lineNumWidth || 1) + "px";
}
return find(1, "I");
}
gutters.style.display = i ? "" : "none";
updateGutterSpace(cm);
}
return "o0Og9ilL1!";
</textarea>
</form>
<p><span class="select">Select a theme
<article>
<h1>Programming Fonts</h1>
<p class="description">What font looks best?<br>
Test drive over 50 free programming fonts and find out!</p>
<p>
<span class="select"><label for="select">Select a theme</label>
<select onchange="selectTheme()" id="select">
<option>3024-day</option>
<option>3024-night</option>
@ -243,25 +232,29 @@ function findSequence(goal) {
<option>vibrant-ink</option>
<option>xq-dark</option>
<option>xq-light</option>
</select></span>
<span class="select">Select a font <select onchange="selectFont()" id="select-font">
</select>
</span>
</p>
<p>
<span class="select" id="fontselect"><label for="select-font">Select a font</label>
<select onchange="selectFont()" id="select-font">
<!-- filled from json -->
</select></span>
</select>
</span>
</p>
<dix id="font-info"></dix>
<footer>
<a href="http://programmingfonts.org/list" rel="external">The full list</a> -
<a href="http://programmingfonts.org">The blog</a> -
<a href="http://atom.io/packages/fonts" rel="external">Atom package</a> -
<a href="https://github.com/braver/programmingfonts">Fork this on Github</a> -
By <a href="http://koenlageveen.nl">Koen Lageveen</a>
</footer>
</article>
<footer>
<p><a href="http://programmingfonts.org/list" rel="external">Download your favourite fonts</a>, or use <a href="http://atom.io/packages/fonts" rel="external">this package</a> in <a href="http://atom.io">Atom</a></p>
<p>
Contribute on <a href="https://github.com/braver/programmingfonts">Github</a>
</p>
<p>
<a href="http://programmingfonts.org">Back to the blog</a> - &copy; 2016 <a href="http://koenlageveen.nl">Koen Lageveen</a>
<p>
</footer>
<!-- Some jquery to make life easier -->
<script src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
@ -277,11 +270,17 @@ function findSequence(goal) {
theme: "monokai"
});
function applyColors() {
$("body").css('color', $(".CodeMirror").css('color'));
$("article").css("text-shadow", "0 0 4px " + $(".CodeMirror").css('background-color'));
}
// CodeMirror theme selector
var input = document.getElementById("select");
function selectTheme() {
var theme = input.options[input.selectedIndex].innerHTML;
editor.setOption("theme", theme);
applyColors();
}
var choice = document.location.search &&
@ -311,6 +310,13 @@ function findSequence(goal) {
}
$(document).ready(function(){
//randomly select a theme
var options = $("#select > option");
options[Math.floor(Math.random() * options.length)].selected = "selected";
selectTheme();
applyColors();
var font_aliases = [];
$.getJSON("fonts.json", function(data) {