From 72567fef840b386df66c1982e5996ef90e151004 Mon Sep 17 00:00:00 2001 From: jakubmanczak Date: Thu, 29 Dec 2022 17:21:34 +0100 Subject: [PATCH] /ja progress --- .../ProfileCard/ProfileCard.module.scss | 102 ++++++++++++++++ components/ProfileCard/ProfileCard.tsx | 113 ++++++++++++++++++ pages/ja.tsx | 49 +++++++- styles/Ja.module.scss | 14 --- 4 files changed, 258 insertions(+), 20 deletions(-) create mode 100644 components/ProfileCard/ProfileCard.module.scss create mode 100644 components/ProfileCard/ProfileCard.tsx delete mode 100644 styles/Ja.module.scss diff --git a/components/ProfileCard/ProfileCard.module.scss b/components/ProfileCard/ProfileCard.module.scss new file mode 100644 index 0000000..2f5083f --- /dev/null +++ b/components/ProfileCard/ProfileCard.module.scss @@ -0,0 +1,102 @@ +.profile { + margin: 2rem 0; + background: var(--black1); + border-radius: 8px; + box-shadow: var(--shadow0); + article { + display: flex; + flex-direction: row; + padding: 1.5rem 1.5rem 1rem 1.5rem; + gap: 1rem; + background-color: var(--black2); + border-radius: 8px 8px 0 0; + @media screen and (max-width: 400px) { + flex-direction: column; + justify-content: center; + } + img { + border-radius: 50%; + height: 128px; + width: 128px; + @media screen and (max-width: 600px) { + height: 64px; + width: 64px; + } + } + .inner { + width: 100%; + header { + display: flex; + flex-direction: row; + align-items: baseline; + justify-content: space-between; + width: 100%; + h1 { + font-size: 2rem; + } + p { + font-family: var(--fonts-bold); + span { + font-size: 2rem; + } + } + } + .badges { + display: flex; + flex-direction: row; + gap: 1rem; + margin: 8px 0; + .badge { + display: flex; + flex-direction: row; + align-items: center; + width: initial; + gap: 8px; + padding: 4px 8px; + background: rgba(white, 0.1); + border-radius: 4px; + .dot { + width: 16px; + height: 16px; + border-radius: 50%; + background-color: #fb636b; + } + } + } + } + } + .xpinfo { + display: flex; + flex-direction: row; + justify-content: space-between; + background: var(--black2); + color: #ababab; + padding: 0 14px; + } + .xpbar { + display: block; + width: 100%; + height: 10px; + background: rgba(white, 0.025); + .xpinner { + display: block; + height: 100%; + width: 99%; + background: #fb636b; + opacity: 75%; + } + } + footer { + min-height: 16px; + display: flex; + flex-direction: row; + flex-wrap: wrap; + section { + width: 50%; + padding: 2rem; + @media screen and (max-width: 800px) { + width: 100%; + } + } + } +} diff --git a/components/ProfileCard/ProfileCard.tsx b/components/ProfileCard/ProfileCard.tsx new file mode 100644 index 0000000..626886e --- /dev/null +++ b/components/ProfileCard/ProfileCard.tsx @@ -0,0 +1,113 @@ +import styles from "./ProfileCard.module.scss"; + +type UserProfileCardProps = { + username: string; + description?: string; + picture?: string | null; + isAdmin?: boolean; + isDeveloper?: boolean; + experience?: { + level: number; + tilNextLevel?: number; + looseXP?: number; + }; + badges?: { + badgeName: string; + badgeDesc?: string; + badgeMerit?: string; + badgeImage?: string; + }[]; + accentColor?: string; +}; + +let placeholderPicture = "https://placewaifu.com/image/128?greyscale&blur"; + +const ProfileCard = (user: UserProfileCardProps) => { + return ( + <> +
+
+ {user.username} +
+
+

{user.username}

+

+ {user.experience?.level && ( + <> + {"LVL "} + {user.experience.level} + + )} +

+
+

{user.description}

+
+ {user.isAdmin && ( +
+
+ Admin +
+ )} + {user.isDeveloper && ( +
+
+ DEV +
+ )} +
+
+
+ {user.experience?.looseXP && user.experience.tilNextLevel && ( +
+

XP: {user.experience.looseXP}

+

XP until next level: {user.experience.tilNextLevel}

+
+ )} + {user.experience?.looseXP && user.experience.tilNextLevel && ( +
+
+
+ )} +
+ {user.badges + ?.slice(0, 1) + .map( + (el: { + badgeName: string; + badgeDesc?: string; + badgeMerit?: string; + badgeImage?: string; + }) => { + return ( +
+

{el.badgeName}

+

{el.badgeDesc}

+
+ ); + } + )} +
+
+ + ); +}; + +export { ProfileCard }; diff --git a/pages/ja.tsx b/pages/ja.tsx index 2bf12b9..7265b81 100644 --- a/pages/ja.tsx +++ b/pages/ja.tsx @@ -1,8 +1,9 @@ -import styles from "../styles/Ja.module.scss"; import { useUser } from "@auth0/nextjs-auth0/client"; +import { ProfileCard } from "../components/ProfileCard/ProfileCard"; const PageMe = () => { const { user, error, isLoading } = useUser(); + return ( <> {isLoading && ( @@ -14,15 +15,51 @@ const PageMe = () => { {error && (

Wystąpił błąd.

-

Tyle wiemy.

+

Tyle wiemy:

+

{error.name}

+

{error.message}

)} {!isLoading && !error && user && (
-
- {`${user.name}'s -

{user.name}

-
+
)} {!isLoading && !user && ( diff --git a/styles/Ja.module.scss b/styles/Ja.module.scss deleted file mode 100644 index fad7f83..0000000 --- a/styles/Ja.module.scss +++ /dev/null @@ -1,14 +0,0 @@ -.header { - margin: 2rem 0; - display: flex; - flex-direction: row; - align-items: center; - gap: 1rem; - img { - height: 69px; - border-radius: 50%; - } - h1 { - font-size: 2rem; - } -}