-
Notifications
You must be signed in to change notification settings - Fork 9
[Project1/최민석] Colors #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
## Colors | ||
|
||
### DEMO | ||
|
||
<img src="./Colors.gif" /> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
.main-container { | ||
background-color: white; | ||
width: 100%; | ||
height: 100vh; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
} | ||
|
||
.color-event-button { | ||
background-color: transparent; | ||
border: 1px solid black; | ||
color: black; | ||
border-radius: 5px; | ||
padding: 14px 12.5px; | ||
font-size: 20px; | ||
transition: all 0.15s; | ||
} | ||
|
||
.color-event-button:hover { | ||
background-color: black; | ||
color: white; | ||
padding: 15px 12.5px; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
/* http://meyerweb.com/eric/tools/css/reset/ | ||
v2.0 | 20110126 | ||
License: none (public domain) | ||
*/ | ||
|
||
html, | ||
body, | ||
div, | ||
span, | ||
applet, | ||
object, | ||
iframe, | ||
h1, | ||
h2, | ||
h3, | ||
h4, | ||
h5, | ||
h6, | ||
p, | ||
blockquote, | ||
pre, | ||
a, | ||
abbr, | ||
acronym, | ||
address, | ||
big, | ||
cite, | ||
code, | ||
del, | ||
dfn, | ||
em, | ||
img, | ||
ins, | ||
kbd, | ||
q, | ||
s, | ||
samp, | ||
small, | ||
strike, | ||
strong, | ||
sub, | ||
sup, | ||
tt, | ||
var, | ||
b, | ||
u, | ||
i, | ||
center, | ||
dl, | ||
dt, | ||
dd, | ||
ol, | ||
ul, | ||
li, | ||
fieldset, | ||
form, | ||
label, | ||
legend, | ||
table, | ||
caption, | ||
tbody, | ||
tfoot, | ||
thead, | ||
tr, | ||
th, | ||
td, | ||
article, | ||
aside, | ||
canvas, | ||
details, | ||
embed, | ||
figure, | ||
figcaption, | ||
footer, | ||
header, | ||
hgroup, | ||
menu, | ||
nav, | ||
output, | ||
ruby, | ||
section, | ||
summary, | ||
time, | ||
mark, | ||
audio, | ||
video { | ||
margin: 0; | ||
padding: 0; | ||
border: 0; | ||
font-size: 100%; | ||
font: inherit; | ||
vertical-align: baseline; | ||
} | ||
/* HTML5 display-role reset for older browsers */ | ||
article, | ||
aside, | ||
details, | ||
figcaption, | ||
figure, | ||
footer, | ||
header, | ||
hgroup, | ||
menu, | ||
nav, | ||
section { | ||
display: block; | ||
} | ||
body { | ||
line-height: 1; | ||
} | ||
ol, | ||
ul { | ||
list-style: none; | ||
} | ||
blockquote, | ||
q { | ||
quotes: none; | ||
} | ||
blockquote:before, | ||
blockquote:after, | ||
q:before, | ||
q:after { | ||
content: ""; | ||
content: none; | ||
} | ||
table { | ||
border-collapse: collapse; | ||
border-spacing: 0; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<link rel="stylesheet" href="./assets/reset.css" /> | ||
<link rel="stylesheet" href="./assets/index.css" /> | ||
<title>Document</title> | ||
</head> | ||
<body> | ||
<main id="App"></main> | ||
<script src="./src/main.js" type="module"></script> | ||
</body> | ||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import Button from "./Button.js"; | ||
|
||
const COLOR_LIST = [ | ||
"Orangered", | ||
"Blue", | ||
"Yellow", | ||
"Green", | ||
"Orange", | ||
"Cyan", | ||
"DodgerBlue", | ||
"Violet", | ||
"Navy", | ||
"Purple", | ||
"YellowGreen", | ||
"OrangeRed", | ||
"SlateBlue", | ||
"Salmon", | ||
"Crimson", | ||
"HotPink", | ||
"Magenta", | ||
]; | ||
|
||
export default function App({ $target }) { | ||
const $main = document.createElement("div"); | ||
$main.className = "main-container"; | ||
$target.appendChild($main); | ||
|
||
let ColorListIndex = 0; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 사소한 부분이지만 자바스크립트 변수 네이밍 컨벤션은 camelCase니까 |
||
|
||
new Button({ | ||
$target: $main, | ||
text: "Click Me!", | ||
onClick: () => { | ||
if (ColorListIndex > COLOR_LIST.length - 1) { | ||
ColorListIndex = 0; | ||
} | ||
Comment on lines
+34
to
+36
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 고양이 사진 검색기에서도 나왔던 패턴이군요! 저는 랜덤 컬러를 랜덤으로 만드는 것으로 구현했는데 민석님은 원본 프로젝트를 꼼꼼히 살펴보시고 정해진 패턴대로 움직인다는 것을 파악하셨네요 👍👍👍 |
||
$main.style.backgroundColor = COLOR_LIST[ColorListIndex++]; | ||
}, | ||
}); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export default function Button({ $target, text, onClick }) { | ||
const $button = document.createElement("button"); | ||
$button.className = "color-event-button"; | ||
$target.appendChild($button); | ||
$button.textContent = text; | ||
$button.addEventListener("click", (e) => { | ||
onClick(); | ||
}); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import App from "./components/App.js"; | ||
const $app = document.querySelector("#App"); | ||
Comment on lines
+1
to
+2
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. eslint에서는 import 라인 뒤에 new line을 넣도록 권장하고 있는데 한번 참고하시면 좋을 것 같습니다ㅎㅎ |
||
|
||
new App({ $target: $app }); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
## Colors | ||
|
||
### DEMO | ||
|
||
<img src="./hex-colors.gif" /> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
.main-container { | ||
background: linear-gradient(to right, #ffffff, #ffffff); | ||
width: 100%; | ||
height: 100vh; | ||
display: flex; | ||
flex-direction: column; | ||
text-align: center; | ||
justify-content: center; | ||
align-items: center; | ||
} | ||
|
||
.background-text { | ||
font-size: 45px; | ||
animation: 2s linear 1.5s infinite alternate colorChange; | ||
margin: 5vh; | ||
} | ||
|
||
.color-event-button { | ||
background-color: transparent; | ||
border: 1px solid black; | ||
color: black; | ||
border-radius: 5px; | ||
padding: 14px 12.5px; | ||
font-size: 20px; | ||
transition: all 0.15s; | ||
} | ||
|
||
.color-event-button:hover { | ||
background-color: black; | ||
color: white; | ||
padding: 15px 12.5px; | ||
} | ||
|
||
@keyframes colorChange { | ||
from { | ||
color: #000000; | ||
} | ||
to { | ||
color: #ffffff; | ||
} | ||
} | ||
Comment on lines
+34
to
+41
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 저는 setInterval로 구현했는데 역시 CSS잘알이셔서 애니메이션을 활용하셨군요!! 배워갑니다👍👍👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
전에 동영팀 스크럼때 reset.css 말씀해주셨던 것 같은데 이렇게 활용하는 거군요ㅎㅎ배워갑니다👍