Skip to content

Commit 0e186d1

Browse files
committed
aboutme section
1 parent 3466c04 commit 0e186d1

File tree

9 files changed

+190
-7
lines changed

9 files changed

+190
-7
lines changed

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"scripts": {
66
"test": "gulp",
77
"start": "node index.js",
8-
"watch": "nodemon index.js"
8+
"watch": "nodemon index.js",
9+
"deploy": "gh-pages -d public"
910
},
1011
"author": "Charlie Lin <n7best>",
1112
"license": "MIT",
@@ -20,6 +21,7 @@
2021
"dependencies": {},
2122
"devDependencies": {
2223
"autoprefixer": "^7.1.4",
24+
"gh-pages": "^1.0.0",
2325
"gulp": "3.9.1",
2426
"gulp-buffer": "0.0.2",
2527
"gulp-clean-css": "2.0.12",

src/app.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import './app.sass';
22
import { h, wait } from './utils/engine';
33
import { logo, intro, intro_text } from './view/intro';
4-
import { about, about_name, about_title, down_indicator} from './view/about';
5-
4+
import { about, about_name, about_title, down_indicator, about_detail} from './view/about';
5+
import { MoveOnScroll } from './hoc/moveOnScroll';
66

77
const container = h('div', 'container', intro, about, down_indicator)
88
document.body.appendChild(container)
@@ -30,7 +30,7 @@ wait(2000)
3030
})
3131
.then( ()=> {
3232
intro.className = 'intro active bg-blue'
33-
33+
MoveOnScroll(intro)
3434
return wait(500)
3535
})
3636
.then( ()=> {
@@ -41,4 +41,5 @@ wait(2000)
4141
})
4242
.then( ()=> {
4343
down_indicator.style.opacity = 1;
44+
container.appendChild(about_detail(container))
4445
})

src/app.sass

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
body {
23
font-size: 12px;
34
color: #345274;
@@ -23,6 +24,7 @@ body {
2324
display: none;
2425
font-size: 2em;
2526
animation: fadeInTop 1.5s;
27+
margin-bottom: 5em;
2628
i {
2729
left: 1em;
2830

@@ -106,7 +108,48 @@ body {
106108
animation: fadeInTop .5s;
107109
}
108110

109-
111+
&-detail {
112+
width: 100%;
113+
padding: 10em 0;
114+
min-height: 40em;
115+
padding-bottom: 0;
116+
117+
&_intro {
118+
max-width: 980px;
119+
width: 60%;
120+
margin: 3em auto;
121+
font-size: 1.5em;
122+
font-family: 'Arimo', sans-serif;
123+
line-height: 1.5em;
124+
color: #ccc;
125+
transition: all .5s;
126+
}
127+
128+
&_badges {
129+
max-width: 980px;
130+
width: 60%;
131+
margin: 3em auto;
132+
transition: all .5s;
133+
134+
&-badge {
135+
padding: .5em;
136+
height: 5em;
137+
font-family: 'Quicksand', sans-serif;
138+
font-size: 1.25em;
139+
font-weight: 500;
140+
display: inline-block;
141+
img {
142+
display: block;
143+
margin: .75em auto;
144+
height: 100%;
145+
}
146+
}
147+
}
148+
149+
&_photo {
150+
margin-top: 5em;
151+
}
152+
}
110153
}
111154

112155
@keyframes fadeInTop {
@@ -129,6 +172,11 @@ body {
129172
0 3em 3em -0.25em rgba(100,100,100,0.2);
130173
}
131174

175+
.bg-dark {
176+
background: #161616;
177+
color: #fff;
178+
}
179+
132180
.bg-white {
133181
background-color: #fff;
134182
}

src/components/header/index.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import {h} from '../../utils/engine';
2+
import './style.scss';
3+
4+
export const header = (tip, title, tag) => {
5+
6+
const tipel = h('span', 'tip', tip)
7+
const titleel = h('h2', 'title', title)
8+
9+
const el = h('div', 'header-block', tipel, titleel)
10+
return el;
11+
}

src/components/header/style.scss

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
.header-block {
2+
text-align: center;
3+
font-family: 'Quicksand', sans-serif;
4+
transition: all .5s;
5+
margin-top: 40px;
6+
span.tip {
7+
display: block;
8+
font-size: 2em;
9+
10+
}
11+
12+
h2 {
13+
display: block;
14+
font-size: 3.5em;
15+
margin: 0.5em auto;
16+
}
17+
}

src/hoc/moveOnScroll.js

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
export const MoveOnScroll = (component, opts = {}) => {
2+
const options = Object.assign({},{
3+
animation: {
4+
enable: true,
5+
max: 40,
6+
min: 0,
7+
transform: true,
8+
type: '',
9+
10+
},
11+
trigger: (change, el) => el.style.transform = `translate(0px, ${change}px)`,
12+
onVisible: ()=>null,
13+
onInvisible: ()=>null,
14+
container: component.parentElement
15+
}, opts)
16+
17+
options.container.addEventListener('scroll', e=>updateItem(component, options.container))
18+
19+
function updateItem(el, holder) {
20+
21+
22+
const { top:elemTop, bottom:elemBottom, height:elemHeight } = el.getBoundingClientRect()
23+
const { top:holderTop, bottom:holderBottom } = holder.getBoundingClientRect()
24+
25+
let isVisible;
26+
let offset;
27+
28+
if (elemTop <= holderTop) {
29+
//scroll pass the element
30+
offset = window.innerHeight
31+
isVisible = !(holderTop - elemTop > elemHeight);
32+
} else {
33+
//scroll before the element
34+
offset = elemBottom - holderBottom - elemHeight
35+
if(holder.scrollTop < elemTop) offset = holder.scrollTop;
36+
isVisible = !(elemBottom - holderBottom > elemHeight);
37+
}
38+
39+
if(isVisible){
40+
41+
if(options.animation.enable){
42+
let changeValue = 0
43+
changeValue = Math.abs(offset) / window.innerHeight * options.animation.max + options.animation.min
44+
options.trigger(changeValue, el)
45+
}
46+
47+
}
48+
}
49+
50+
return component;
51+
52+
}
53+
54+
export const moveOnScrollOpacity = (component, opt = {}, withold = 25) =>{
55+
return MoveOnScroll(component, Object.assign({},{
56+
trigger : (change, el) => {
57+
el.style.transform = `translate(0px, ${change}px)`
58+
el.style.opacity = change / parseFloat(withold)
59+
}
60+
}, opt))
61+
}

src/utils/avalanche.css

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/view/about.js

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,44 @@
11
import { h } from '../utils/engine'
22
import { button } from '../components/button/index.js'
3+
import { header } from '../components/header/index.js'
4+
import { moveOnScrollOpacity } from '../hoc/moveOnScroll'
35

46
export const about_name = h('p', 'about-name', 'Charlie Lin')
57
export const about_title = h('p', 'about-title', 'WEB DESIGNER / WEB DEVELOPER')
68
export const down_indicator = button('fa fa-long-arrow-down', '', 'btn-grey')
7-
export const about = h('div', 'about', about_name, about_title)
9+
export const about = h('div', 'about', about_name, about_title)
10+
11+
12+
13+
export const about_detail = container =>
14+
{
15+
const iconNYC = h('img', '')
16+
iconNYC.src = 'assets/img/nyc.png'
17+
const badgeNYC= h('div', 'about-detail_badges-badge 1/2 1/3--desk grid__cell', iconNYC, 'Proud New Yoker')
18+
19+
const iconChinese = h('img', '')
20+
iconChinese.src = 'assets/img/chinese.png'
21+
const badgeChinese= h('div', 'about-detail_badges-badge 1/2 1/3--desk grid__cell', iconChinese, 'Made in China')
22+
23+
const iconUSMC = h('img', '')
24+
iconUSMC.src = 'assets/img/usmc.png'
25+
const badgeUSMC= h('div', 'about-detail_badges-badge 1/2 1/3--desk grid__cell', iconUSMC, 'Veteran Marines')
26+
27+
const badgeArea = h('div', 'about-detail_badges', badgeNYC, badgeChinese, badgeUSMC)
28+
29+
const photo = h('img', 'about-detail_photo')
30+
photo.src = 'assets/img/charlie.jpg'
31+
32+
return h('div', 'about-detail bg-dark',
33+
moveOnScrollOpacity(header('Little About Me', 'Personal Information', ''), {
34+
container
35+
}),
36+
moveOnScrollOpacity(h(
37+
'p', 'about-detail_intro',
38+
'Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem.'),
39+
{container}, 15
40+
),
41+
moveOnScrollOpacity(badgeArea, {container}, 15),
42+
photo
43+
);
44+
}

tasks/css.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const livereload = require('gulp-livereload');
55

66
module.exports = () => {
77
gulp.task( 'css', function () {
8-
return gulp.src( [ 'src/utils/normalize.css', 'src/css/**/*.css' ] )
8+
return gulp.src( [ 'src/utils/normalize.css', 'src/utils/avalanche.css', 'src/css/**/*.css' ] )
99
.pipe( concat('main.css') )
1010
.pipe( clean({ compatibility: 'ie8' }) )
1111
.pipe( gulp.dest('./public') )

0 commit comments

Comments
 (0)