Skip to content

Commit

Permalink
metalinks
Browse files Browse the repository at this point in the history
  • Loading branch information
0xSero committed Feb 2, 2024
1 parent d21ab64 commit 63afbf8
Show file tree
Hide file tree
Showing 14 changed files with 1,484 additions and 163 deletions.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
NEXT_PUBLIC_METAGAME_GRAPHQL_API=https://api.metagame.wtf/v1/graphql
85 changes: 85 additions & 0 deletions app/[address]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
"use client"

import React from 'react';
import { useQuery } from "@apollo/client";
import { profileQuery } from "@/services/apollo";
import { toHTTP } from '@/utils/ipfs';
import { useParams } from 'next/navigation';
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"
import {
Menubar,
MenubarContent,
MenubarItem,
MenubarMenu,
MenubarSeparator,
MenubarShortcut,
MenubarTrigger,
} from "@/components/ui/menubar"

const Page: React.FC = () => {
// Get the address from the router params
const router = useParams();
const address = router.address as string;

// Fetch the profile data using Apollo useQuery hook
const { loading, error, data } = useQuery(profileQuery, {
variables: { address },
});

// Render loading state if data is still loading
if (loading) {
return <p>Loading...</p>;
}

// Render error message if user is not found
if (error || !data?.player[0]) {
return <p>Error: User not found</p>;
}
console.log(data?.player[0])
// Render the profile information
return (
<main>
<Menubar className='flex items-center justify-space-between height-10 w-full'>
<Avatar>
<AvatarImage src="https://i.imgur.com/tQfcTRL.png" />
<AvatarFallback>CN</AvatarFallback>
</Avatar>
<MenubarMenu>
<MenubarTrigger>File</MenubarTrigger>
<MenubarContent>
<MenubarItem>
New Tab <MenubarShortcut>⌘T</MenubarShortcut>
</MenubarItem>
<MenubarItem>New Window</MenubarItem>
<MenubarSeparator />
<MenubarItem>Share</MenubarItem>
<MenubarSeparator />
<MenubarItem>Print</MenubarItem>
</MenubarContent>
</MenubarMenu>
</Menubar>
<h1>MetaLink</h1>
<img
src={toHTTP(data?.player[0]?.profile.profileImageURL ?? '')}
alt="Picture of the author"
/>
<h2>{data?.player[0]?.profile?.name ?? ''}</h2>
<p>{data?.player[0]?.profile?.description ?? ''}</p>
<ul>
{data?.player[0]?.links.map((link: any, index: number) => (
<li key={index}>
<a href={link.url}>{link.name}</a>
</li>
))}
{data?.player[0]?.guilds.map((guild: any, index: number) => (
<li key={index}>
<img src={toHTTP(guild.Guild.logo)} style={{ height: '50px', width: '50px' }} />
<a href="">{guild.Guild.guildname}</a>
</li>
))}
</ul>
</main>
);
};

export default Page;
93 changes: 68 additions & 25 deletions app/globals.css
Original file line number Diff line number Diff line change
@@ -1,33 +1,76 @@
@tailwind base;
@tailwind components;
@tailwind utilities;

:root {
--foreground-rgb: 0, 0, 0;
--background-start-rgb: 214, 219, 220;
--background-end-rgb: 255, 255, 255;
}

@media (prefers-color-scheme: dark) {

@layer base {
:root {
--foreground-rgb: 255, 255, 255;
--background-start-rgb: 0, 0, 0;
--background-end-rgb: 0, 0, 0;
}
}
--background: 0 0% 100%;
--foreground: 224 71.4% 4.1%;

body {
color: rgb(var(--foreground-rgb));
background: linear-gradient(
to bottom,
transparent,
rgb(var(--background-end-rgb))
)
rgb(var(--background-start-rgb));
}
--card: 0 0% 100%;
--card-foreground: 224 71.4% 4.1%;

--popover: 0 0% 100%;
--popover-foreground: 224 71.4% 4.1%;

--primary: 220.9 39.3% 11%;
--primary-foreground: 210 20% 98%;

--secondary: 220 14.3% 95.9%;
--secondary-foreground: 220.9 39.3% 11%;

--muted: 220 14.3% 95.9%;
--muted-foreground: 220 8.9% 46.1%;

--accent: 220 14.3% 95.9%;
--accent-foreground: 220.9 39.3% 11%;

--destructive: 0 84.2% 60.2%;
--destructive-foreground: 210 20% 98%;

@layer utilities {
.text-balance {
text-wrap: balance;
--border: 220 13% 91%;
--input: 220 13% 91%;
--ring: 224 71.4% 4.1%;

--radius: 0.5rem;
}

.dark {
--background: 224 71.4% 4.1%;
--foreground: 210 20% 98%;

--card: 224 71.4% 4.1%;
--card-foreground: 210 20% 98%;

--popover: 224 71.4% 4.1%;
--popover-foreground: 210 20% 98%;

--primary: 210 20% 98%;
--primary-foreground: 220.9 39.3% 11%;

--secondary: 215 27.9% 16.9%;
--secondary-foreground: 210 20% 98%;

--muted: 215 27.9% 16.9%;
--muted-foreground: 217.9 10.6% 64.9%;

--accent: 215 27.9% 16.9%;
--accent-foreground: 210 20% 98%;

--destructive: 0 62.8% 30.6%;
--destructive-foreground: 210 20% 98%;

--border: 215 27.9% 16.9%;
--input: 215 27.9% 16.9%;
--ring: 216 12.2% 83.9%;
}
}

@layer base {
* {
@apply border-border;
}
body {
@apply bg-background text-foreground;
}
}
35 changes: 26 additions & 9 deletions app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import type { Metadata } from "next";
import { Inter } from "next/font/google";
import "./globals.css";
"use client"

const inter = Inter({ subsets: ["latin"] });
import { ThemeProvider } from "@/components/theme-provider"
import { Inter as FontSans } from "next/font/google";
import { client } from "@/services/apollo";
import { ApolloProvider } from '@apollo/client';
import { cn } from "@/lib/utils";
import "./globals.css";

export const metadata: Metadata = {
title: "Create Next App",
description: "Generated by create next app",
};
export const fontSans = FontSans({
subsets: ["latin"],
variable: "--font-sans",
})

export default function RootLayout({
children,
Expand All @@ -16,7 +19,21 @@ export default function RootLayout({
}>) {
return (
<html lang="en">
<body className={inter.className}>{children}</body>
<ApolloProvider client={client}>
<ThemeProvider
attribute="class"
defaultTheme="dark"
enableSystem
disableTransitionOnChange
>
<body className={
cn(
"min-h-screen bg-background font-sans antialiased",
fontSans.variable
)}
>{children}</body>
</ThemeProvider>
</ApolloProvider>
</html>
);
}
17 changes: 17 additions & 0 deletions components.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"$schema": "https://ui.shadcn.com/schema.json",
"style": "new-york",
"rsc": true,
"tsx": true,
"tailwind": {
"config": "tailwind.config.ts",
"css": "app/globals.css",
"baseColor": "gray",
"cssVariables": true,
"prefix": ""
},
"aliases": {
"components": "@/components",
"utils": "@/lib/utils"
}
}
9 changes: 9 additions & 0 deletions components/theme-provider.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
"use client"

import * as React from "react"
import { ThemeProvider as NextThemesProvider } from "next-themes"
import { type ThemeProviderProps } from "next-themes/dist/types"

export function ThemeProvider({ children, ...props }: ThemeProviderProps) {
return <NextThemesProvider {...props}>{children}</NextThemesProvider>
}
50 changes: 50 additions & 0 deletions components/ui/avatar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
"use client"

import * as React from "react"
import * as AvatarPrimitive from "@radix-ui/react-avatar"

import { cn } from "@/lib/utils"

const Avatar = React.forwardRef<
React.ElementRef<typeof AvatarPrimitive.Root>,
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Root>
>(({ className, ...props }, ref) => (
<AvatarPrimitive.Root
ref={ref}
className={cn(
"relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",
className
)}
{...props}
/>
))
Avatar.displayName = AvatarPrimitive.Root.displayName

const AvatarImage = React.forwardRef<
React.ElementRef<typeof AvatarPrimitive.Image>,
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Image>
>(({ className, ...props }, ref) => (
<AvatarPrimitive.Image
ref={ref}
className={cn("aspect-square h-full w-full", className)}
{...props}
/>
))
AvatarImage.displayName = AvatarPrimitive.Image.displayName

const AvatarFallback = React.forwardRef<
React.ElementRef<typeof AvatarPrimitive.Fallback>,
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Fallback>
>(({ className, ...props }, ref) => (
<AvatarPrimitive.Fallback
ref={ref}
className={cn(
"flex h-full w-full items-center justify-center rounded-full bg-muted",
className
)}
{...props}
/>
))
AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName

export { Avatar, AvatarImage, AvatarFallback }
Loading

0 comments on commit 63afbf8

Please sign in to comment.