Update layout drastically

This commit is contained in:
Sumire Isshiki 2024-02-12 13:53:54 +09:00
parent 505b5d094b
commit 8ae86b4856
11 changed files with 111 additions and 50 deletions

View File

@ -21,6 +21,7 @@
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-scroll-percentage": "^4.3.2",
"recoil": "^0.7.7",
"tailwindcss": "^3.4.1"
},
"devDependencies": {

View File

@ -1,18 +1,17 @@
import Card from "./components/Card"
import Profile from "./components/Profile"
import Links from "./components/Links"
import Keys from "./components/Keys"
import Activities from "./components/Activities"
import Footer from "./components/Footer"
import { RecoilRoot } from 'recoil'
import Mutuals from "./components/Mutuals"
import Spotify from "./components/Spotify"
import Services from "./components/Services"
import Card from "./components/Card"
import Menu from "./components/Menu"
import ContentRenderer from "./components/ContentRenderer"
import Footer from "./components/Footer"
import { useState, useEffect } from 'react';
export default function App() {
const [cardY, setCardY] = useState(0);
const [contentY, setContentY] = useState(0);
const [cardOpacity, setCardOpacity] = useState(1.0);
const handleScroll = () => {
@ -57,34 +56,34 @@ export default function App() {
}, []);
return (
<>
<div id="mutuals">
<Mutuals />
</div>
<div>
<div className={`sticky h-screen absolute`} style={{ opacity: cardOpacity, marginTop: `${document.getElementById("mutuals")?.offsetHeight}px` }}>
<div id="card" className="fixed bg-neutral-900 py-5 -mt-20" style={{ top: `${cardY}px` }}>
<Card />
</div>
<RecoilRoot>
<div id="mutuals">
<Mutuals />
</div>
<div className="flex justify-center">
<div id="content" className="absolute text-white max-w-6xl" style={{ top: `${contentY}px`}}>
<div className="grid grid-cols-1 xl:grid-cols-2 gap-4 mb-5 w-full">
<Profile />
<Links />
<Keys />
<Activities />
<Spotify />
<Services />
<div>
<div className={`sticky h-screen absolute`} style={{ opacity: cardOpacity, marginTop: `${document.getElementById("mutuals")?.offsetHeight}px` }}>
<div id="card" className="fixed bg-neutral-900 py-5 -mt-20" style={{ top: `${cardY}px` }}>
<Card />
</div>
</div>
<div className="mb-5" id="test">
<Footer />
<div className="flex justify-center">
<div id="content" className="absolute text-white" style={{ top: `${contentY}px`}}>
<div className="grid md:grid-cols-5 gap-2 min-h-[70vh] max-w-3xl">
<div className="hidden md:block">
<Menu />
</div>
<div className="w-full px-5 md:col-span-4 md:px-0">
<ContentRenderer />
</div>
</div>
<div className="mb-5" id="test">
<Footer />
</div>
</div>
</div>
</div>
</div>
</div>
</>
</RecoilRoot>
)
}

View File

@ -1,7 +1,7 @@
export default function Activities() {
return (
<>
<div className="p-5 rounded-lg max-w-2xl">
<div className="rounded-lg w-full">
<h1 className="text-2xl text-center">Recent activities</h1>
<div className="border border-white-500"></div>

View File

@ -0,0 +1,25 @@
import { useRecoilState } from 'recoil'
import Profile from "./Profile"
import Links from "./Links"
import Keys from "./Keys"
import Activities from "./Activities"
import Spotify from "./Spotify"
import Services from "./Services"
import { currentPage, Pages } from "./Menu"
export default function ContentRenderer() {
const [page, setPage] = useRecoilState(currentPage);
return (
<>
{ page === Pages.Profile && <><Profile /><Spotify /></> }
{ page === Pages.Links && <Links /> }
{ page === Pages.Keys && <Keys /> }
{ page === Pages.Activities && <Activities /> }
{ page === Pages.Services && <Services /> }
</>
)
}

View File

@ -1,8 +0,0 @@
export default function Header() {
return (
<h1 className="text-3xl font-bold underline">
Hello world!
</h1>
)
}

View File

@ -1,7 +1,7 @@
export default function Keys() {
return (
<>
<div className="p-5 rounded-lg max-w-2xl">
<div className="rounded-lg w-full">
<h1 className="text-2xl text-center">Public keys</h1>
<div className="border border-white-500"></div>

View File

@ -5,9 +5,7 @@ import { faAnglesRight } from '@fortawesome/free-solid-svg-icons'
export default function Links() {
return (
<>
<div className="p-5 rounded-lg max-w-2xl">
<h1 className="text-2xl text-center">Links</h1>
<div className="border border-white-500 mb-3"></div>
<div className="rounded-lg w-full">
<div className="gap-x-6 gap-y-8 flex flex-wrap">
<div className="w-24 h-16">
<a href="https://x.com/yude_jp">

46
src/components/Menu.tsx Normal file
View File

@ -0,0 +1,46 @@
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faUser, faStar} from '@fortawesome/free-regular-svg-icons'
import { faLink, faKey, faSquarePersonConfined } from '@fortawesome/free-solid-svg-icons'
import { RecoilRoot, atom, useRecoilState } from 'recoil'
export enum Pages {
Profile = 0,
Links = 1,
Keys = 2,
Activities = 3,
Spotify = 4,
Services = 5,
}
export const currentPage = atom({
key: 'page',
default: Pages.Profile,
})
export default function Menu() {
const [page, setPage] = useRecoilState(currentPage);
return (
<RecoilRoot>
<ul className="w-full text-lg font-medium">
<li className="w-full px-4 py-2" onClick={() => {setPage(Pages.Profile)}}>
<FontAwesomeIcon icon={faUser} />{" "}
</li>
<li className="w-full px-4 py-2" onClick={() => {setPage(Pages.Links)}}>
<FontAwesomeIcon icon={faLink} />{" "}
</li>
<li className="w-full px-4 py-2" onClick={() => {setPage(Pages.Keys)}}>
<FontAwesomeIcon icon={faKey} />{" "}
</li>
<li className="w-full px-4 py-2" onClick={() => {setPage(Pages.Activities)}}>
<FontAwesomeIcon icon={faSquarePersonConfined} />{" "}
</li>
<li className="w-full px-4 py-2" onClick={() => {setPage(Pages.Services)}}>
<FontAwesomeIcon icon={faStar} />{" "}
</li>
</ul>
</RecoilRoot>
)
}

View File

@ -4,7 +4,7 @@ import { faCake, faMapPin } from '@fortawesome/free-solid-svg-icons'
export default function Profile() {
return (
<>
<div className="p-5 rounded-lg max-w-2xl">
<div className="rounded-lg w-full">
<h1 className="text-2xl text-center">Profile</h1>
<div className="border border-white-500"></div>

View File

@ -1,12 +1,12 @@
export default function Services() {
return (
<>
<div className="p-5 rounded-lg max-w-2xl">
<div className="rounded-lg w-full">
<h1 className="text-2xl text-center">Active services</h1>
<div className="border border-white-500"></div>
<h2 className="text-xl font-semibold text-gray-200 mt-2 mb-1 ml-1">
Major public services
</h2>
<ul className="max-w-md space-y-1 ml-5 mt-3 list-disc list-inside text-gray-400">
<li>

View File

@ -1,7 +1,7 @@
export default function Spotify() {
return (
<>
<div className="p-5 rounded-lg max-w-2xl">
<div className="rounded-lg w-full">
<img alt="Spotify Recently Played" src="https://spotify-recently-played-readme.vercel.app/api?user=yude1119&amp;width=400" width="563" height="495" />
</div>
</>