Skip to content

Commit a369e65

Browse files
committed
finished notes
1 parent a257cf8 commit a369e65

File tree

5 files changed

+113
-12
lines changed

5 files changed

+113
-12
lines changed

README.MD

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ On the other hand, if animations are done right it will really make your site st
9191

9292
One way we can create animations is by using a `keyframe`.
9393

94+
### Keyframes
95+
9496
Keyframes are a great way that we can be specific when creating some sort of animation. we will use the `@` sign to declare a keyframe with a name to reference it as.
9597

9698
```css
@@ -102,20 +104,20 @@ Keyframes are a great way that we can be specific when creating some sort of ani
102104
There are multiple ways that we can apply styles using a key frame. The first is `from` and `to`. This is where we can define a set of style rules from the start to the finish.
103105

104106
```css
105-
@keyframes {
107+
@keyframes spin {
106108
from {
107109
transform: rotate(0deg);
108110
}
109111
to {
110-
transform: rotate(1080deg);
112+
transform: rotate(180deg);
111113
}
112114
}
113115
```
114116

115117
Then next way is using percentages inside of the animation, so we can be even more specific about how the animation will work.
116118

117119
```css
118-
@keyframes {
120+
@keyframes spin {
119121
0% {
120122
transform: rotate(0deg);
121123
}
@@ -194,4 +196,29 @@ export default class App extends Component {
194196
)
195197
}
196198
};
197-
```
199+
```
200+
201+
### Transitions
202+
203+
Transitions are another way we can animate our elements. This time, the animation will just be a simple transition that will allow us to create smooth transitions.
204+
205+
All we need to do is use the `transition` property on our css elements. We will just define how long we want to the transition to happen.
206+
207+
```css
208+
/* Transition Circle */
209+
.transition-circle {
210+
height: 50px;
211+
width: 50px;
212+
margin: 25px auto;
213+
background: salmon;
214+
/* transition property to change values */
215+
transition: .2s
216+
}
217+
218+
.transition-circle:hover {
219+
transform: scale(1.1);
220+
border-radius: 50%;
221+
}
222+
```
223+
224+
This will allow us to create simple animations on events such as a hover.

src/App.css

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,19 @@
8282
100% {
8383
transform: scale(1) rotate(-45deg);
8484
}
85+
}
86+
87+
/* Transition Circle */
88+
.transition-circle {
89+
height: 50px;
90+
width: 50px;
91+
margin: 25px auto;
92+
background: salmon;
93+
/* transition property to change values */
94+
transition: .2s
95+
}
96+
97+
.transition-circle:hover {
98+
transform: scale(1.1);
99+
border-radius: 50%;
85100
}

src/App.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export default class App extends Component {
2525

2626
render() {
2727
return (
28-
<div>
28+
<div className="app-container">
2929
{/* Navbar */}
3030
<Navbar />
3131

@@ -40,6 +40,9 @@ export default class App extends Component {
4040
{/* Beating Heart */}
4141
<div className="heart"></div>
4242

43+
{/* Transition Square to Circle */}
44+
<div className="transition-circle"></div>
45+
4346
</div>
4447
)
4548
}

src/components/Navbar/Navbar.css

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,34 @@
4040
margin: 0 5px;
4141
}
4242

43+
/* slide out menu */
44+
.menu {
45+
height: 100vh;
46+
width: 200px;
47+
background: #343A40;
48+
position: fixed;
49+
right: -200px;
50+
z-index: 10;
51+
transition: .3s;
52+
display: flex;
53+
flex-direction: column;
54+
justify-content: flex-start;
55+
align-items: center;
56+
}
57+
58+
.menu > a {
59+
margin-top: 15px;
60+
text-decoration: none;
61+
color: white;
62+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
63+
font-size: 16px;
64+
65+
}
66+
67+
.slide {
68+
right: 0px;
69+
}
70+
4371
/* Media Queries */
4472
@media (max-width: 900px) {
4573
/* get rid of links */

src/components/Navbar/Navbar.js

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,50 @@ import React, { Component } from 'react'
44
import './Navbar.css';
55

66
export default class Navbar extends Component {
7+
constructor(){
8+
super()
79

10+
this.state = {
11+
menu: false
12+
}
13+
}
14+
15+
slide = () => {
16+
this.setState({
17+
menu: !this.state.menu
18+
})
19+
}
820

921
render() {
1022
return (
11-
<nav className="navbar">
12-
<h1 className="navbar-title">Start Bootstrap</h1>
13-
<div className="navbar-icon">
14-
&#9776;
15-
</div>
16-
<div className="navbar-menu">
23+
<div>
24+
{/* Navbar */}
25+
<nav className="navbar">
26+
<h1 className="navbar-title">Start Bootstrap</h1>
27+
<div className="navbar-icon" onClick={this.slide}>
28+
&#9776;
29+
</div>
30+
<div className="navbar-menu">
31+
<a href="#">Home</a>
32+
<a href="#">About</a>
33+
<a href="#">Services</a>
34+
<a href="#">Contact</a>
35+
</div>
36+
</nav>
37+
38+
{/* Slide Out Menu */}
39+
<div className={
40+
this.state.menu ?
41+
'menu slide'
42+
:
43+
'menu'
44+
}>
1745
<a href="#">Home</a>
1846
<a href="#">About</a>
1947
<a href="#">Services</a>
2048
<a href="#">Contact</a>
2149
</div>
22-
</nav>
50+
</div>
2351
)
2452
}
2553
};

0 commit comments

Comments
 (0)