Skip to content

Commit

Permalink
jQuery and nav tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
parkerbossier committed May 21, 2017
1 parent 9206682 commit 870eb1b
Show file tree
Hide file tree
Showing 9 changed files with 212 additions and 14 deletions.
52 changes: 49 additions & 3 deletions app/App.less
@@ -1,4 +1,5 @@
@import url('https://fonts.googleapis.com/css?family=Ubuntu+Mono');
@import (reference) './definitions.less';
@import url('https://fonts.googleapis.com/css?family=Ubuntu+Mono:400,700');

* {
box-sizing: content-box;
Expand All @@ -11,17 +12,62 @@ body {
align-items: center;
justify-content: center;
font-family: 'Ubuntu Mono', monospace;
font-size: 14px;
font-size: 16px;
background: url('/img/mars.jpg');
background-size: cover;
background-repeat: no-repeat;
}

.Nav {
position: fixed;
top: 50px;
left: 50px;
background: fade(black, 50%);
padding: 30px;
color: @colorWhite;

li {
&:before {
content: '> ';
}
}
li + li {
margin-top: @gutterSmall;
}
label {
cursor: pointer;
}
input {
display: none;
}
input:checked + span {
font-weight: bold;
}

&:before,
&:after {
content: '';
position: absolute;
height: 10px;
left: -2px;
right: -2px;
border: 2px solid white;
}
&:before {
top: -2px;
border-bottom: none;
}
&:after {
bottom: -2px;
border-top: none;
}
}

.ComingSoon {
position: relative;
background: fade(black, 50%);
padding: 30px;
color: white;
color: @colorWhite;

&:before,
&:after {
Expand Down
11 changes: 4 additions & 7 deletions app/App.ts
@@ -1,10 +1,7 @@
import './reset.less';
import './App.less';

class Thing {
constructor() {
console.log('thing created', this);
}
}
import { Nav } from './Nav';

import './App.less';

const a = new Thing();
new Nav($('.Nav'));
93 changes: 93 additions & 0 deletions app/Nav.less
@@ -0,0 +1,93 @@
@import (reference) './definitions.less';

.Nav {
position: fixed;
top: 50px;
left: 50px;
background: fade(black, 50%);
padding: 14px 30px;
color: @colorWhite;

ul {
transition: opacity .2s ease, max-height .2s ease;
max-height: 150px;
}
li {
&:before {
content: '> ';
}
}
li + li {
margin-top: @gutterSmall;
}
label {
cursor: pointer;
margin-right: 1em;
}
input[type=radio] {
display: none;
}
&-text {

}
input:checked + &-text {
font-weight: bold;

&:after {
content: ' <';
position: absolute;
margin-left: .5em;
pointer-events: none;
}
}

/* top/bottom bars */
&:before,
&:after {
content: '';
position: absolute;
height: 10px;
left: -2px;
right: -2px;
border: 2px solid white;
}
&:before {
top: -2px;
border-bottom: none;
}
&:after {
bottom: -2px;
border-top: none;
}

/* open/close */
&-toggle {
position: absolute;
top: 5px;
right: 5px;
width: 15px;
height: 15px;
display: flex;
align-items: center;
justify-content: center;
border: 1px solid @colorWhite;
background: none;
color: @colorWhite;
font-size: 16px;
cursor: pointer;
}
&-toggleContent:before {
content: '-';
}

/* collapsed */
&--collapsed {
ul {
max-height: 0;
opacity: 0;
}
}
&--collapsed &-toggleContent:before {
content: '+';
}
}
16 changes: 16 additions & 0 deletions app/Nav.ts
@@ -0,0 +1,16 @@
import './Nav.less';

export class Nav {
constructor(private element: JQuery) {
// on change
element.find('input[type=radio]').on('change', e => {
const input = e.currentTarget as HTMLInputElement;
window.location.hash = input.value;
});

// toggle
element.find('.Nav-toggle').click(e => {
element.toggleClass('Nav--collapsed');
});
}
}
3 changes: 3 additions & 0 deletions app/definitions.less
@@ -0,0 +1,3 @@
@colorWhite: white;
@gutter: 16px;
@gutterSmall: 8px;
1 change: 1 addition & 0 deletions index.d.ts
@@ -0,0 +1 @@
declare var $: JQueryStatic;
46 changes: 42 additions & 4 deletions index.html
Expand Up @@ -9,11 +9,49 @@
</head>

<body>
<div class="ComingSoon">
Assembling launch vehicle
</div>
<nav class="Nav">
<ul>
<li>
<label>
<input checked name="nav" type="radio" value="flightplan" />
<span class="Nav-text">Flightplan</span>
</label>
</li>
<li>
<label>
<input name="nav" type="radio" value="zazzle" />
<span class="Nav-text">Zazzle</span>
</label>
</li>
<li>
<label>
<input name="nav" type="radio" value="secondary" />
<span class="Nav-text">Secondary missions</span>
</label>
</li>
<li>
<label>
<input name="nav" type="radio" value="resume" />
<span class="Nav-text">Resume</span>
</label>
</li>
<li>
<label>
<input name="nav" type="radio" value="contact" />
<span class="Nav-text">Contact</span>
</label>
</li>
</ul>

<script async src="/app.js"></script>
<!--
<div class="Nav-toggle">
<span class="Nav-toggleContent"></span>
</div>
-->
</nav>

<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script>
<script src="/app.js"></script>
</body>

</html>
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -7,6 +7,7 @@
"start": "webpack-dev-server"
},
"dependencies": {
"@types/jquery": "^2.0.45",
"autoprefixer": "^7.1.1",
"awesome-typescript-loader": "^3.1.3",
"css-loader": "^0.28.1",
Expand Down
3 changes: 3 additions & 0 deletions tsconfig.json
Expand Up @@ -10,5 +10,8 @@
},
"exclude": [
"node_modules"
],
"files": [
"index.d.ts"
]
}

0 comments on commit 870eb1b

Please sign in to comment.