Skip to content

Commit

Permalink
feat: add disc buttons and refactor top menu style using grid
Browse files Browse the repository at this point in the history
  • Loading branch information
marianzburlea committed Oct 9, 2019
1 parent fb184c6 commit edea7b0
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 22 deletions.
15 changes: 15 additions & 0 deletions src/component/_dumb/disc/disc.component.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from 'react'
import { StyledDisc } from './disc.style'

const Disc = ({ title, image, color, onClick }) => {
return (
<StyledDisc
title={title}
color={color}
image={image}
onClick={onClick}
/>
)
}

export default Disc
28 changes: 28 additions & 0 deletions src/component/_dumb/disc/disc.style.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import styled from 'styled-components'

export const StyledDisc = styled.button`
width: 40px;
height: 40px;
border-radius: 50%;
overflow: hidden;
background-color: ${({ theme, color }) => theme.colorList[color || 'primary']};
margin-left: ${({ marginLeft }) => marginLeft};
position: relative;
cursor: pointer;
border: 0;
&::after {
content: '';
border-radius: 50%;
overflow: hidden;
position: absolute;
top: 2px;
left: 2px;
right: 2px;
bottom: 2px;
background-image: url('${({ image }) => image}');
background-size: cover;
background-position: center center;
}
`
1 change: 1 addition & 0 deletions src/component/_dumb/disc/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './disc.component'
1 change: 1 addition & 0 deletions src/component/_dumb/logo/logo.data.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion src/component/_dumb/logo/logo.styled.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import styled from 'styled-components'
import { logoBase64 } from './logo.data'

export const StyledLogo = styled.div`
width: 1.5rem;
height: 1.5rem;
margin-right: 0.5rem;
background-repeat: no-repeat;
background-image: url(data:image/svg+xml;base64,PHN2ZyBpZD0iTGF5ZXJfMSIgZGF0YS1uYW1lPSJMYXllciAxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdC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bnNsYXRlKC04Mi44NCAyMDAuMDEpIHJvdGF0ZSgtNDUpIi8+PC9zdmc+);
background-image: url(${logoBase64});
`
35 changes: 20 additions & 15 deletions src/component/top-menu/top-menu.component.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ import { StyledTopMenu, StyledLink, StyledButton, StyledLogoWrapper } from './to
import { WebInfoState } from '../web-info/web-info.context'
import { auth, GitHubProvider, db } from '../data/firebase'
import Avatar from '../avatar'
import Logo from '../_dumb/logo/logo.component'
import Logo from '../_dumb/logo'
import { navigate } from '@reach/router'
import Button from '../_dumb/button/button.component'
import ButtonGroup from '../_dumb/button-group/button-group.component'
import Button from '../_dumb/button'
import ButtonGroup from '../_dumb/button-group'
import Disc from '../_dumb/disc'
import { logoBase64 } from '../_dumb/logo/logo.data'
import HeaderTitle from '../_dumb/header-title/header-title.component'

const TopMenu = () => {
const { user, updateUser } = WebInfoState()
Expand Down Expand Up @@ -94,50 +97,52 @@ const TopMenu = () => {
};

const getLogInOutLabel = () => (user ? 'Logout' : 'Login');
const goHome = () => {
navigate('/')
console.log('go home');

}

return (
<StyledTopMenu>
<StyledLink to="/">
<StyledLogoWrapper title="The Web Developer Factory - Super Boost Your Career from Zero to Hired">
<Logo />
<span>CodeTap Academy</span>
</StyledLogoWrapper>
</StyledLink>
<Disc image={logoBase64} title="CodeTap" color="danger" onClick={goHome} />
<HeaderTitle
tag="h1"
title="CodeTap Academy - the Web Developer Factory"
text="CodeTap Academy - the Web Developer Factory"
link="/"
/>
{user && user.isAdmin && (
<ButtonGroup>
<Button
onClick={() => navigate('/dashboard')}
label="Dashboard"
marginLeft="1rem"
color="ok"
/>
<Button
onClick={() => navigate('/manage/user')}
label="Manage user"
marginLeft="1rem"
color="ok"
/>
</ButtonGroup>
)}
<Button
onClick={() => window.open('https://discord.gg/xcmtRYV')}
label="Chat"
marginLeft="1rem"
color="warning"
/>
<Button
onClick={() => navigate('/subscribe')}
label="Subscribe"
marginLeft="1rem"
color="danger"
/>
<Button
onClick={handleLogInAndOut}
label={getLogInOutLabel()}
marginLeft="1rem"
color="primary"
/>
<Avatar showUser={false} user={user} />

{user && <Disc image={user.photoURL} title={`${user.displayName} (${user.plan_id})`} />}
</StyledTopMenu>
);
};
Expand Down
11 changes: 5 additions & 6 deletions src/component/top-menu/top-menu.style.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ import { Link } from '@reach/router'
export const StyledLogoWrapper = styled.span`
display: flex;
align-items: center;
/*
&:hover {
color: black;
} */
`

export const StyledButton = styled.button`
Expand Down Expand Up @@ -46,8 +42,11 @@ export const StyledTopMenu = styled.div`
border-bottom: 2px solid #3D465E;
background-color: ${({ theme }) => theme.menu.background};
padding: 0 ${({ theme }) => theme.layout.bigPadding};
display: flex;
justify-content: space-between;
display: grid;
grid-template-rows: 1fr;
grid-template-columns: auto 1fr auto;
grid-gap: 0.5rem;
grid-auto-flow: column;
align-items: center;
position: fixed;
top: 0;
Expand Down

0 comments on commit edea7b0

Please sign in to comment.