Skip to content

Commit 5a3039e

Browse files
author
Roshan Jossy
committed
change badge design
1 parent 8148ee0 commit 5a3039e

File tree

10 files changed

+144
-26
lines changed

10 files changed

+144
-26
lines changed

src/components/UserDetails/Badges/Badge.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
11
import { graphql, useFragment } from "react-relay"
2-
import CircularProgress from './CircularProgress'
3-
import { DiAndroid } from '@react-icons/all-files/di/DiAndroid'
2+
import BadgeIcon from "./BadgeIcon"
3+
import Hexagon from "./Hexagon"
44

55
const Badge = ({badge}: any) => {
66
const data = useFragment(
77
graphql`
88
fragment Badge_node on Badge {
99
displayName
1010
progressPercentageToNextLevel
11+
currentLevel
1112
}
1213
`, badge
1314
)
1415

1516
return (
1617
<>
1718
<h4>{data.displayName}</h4>
18-
<DiAndroid className="w-10 h-10 text-green-600 "/>
19+
<Hexagon size={60} color="red" >
20+
<BadgeIcon displayName={data.displayName} />
21+
</Hexagon>
22+
{data.currentLevel}
1923
</>
2024
)
2125
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { SiC } from "@react-icons/all-files/si/SiC"
2+
import { SiGo } from "@react-icons/all-files/si/SiGo"
3+
import { SiPython } from "@react-icons/all-files/si/SiPython"
4+
import { SiCplusplus } from "@react-icons/all-files/si/SiCplusplus"
5+
import { SiJavascript } from "@react-icons/all-files/si/SiJavascript"
6+
import { SiTypescript } from "@react-icons/all-files/si/SiTypescript"
7+
import { SiJava } from "@react-icons/all-files/si/SiJava"
8+
import { SiRuby } from "@react-icons/all-files/si/SiRuby"
9+
import { SiRust } from "@react-icons/all-files/si/SiRust"
10+
import { SiGnubash } from "@react-icons/all-files/si/SiGnubash"
11+
import { SiPhp } from "@react-icons/all-files/si/SiPhp"
12+
import React from "react"
13+
14+
const iconMap = {
15+
"Go": <SiGo />,
16+
"Python": <SiPython />,
17+
"C": <SiC />,
18+
"C++": <SiCplusplus/>,
19+
"JavaScript": <SiJava/>,
20+
"TypeScript": <SiTypescript />,
21+
"Java": <SiJava />,
22+
"Ruby": <SiRuby />,
23+
"Rust": <SiRust />,
24+
"Unix Sell": <SiGnubash />,
25+
"PHP": <SiPhp />
26+
}
27+
export default function BadgeIcon ({displayName}) {
28+
return (
29+
<div className="text-3xl z-10 badge-icon">
30+
{iconMap[displayName]}
31+
<style>
32+
{`
33+
.badge-icon {
34+
color: #00000077;
35+
}
36+
`}
37+
</style>
38+
</div>
39+
)
40+
}

src/components/UserDetails/Badges/BadgeList.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const BadgeList = ({user}: any) => {
88
fragment BadgeList_user on User
99
@refetchable(queryName: "BadgeList_userQuery")
1010
@argumentDefinitions(
11-
count: {type: "Int", defaultValue: 2}
11+
count: {type: "Int", defaultValue: 5}
1212
cursor: {type: "String"}
1313
){
1414
badges(first:$count, after: $cursor)
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
export default function Hexagon ({children, size, color}) {
2+
return (
3+
4+
<div className="badge-icon-container">
5+
{children}
6+
<style jsx>
7+
{`
8+
.badge-icon-container {
9+
position: relative;
10+
width: ${size * 0.645}px;
11+
height: ${size}px;
12+
background-image: linear-gradient(90deg, #00ffb8, #13ce9a);
13+
border-radius: ${size / 10}px;
14+
display: flex;
15+
justify-content: center;
16+
align-items: center;
17+
}
18+
19+
.badge-icon-container:before,
20+
.badge-icon-container:after {
21+
content: '';
22+
display: block;
23+
position: absolute;
24+
top: 0;
25+
bottom: 0;
26+
left: 0;
27+
right: 0;
28+
width: inherit;
29+
height: inherit;
30+
border-radius: inherit;
31+
background-image: inherit;
32+
}
33+
34+
.badge-icon-container:before {
35+
transform: rotate(60deg);
36+
}
37+
38+
.badge-icon-container:after {
39+
transform: rotate(-60deg);
40+
}
41+
`}
42+
</style>
43+
</div>
44+
)
45+
}

src/components/UserDetails/UserDetails.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const UserDetails = ({user}: Props)=> {
3636
@{data.handle}
3737
</h1>
3838
<Bio user={data}/>
39-
<div className="my-4">
39+
<div className="my-4 flex space-x-4">
4040
<span className="font-bold mb-2 flex">
4141
<span className="text-2xl mr-2">
4242
<GoIssueOpened />

src/queries/__generated__/BadgeList_user.graphql.ts

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/queries/__generated__/BadgeList_userQuery.graphql.ts

Lines changed: 12 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/queries/__generated__/Badge_node.graphql.ts

Lines changed: 10 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/queries/__generated__/BioUpdateMutation.graphql.ts

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/queries/__generated__/pages_UserQuery.graphql.ts

Lines changed: 23 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)