Skip to content

Instantly share code, notes, and snippets.

@juunegreiros
Last active April 30, 2023 15:47
Show Gist options
  • Save juunegreiros/bbcd0de4af38bc37089e579ec74b0a9a to your computer and use it in GitHub Desktop.
Save juunegreiros/bbcd0de4af38bc37089e579ec74b0a9a to your computer and use it in GitHub Desktop.
Aula 1 - Imersão React 3
import React from 'react';
import styled, { css } from 'styled-components';
import NextLink from 'next/link';
const BASE_URL = 'http://alurakut.vercel.app/';
const v = '1';
function Link({ href, children, ...props }) {
return (
<NextLink href={href} passHref>
<a {...props}>
{children}
</a>
</NextLink>
)
}
// ================================================================================================================
// Menu
// ================================================================================================================
export function AlurakutMenu({ githubUser }) {
const [isMenuOpen, setMenuState] = React.useState(false);
return (
<AlurakutMenu.Wrapper isMenuOpen={isMenuOpen}>
<div className="container">
<AlurakutMenu.Logo src={`${BASE_URL}/logo.svg`} />
<nav style={{ flex: 1 }}>
{[{ name: 'Inicio', slug: '/'}, {name: 'Amigos', slug: '/amigos'}, {name: 'Comunidades', slug: '/comunidades'}].map((menuItem) => (
<Link key={`key__${menuItem.name.toLocaleLowerCase()}`} href={`${menuItem.slug.toLocaleLowerCase()}`}>
{menuItem.name}
</Link>
))}
</nav>
<nav>
<a href={`/logout`}>
Sair
</a>
<div>
<input placeholder="Pesquisar no Orkut" />
</div>
</nav>
<button onClick={() => setMenuState(!isMenuOpen)}>
{isMenuOpen && <img src={`${BASE_URL}/icons/menu-open.svg?v=${v}`} />}
{!isMenuOpen && <img src={`${BASE_URL}/icons/menu-closed.svg?v=${v}`} />}
</button>
</div>
<AlurakutMenuProfileSidebar githubUser={githubUser} />
</AlurakutMenu.Wrapper>
)
}
AlurakutMenu.Wrapper = styled.header`
width: 100%;
background-color: #308BC5;
.alurakutMenuProfileSidebar {
background: white;
position: fixed;
z-index: 100;
padding: 46px;
bottom: 0;
left: 0;
right: 0;
top: 48px;
transition: .3s;
pointer-events: ${({ isMenuOpen }) => isMenuOpen ? 'all' : 'none'};
opacity: ${({ isMenuOpen }) => isMenuOpen ? '1' : '0'};
transform: ${({ isMenuOpen }) => isMenuOpen ? 'translateY(0)' : 'translateY(calc(-100% - 48px))'};
@media(min-width: 860px) {
display: none;
}
> div {
max-width: 400px;
margin: auto;
}
a {
font-size: 18px;
}
.boxLink {
font-size: 18px;
color: #2E7BB4;
-webkit-text-decoration: none;
text-decoration: none;
font-weight: 800;
}
hr {
margin-top: 12px;
margin-bottom: 8px;
border-color: transparent;
border-bottom-color: #ECF2FA;
}
}
.container {
background-color: #308BC5;
padding: 7px 16px;
max-width: 1110px;
margin: auto;
display: flex;
justify-content: space-between;
position: relative;
z-index: 101;
@media(min-width: 860px) {
justify-content: flex-start;
}
button {
border: 0;
background: transparent;
align-self: center;
display: inline-block;
@media(min-width: 860px) {
display: none;
}
}
nav {
display: none;
@media(min-width: 860px) {
display: flex;
}
a {
font-size: 12px;
color: white;
padding: 10px 16px;
position: relative;
text-decoration: none;
&:after {
content: " ";
background-color: #5292C1;
display: block;
position: absolute;
width: 1px;
height: 12px;
margin: auto;
left: 0;
top: 0;
bottom: 0;
}
}
}
input {
color: #ffffff;
background: #5579A1;
padding: 10px 42px;
border: 0;
background-image: url(${`${BASE_URL}/icons/search.svg`});
background-position: 15px center;
background-repeat: no-repeat;
border-radius: 1000px;
font-size: 12px;
::placeholder {
color: #ffffff;
opacity: 1;
}
}
}
`;
AlurakutMenu.Logo = styled.img`
background-color: #ffffff;
padding: 9px 14px;
border-radius: 1000px;
height: 34px;
`;
function AlurakutMenuProfileSidebar({ githubUser }) {
return (
<div className="alurakutMenuProfileSidebar">
<div>
<img src={`https://github.com/${githubUser}.png`} style={{ borderRadius: '8px' }} />
<hr />
<p>
<a className="boxLink" href={`/user/${githubUser}`}>
@{githubUser}
</a>
</p>
<hr />
<AlurakutProfileSidebarMenuDefault />
</div>
</div>
)
}
// ================================================================================================================
// AlurakutProfileSidebarMenuDefault
// ================================================================================================================
export function AlurakutProfileSidebarMenuDefault() {
return (
<AlurakutProfileSidebarMenuDefault.Wrapper>
<nav>
<a href="/">
<img src={`${BASE_URL}/icons/user.svg`} />
Perfil
</a>
<a href="/">
<img src={`${BASE_URL}/icons/book.svg`} />
Recados
</a>
<a href="/">
<img src={`${BASE_URL}/icons/camera.svg`} />
Fotos
</a>
<a href="/">
<img src={`${BASE_URL}/icons/sun.svg`} />
Depoimentos
</a>
</nav>
<hr />
<nav>
<a href="/">
<img src={`${BASE_URL}/icons/plus.svg`} />
GitHub Trends
</a>
<a href="/logout">
<img src={`${BASE_URL}//icons/logout.svg`} />
Sair
</a>
</nav>
</AlurakutProfileSidebarMenuDefault.Wrapper>
)
}
AlurakutProfileSidebarMenuDefault.Wrapper = styled.div`
a {
font-size: 12px;
color: #2E7BB4;
margin-bottom: 16px;
display: flex;
align-items: center;
justify-content: flex-start;
text-decoration: none;
img {
width: 16px;
height: 16px;
margin-right: 5px;
}
}
`;
// ================================================================================================================
// OrkutNostalgicIconSet
// ================================================================================================================
export function OrkutNostalgicIconSet(props) {
return (
<OrkutNostalgicIconSet.List>
{[
{ name: 'Recados', slug: 'recados', icon: 'book' },
{ name: 'Fotos', slug: 'fotos', icon: 'camera' },
{ name: 'Videos', slug: 'videos', icon: 'video-camera' },
{ name: 'Fãs', slug: 'fas', icon: 'star' },
{ name: 'Mensagens', slug: 'mensagens', icon: 'email' },
].map(({ name, slug, icon }) => (
<li key={`orkut__icon_set__${slug}`}>
<span style={{ gridArea: 'title' }} className="OrkutNostalgicIconSet__title">
{name}
</span>
<span className="OrkutNostalgicIconSet__number" style={{ gridArea: 'number' }}>
<img key={`orkut__icon_set__${slug}_img`} className="OrkutNostalgicIconSet__iconSample" src={`https://alurakut.vercel.app/icons/${icon}.svg`} />
{props[slug] ? props[slug] : 0}
</span>
</li>
))}
{[
{ name: 'Confiável', slug: 'confiavel', icon: 'smile' },
{ name: 'Legal', slug: 'legal', icon: 'cool' },
{ name: 'Sexy', slug: 'sexy', icon: 'heart' },
].map(({ name, slug, icon }) => {
const total = props[slug] ? props[slug] : 2;
return (
<li key={`orkut__icon_set__${slug}`}>
<span className="OrkutNostalgicIconSet__title">
{name}
</span>
<span className="OrkutNostalgicIconSet__iconComplex" className="OrkutNostalgicIconSet__number" style={{ gridArea: 'number' }}>
{[0, 1, 2].map((_, index) => {
const isHeartActive = index <= (total - 1);
return <img key={`orkut__icon_set__${slug}_img_${index}`} src={`https://alurakut.vercel.app/icons/${icon}.svg`} style={{ marginRight: '2px', opacity: isHeartActive ? 1 : '0.5' }} />
})}
</span>
</li>
);
})}
</OrkutNostalgicIconSet.List>
)
}
OrkutNostalgicIconSet.List = styled.ul`
margin-top: 32px;
list-style: none;
display: flex;
justify-content: space-between;
flex-wrap: wrap;
li {
font-size: 12px;
color: #5A5A5A;
display: grid;
grid-template-areas:
"title title"
"number number";
&:not(:last-child) {
margin-right: 5px;
}
.OrkutNostalgicIconSet__title {
display: block;
font-style: italic;
}
.OrkutNostalgicIconSet__number {
min-width: 15px;
display: flex;
align-items: center;
justify-content: flex-start;
.OrkutNostalgicIconSet__iconSample {
margin-right: 7px;
}
}
}
`;
// ================================================================================================================
// Login Page
// ================================================================================================================
const AlurakutLoginScreen = css`
:root {
--backgroundPrimary: #D9E6F6;
--backgroundSecondary: #F1F9FE;
--backgroundTertiary: #FFFFFF;
--backgroundQuarternary: #BBCDE8;
--colorPrimary: #2E7BB4;
--colorSecondary: #388BB0;
--colorTertiary: #2F4A71;
--colorQuarternary: #D81D99;
--textPrimaryColor: #333333;
--textSecondaryColor: #FFFFFF;
--textTertiaryColor: #5A5A5A;
--textQuarternaryColor: #C5C6CA;
--commonRadius: 8px;
}
.loginScreen {
padding: 16px;
max-width: 1110px;
display: grid;
--gap: 12px;
--gutter: 16px;
grid-gap: var(--gap);
grid-template-areas:
"logoArea"
"formArea"
"footerArea";
@media(min-width: 860px) {
grid-template-columns: 2fr 1fr;
grid-template-areas:
"logoArea formArea"
"logoArea formArea"
"footerArea footerArea";
}
.logoArea {
grid-area: logoArea;
background-color: var(--backgroundTertiary);
border-radius: var(--commonRadius);
padding: var(--gutter);
text-align: center;
display: flex;
flex-direction: column;
flex-wrap: wrap;
justify-content: center;
align-items: center;
min-height: 263px;
@media(min-width: 860px) {
min-height: 368px;
}
p {
font-size: 12px;
line-height: 1.2;
&:not(:last-child) {
margin-bottom: 12px;
}
strong {
color: var(--colorQuarternary);
}
}
img {
max-height: 45px;
margin-bottom: 36px;
}
}
.formArea {
grid-area: formArea;
display: flex;
flex-wrap: wrap;
flex-direction: column;
.box {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
text-align: center;
padding: var(--gutter);
padding-left: 50px;
padding-right: 50px;
background-color: var(--backgroundSecondary);
border-radius: var(--commonRadius);
flex: 1;
&:not(:last-child) {
margin-bottom: var(--gap);
}
&:first-child {
min-height: 224px;
@media(min-width: 860px) {
min-height: 282px;
}
}
p {
font-size: 14px;
}
a {
text-decoration: none;
color: var(--colorPrimary);
}
input {
width: 100%;
display: block;
border: 1px solid var(--textQuarternaryColor);
padding: 12px;
background-color: var(--backgroundTertiary);
border-radius: var(--commonRadius);
margin-top: 24px;
margin-bottom: 16px;
}
button {
width: 100%;
display: block;
border: 0;
padding: 12px;
border-radius: var(--commonRadius);
background-color: var(--colorPrimary);
color: var(--textSecondaryColor);
}
}
}
.footerArea {
grid-area: footerArea;
background-color: var(--backgroundQuarternary);
border-radius: var(--commonRadius);
padding: 8px;
p {
font-size: 12px;
text-align: center;
a {
text-decoration: none;
color: var(--colorPrimary);
}
}
}
}
`;
// ================================================================================================================
// Reset Styles
// ================================================================================================================
export const AlurakutStyles = css`
*::-webkit-scrollbar {
width: 8px;
}
*::-webkit-scrollbar-track {
background: #f1f1f1;
}
*::-webkit-scrollbar-thumb {
background: #888;
border-radius: 10px;
}
*::-webkit-scrollbar-thumb:hover {
background: #555;
}
a,
button {
cursor: pointer;
transition: .3s;
outline: 0;
&:hover,
&:focus {
opacity: .8;
}
&:disabled {
cursor: not-allowed;
opacity: .5;
}
}
input {
transition: .3s;
outline: 0;
&:disabled {
cursor: not-allowed;
opacity: .5;
}
&:hover,
&:focus {
box-shadow: 0px 0px 5px #33333357;
}
}
${AlurakutLoginScreen}
`;
import styled from 'styled-components';
const Box = styled.div`
background: #FFFFFF;
border-radius: 8px;
padding: 16px;
/* CSS Pré-Pronto */
margin-bottom: 10px;
.boxLink {
font-size: 14px;
color: #2E7BB4;
text-decoration: none;
font-weight: 800;
}
.title {
font-size: 32px;
font-weight: 400;
margin-bottom: 20px;
}
.subTitle {
font-size: 18px;
font-weight: 400;
margin-bottom: 20px;
}
.smallTitle {
margin-bottom: 20px;
font-size: 16px;
font-weight: 700;
color: #333333;
margin-bottom: 20px;
}
hr {
margin-top: 12px;
margin-bottom: 8px;
border-color: transparent;
border-bottom-color: #ECF2FA;
}
input {
width: 100%;
background-color: #F4F4F4;
color: #333333;
border: 0;
padding: 14px 16px;
margin-bottom: 14px;
border-radius: 10000px;
::placeholder {
color: #333333;
opacity: 1;
}
}
button {
border: 0;
padding: 8px 12px;
color: #FFFFFF;
border-radius: 10000px;
background-color: #6F92BB;
}
`;
export default Box
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment