Skip to content
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

Desafio finalizado - Fábio Henriques Viana Pinto #11

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist
node_modules
Empty file added images/.empty
Empty file.
Binary file added images/background.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8,700 changes: 8,700 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

35 changes: 35 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "webpack-config",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"dev": "webpack-dev-server --open --mode development --config webpack.config.js",
"build": "webpack --mode production"
},
"author": "",
"license": "ISC",
"devDependencies": {
"@babel/core": "^7.12.9",
"@fortawesome/fontawesome-free": "^5.14.0",
"@fortawesome/fontawesome-svg-core": "^1.2.32",
"@fortawesome/free-brands-svg-icons": "^5.15.1",
"@fortawesome/free-regular-svg-icons": "^5.15.1",
"babel-loader": "^8.2.1",
"babel-preset-es2015": "^6.24.1",
"copy-webpack-plugin": "^6.3.2",
"css-loader": "^5.0.1",
"file-loader": "^6.2.0",
"gm": "^1.23.1",
"html-webpack-plugin": "^4.5.0",
"sass": "^1.29.0",
"sass-loader": "^10.1.0",
"sass-to-string": "^1.1.0",
"style-loader": "^2.0.0",
"url-loader": "^4.1.1",
"webpack": "^4.44.2",
"webpack-cli": "^3.3.12",
"webpack-dev-server": "^3.11.0",
"webpack-images-resizer": "^0.1.2"
}
}
4 changes: 4 additions & 0 deletions src/_reset.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
* {
margin: 0 0;
padding: 0 0;
}
7 changes: 7 additions & 0 deletions src/_variables.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
$screen-large: 1024px;
$screen-medium: 768px;
$screen-small: 480px;
$primary-color: white;
$secondary-color: black;
$git-dark-gray: #666;
$git-light-gray: #bbb;
20 changes: 20 additions & 0 deletions src/app.global.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
@import "./_variables.scss";
@import "./_reset.scss";

.container {
margin: auto;
width: $screen-large;
overflow: hidden;
}

@media (max-width: $screen-medium) {
.container {
width: $screen-medium;
}
}

@media (max-width: $screen-small) {
.container {
width: $screen-small;
}
}
6 changes: 6 additions & 0 deletions src/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import "./routes/desafio/Desafio";
import "./routes/home/Home";
import "./routes/sobre/Sobre";
import "./components/navBar/NavBar";
import "./components/rodape/Rodape";
import "./app.global.scss";
37 changes: 37 additions & 0 deletions src/components/avatar/Avatar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { githubUrl, githubAvatarUrl } from "../../data/constants";
import styles from "./avatar.scss";

const templateElement = document.createElement("template");

function createStyle() {
const style = document.createElement("style");
style.textContent = styles;
return style;
}

function createTemplate() {
templateElement.innerHTML = `
<div>
<img src="${githubAvatarUrl}" alt="Avatar" />
<div>
<a href="${githubUrl}" target="_blank">VISITAR PERFIL</a>
</div>
</div>
`;
return templateElement.content.cloneNode(true);
}

class Avatar extends HTMLElement {
constructor() {
super();
const style = createStyle();
const template = createTemplate();

this.attachShadow({ mode: "open" });
this.shadowRoot.appendChild(style);
this.shadowRoot.appendChild(template);
}
}

customElements.define("c-avatar", Avatar);
export default Avatar;
21 changes: 21 additions & 0 deletions src/components/avatar/avatar.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
@import "../../_variables.scss";

div {
width: 100%;

div {
margin-top: 1em;
}

img {
width: 130px;
height: 130px;
border-radius: 100%;
}

a {
font-weight: bolder;
color: $git-dark-gray;
text-decoration: none;
}
}
43 changes: 43 additions & 0 deletions src/components/cartao/Cartao.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import "../avatar/Avatar";
import "../gitInfo/GitInfo";
import { getData } from "../../data/githubRepository";
import styles from "./cartao.scss";

const templateElement = document.createElement("template");

function createStyle() {
const style = document.createElement("style");
style.textContent = styles;
return style;
}

function createTemplate() {
templateElement.innerHTML = `
<div>
<c-avatar></c-avatar>
<c-git-info></c-git-info>
</div>
`;
return templateElement.content.cloneNode(true);
}

class Cartao extends HTMLElement {
constructor() {
super();
const style = createStyle();
const template = createTemplate();

this.attachShadow({ mode: "open" });
this.shadowRoot.appendChild(style);
this.shadowRoot.appendChild(template);
this.init();
}

async init() {
const gitInfo = this.shadowRoot.querySelector("c-git-info");
gitInfo.data = await getData();
}
}

customElements.define("c-cartao", Cartao);
export default Cartao;
8 changes: 8 additions & 0 deletions src/components/cartao/cartao.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
div {
background-color: white;
padding: 5% 5%;
text-align: center;
display: grid;
grid-template-columns: 160px auto;
justify-items: start;
}
43 changes: 43 additions & 0 deletions src/components/gitInfo/GitInfo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { githubUrl } from "../../data/constants";
import styles from "./gitInfo.scss";

const templateElement = document.createElement("template");

function createStyle() {
const style = document.createElement("style");
style.textContent = styles;
return style;
}

function createTemplate(repositorios, seguidores, seguindo) {
templateElement.innerHTML = `
<ul>
<li>Repositórios: <span>${repositorios.length}</span></li>
<li>Seguidores: <span>${seguidores.length}</span></li>
<li>Seguindo: <span>${seguindo.length}</span></li>
</ul>
<div>
<a href="${githubUrl}?tab=repositories" target="_blank" class="button btn-link-github">VER REPOSITÓRIOS</a>
<a href="${githubUrl}?tab=stars" target="_blank" class="button btn-link-github">VER FAVORITOS</a>
</div>
`;
return templateElement.content.cloneNode(true);
}

class GitInfo extends HTMLElement {
constructor() {
super();
const style = createStyle();

this.attachShadow({ mode: "open" });
this.shadowRoot.appendChild(style);
}

set data({ repositorios, seguidores, seguindo }) {
const template = createTemplate(repositorios, seguidores, seguindo);
this.shadowRoot.appendChild(template);
}
}

customElements.define("c-git-info", GitInfo);
export default GitInfo;
21 changes: 21 additions & 0 deletions src/components/gitInfo/gitInfo.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
@import "../../_variables.scss";

ul {
padding: 0 0;
list-style: none;
text-align: left;
line-height: 1.5em;
color: $git-dark-gray;
font-weight: bolder;
}

div {
margin-top: 50px;

a {
color: $git-light-gray;
border: 1px solid $git-light-gray;
padding: 10px 10px;
text-decoration: none;
}
}
48 changes: 48 additions & 0 deletions src/components/midiaSocial/MidiaSocial.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { icon } from "@fortawesome/fontawesome-svg-core";
import { faGithub, faLinkedin } from "@fortawesome/free-brands-svg-icons";
import { githubUrl, linkedinUrl } from "../../data/constants";
import styles from "./midiaSocial.scss";

const iconLinkedin = icon(faLinkedin);
const iconGithub = icon(faGithub);

const templateElement = document.createElement("template");

function createStyle() {
const style = document.createElement("style");
style.textContent = styles;
return style;
}

function createTemplate() {
templateElement.innerHTML = `
<ul>
<li>
<a href="${linkedinUrl}" target="_blank" class="link-linkedin">
${iconLinkedin.node[0].outerHTML}
</a>
</li>
<li>
<a href="${githubUrl}" target="_blank" class="link-github">
${iconGithub.node[0].outerHTML}
</a>
</li>
</ul>
`;
return templateElement.content.cloneNode(true);
}

class MidiaSocial extends HTMLElement {
constructor() {
super();
const style = createStyle();
const template = createTemplate();

this.attachShadow({ mode: "open" });
this.shadowRoot.appendChild(style);
this.shadowRoot.appendChild(template);
}
}

customElements.define("c-midia-social", MidiaSocial);
export default MidiaSocial;
21 changes: 21 additions & 0 deletions src/components/midiaSocial/midiaSocial.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
@import "../../_reset.scss";
@import "../../_variables.scss";

ul {
position: absolute;
text-align: center;
bottom: 0;
left: 50%;
transform: translate(-50%, -50%);
}

li {
list-style: none;
float: left;
margin: 0 1em;
}

svg {
width: 2em;
color: $primary-color;
}
50 changes: 50 additions & 0 deletions src/components/navBar/NavBar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import styles from "./navBar.scss";

const templateElement = document.createElement("template");

function createStyle() {
const style = document.createElement("style");
style.textContent = styles;
return style;
}

function createTemplate() {
templateElement.innerHTML = `
<nav>
<span class="brand">Fábio Henriques</span>
<a href="#home" class="btn-secao"> Home </a>
<a href="#sobre" class="btn-secao"> Sobre </a>
<a href="#desafio" class="btn-secao"> Desafio </a>
</nav>
`;
return templateElement.content.cloneNode(true);
}

class NavBar extends HTMLElement {
constructor() {
super();
const style = createStyle();
const template = createTemplate();

this.attachShadow({ mode: "open" });
this.shadowRoot.appendChild(style);
this.shadowRoot.appendChild(template);
this.addSmoothScrollOnClick();
}

addSmoothScrollOnClick() {
this.shadowRoot.querySelectorAll(".btn-secao").forEach((button) => {
button.addEventListener("click", function (e) {
e.preventDefault();
const href = this.getAttribute("href");

document.querySelector(href).scrollIntoView({
behavior: "smooth",
});
});
});
}
}

customElements.define("c-nav-bar", NavBar);
export default NavBar;
Loading