diff --git a/.env.example b/.env.example index f23bbc6..2e5758e 100644 --- a/.env.example +++ b/.env.example @@ -13,3 +13,6 @@ BETTER_AUTH_URL=http://localhost:3000 # Local email previews do not need these values. RESEND_API_KEY= RESEND_FROM_EMAIL= + +# reccomended as 5000 reqs can be sent per hour +GITHUB_TOKEN= diff --git a/README.md b/README.md index b6db4a5..9dbd4c5 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ pnpm install pnpm dev ``` -Open http://localhost:3000. No environment variables or separate service are required for the existing site. +Open http://localhost:3000. No environment variables or separate service are required for the existing site; an optional `GITHUB_TOKEN` raises the GitHub API limit for the home page statistics. Development and production builds use Turbopack. diff --git a/WEBSITE_CONFIG.md b/WEBSITE_CONFIG.md index f5ca17a..07c29b6 100644 --- a/WEBSITE_CONFIG.md +++ b/WEBSITE_CONFIG.md @@ -2,6 +2,12 @@ All source, public assets, and configuration are at the repository root. Run `pnpm dev` from this directory. No environment variables are needed for the existing site. Future server features can read private values from `.env.local`; never prefix secrets with `NEXT_PUBLIC_`. +## Home page + +The home page is a bento grid (`app/page.tsx`, laid out by the `.bento` rules in `styles/globals.css`). Its statistics, language breakdown, and commit calendar come from the public GitHub API for the [Manipal-OSF](https://github.com/Manipal-OSF) organization (`lib/github.ts`). Responses are cached for a day and the page re-renders hourly; if GitHub is unreachable, those cells say so instead of failing the page. Unauthenticated requests are limited to 60 an hour, so set `GITHUB_TOKEN` in `.env.local` or the hosting environment if builds or previews run often. A fine-grained token without any permissions is enough. + +The map uses [MapLibre](https://maplibre.org/) with [OpenFreeMap](https://openfreemap.org/) tiles; edit `regions` in `components/home/KarnatakaMap.tsx` to change the places in its menu. + ## Write a blog post Create `content/posts/your-post.md`: diff --git a/app/blog/[uid]/page.tsx b/app/blog/[uid]/page.tsx index 5d1f0f0..34fd0a7 100644 --- a/app/blog/[uid]/page.tsx +++ b/app/blog/[uid]/page.tsx @@ -5,10 +5,8 @@ import CoverImage from '@/components/blog/CoverImage'; import MarkdownRenderer from '@/components/blog/MarkdownRenderer'; import PostHeader from '@/components/blog/PostHeader'; import PostNavigation from '@/components/blog/PostNavigation'; -import { - TableOfContentsDropdown, - TableOfContentsSidebar, -} from '@/components/blog/TableOfContents'; +import MobileTableOfContents from '@/components/blog/MobileTableOfContents'; +import { TableOfContentsSidebar } from '@/components/blog/TableOfContents'; import Breadcrumbs from '@/components/common/Breadcrumbs'; import Container from '@/components/common/Container'; import { resolveAuthors } from '@/lib/content/authors'; @@ -79,16 +77,15 @@ export default async function PostPage({ params }: PostPageProps) { preload className='mx-auto aspect-[1200/630] w-full max-w-5xl rounded-xl' /> - + -
- diff --git a/app/blog/page.tsx b/app/blog/page.tsx index 85a2f2a..5f363e4 100644 --- a/app/blog/page.tsx +++ b/app/blog/page.tsx @@ -2,7 +2,6 @@ import type { Metadata } from 'next'; import PostList from '@/components/blog/PostList'; import Breadcrumbs from '@/components/common/Breadcrumbs'; import Container from '@/components/common/Container'; -import Link from '@/components/common/TransitionLink'; import { getPublishedPosts } from '@/lib/content/posts'; export const metadata: Metadata = { title: 'Blog' }; @@ -16,16 +15,7 @@ export default async function BlogPage() { return ( -
- - - Authors - -
+ {posts.length === 0 ? (

No posts yet.

) : ( diff --git a/app/page.tsx b/app/page.tsx index da6bcc0..2a4fd4c 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -1,12 +1,196 @@ -import { siteName } from '@/lib/site'; +import { BookMarked, GitFork, Star, Users, UsersRound } from 'lucide-react'; +import type { ReactNode } from 'react'; +import BrandIcon from '@/components/common/BrandIcon'; +import Link from '@/components/common/TransitionLink'; +import CoverImage from '@/components/blog/CoverImage'; +import ActivityCard from '@/components/home/ActivityCard'; +import BentoCell from '@/components/home/BentoCell'; +import KarnatakaMap from '@/components/home/KarnatakaMap'; +import LanguagesCard from '@/components/home/LanguagesCard'; +import LinkCell from '@/components/home/LinkCell'; +import Logo from '@/components/layout/Logo'; +import { getPublishedPosts } from '@/lib/content/posts'; +import { formatDate } from '@/lib/format'; +import { getOrgStats, githubOrg } from '@/lib/github'; +import { siteName, socialLinks } from '@/lib/site'; + +// Re-render hourly; GitHub responses themselves are cached for a day. +export const revalidate = 3600; + +const href = (label: (typeof socialLinks)[number]['label']) => + socialLinks.find((link) => link.label === label)!.href; + +const Stat = ({ + icon, + value, + label, +}: { + icon: ReactNode; + value: number; + label: string; +}) => ( +
+
+ {icon} + {label} +
+
{value}
+
+); + +const Unavailable = ({ children }: { children: ReactNode }) => ( +

+ {children} +

+); + +export default async function HomePage() { + const [stats, posts] = await Promise.all([ + getOrgStats(), + getPublishedPosts(), + ]); + const latest = posts[0]; -export default function HomePage() { return ( -
-

- Experience -

-

{siteName}

+
+ +

+ Hello, We are {siteName} +

+

+ An open-source initiative led by the students of MIT for democratizing + free software & material +

+
+ + + + + + + {stats ? ( +
+

+ All time stats +

+
+ } value={stats.repos} label='repos' /> + } value={stats.stars} label='stars' /> + } value={stats.forks} label='forks' /> + } + value={stats.followers} + label='followers' + /> +
+
+ ) : ( + + GitHub statistics are unavailable right now. + + )} +
+ + + + +
+ + Latest post + +

+ {latest?.title ?? 'Read our blog'} +

+ {latest && ( +

+ {formatDate(latest.publishDate)} ยท {latest.readingTime} +

+ )} +
+ +
+ + + + + + + {stats?.languages.length ? ( + + ) : ( + + Language statistics are unavailable right now. + + )} + + + + {stats ? ( + + ) : ( + Commit activity is unavailable right now. + )} + + + } + title='GitHub' + detail={`@${githubOrg}`} + note='Star a repo!' + /> + } + title='Discord' + detail='Join the server' + note='Come say hi!' + /> + } + title='MS Teams' + detail='Join the channel' + /> + } + title='Our team' + detail='Meet the people behind OSF' + />
); } diff --git a/components/blog/MarkdownRenderer.tsx b/components/blog/MarkdownRenderer.tsx index 31c693e..773b83b 100644 --- a/components/blog/MarkdownRenderer.tsx +++ b/components/blog/MarkdownRenderer.tsx @@ -4,7 +4,7 @@ import rehypeSlug from 'rehype-slug'; export default function MarkdownRenderer({ content }: { content: string }) { return ( -
+
{content} diff --git a/components/blog/MobileTableOfContents.tsx b/components/blog/MobileTableOfContents.tsx new file mode 100644 index 0000000..fadcd29 --- /dev/null +++ b/components/blog/MobileTableOfContents.tsx @@ -0,0 +1,88 @@ +'use client'; + +import { ChevronDown } from 'lucide-react'; +import { useRef } from 'react'; +import { useScrollProgress } from '@/hooks/use-scroll-progress'; +import { useVisibleSections } from '@/hooks/use-visible-sections'; +import { cn } from '@/lib/utils'; +import type { PostHeading } from '@/types/blog'; +import HeadingList from './HeadingList'; + +const RADIUS = 10; +const CIRCUMFERENCE = 2 * Math.PI * RADIUS; + +interface MobileTableOfContentsProps { + headings: PostHeading[]; + className?: string; +} + +// Sticky bar under the header for narrow screens: shows the section being read +// and a ring that fills as the reader works through the post. +const MobileTableOfContents = ({ + headings, + className, +}: MobileTableOfContentsProps) => { + const details = useRef(null); + const visible = useVisibleSections(headings.map((heading) => heading.slug)); + const progress = useScrollProgress(); + + if (headings.length === 0) return null; + + const current = + headings + .filter((heading) => visible.includes(heading.slug)) + .map((heading) => heading.text) + .join(', ') || 'Overview'; + + return ( +
{ + if ((event.target as HTMLElement).closest('a') && details.current) + details.current.open = false; + }} + className={cn( + 'group bg-background/80 sticky top-14 z-40 -mx-4 border-b px-4 py-3 backdrop-blur-sm sm:mx-0 sm:rounded-xl sm:border', + className + )} + > + + + + + + {current} + + +
+ +
+
+ ); +}; + +export default MobileTableOfContents; diff --git a/components/blog/TableOfContents.tsx b/components/blog/TableOfContents.tsx index bc11855..ebeba3c 100644 --- a/components/blog/TableOfContents.tsx +++ b/components/blog/TableOfContents.tsx @@ -1,4 +1,3 @@ -import { ChevronRight } from 'lucide-react'; import { cn } from '@/lib/utils'; import type { PostHeading } from '@/types/blog'; import HeadingList from './HeadingList'; @@ -8,9 +7,8 @@ interface TableOfContentsProps { className?: string; } -// Server-rendered wrappers; only HeadingList runs on the client. -// Sticky sidebar for wide screens. - +// Server-rendered sticky sidebar for wide screens; only HeadingList runs on the client. +// Narrow screens use MobileTableOfContents instead. export const TableOfContentsSidebar = ({ headings, className, @@ -29,20 +27,3 @@ export const TableOfContentsSidebar = ({ ) : null; - -// Collapsible box for narrow screens. -export const TableOfContentsDropdown = ({ - headings, - className, -}: TableOfContentsProps) => - headings.length > 0 ? ( -
- - - Table of Contents - -
- -
-
- ) : null; diff --git a/components/common/BrandIcon.tsx b/components/common/BrandIcon.tsx new file mode 100644 index 0000000..14445a0 --- /dev/null +++ b/components/common/BrandIcon.tsx @@ -0,0 +1,27 @@ +import type { SVGProps } from 'react'; +import type { socialLinks } from '@/lib/site'; + +type Brand = (typeof socialLinks)[number]['label']; + +const brandPaths: Record = { + Instagram: + 'M7.0301.084c-1.2768.0602-2.1487.264-2.911.5634-.7888.3075-1.4575.72-2.1228 1.3877-.6652.6677-1.075 1.3368-1.3802 2.127-.2954.7638-.4956 1.6365-.552 2.914-.0564 1.2775-.0689 1.6882-.0626 4.947.0062 3.2586.0206 3.6671.0825 4.9473.061 1.2765.264 2.1482.5635 2.9107.308.7889.72 1.4573 1.388 2.1228.6679.6655 1.3365 1.0743 2.1285 1.38.7632.295 1.6361.4961 2.9134.552 1.2773.056 1.6884.069 4.9462.0627 3.2578-.0062 3.668-.0207 4.9478-.0814 1.28-.0607 2.147-.2652 2.9098-.5633.7889-.3086 1.4578-.72 2.1228-1.3881.665-.6682 1.0745-1.3378 1.3795-2.1284.2957-.7632.4966-1.636.552-2.9124.056-1.2809.0692-1.6898.063-4.948-.0063-3.2583-.021-3.6668-.0817-4.9465-.0607-1.2797-.264-2.1487-.5633-2.9117-.3084-.7889-.72-1.4568-1.3876-2.1228C21.2982 1.33 20.628.9208 19.8378.6165 19.074.321 18.2017.1197 16.9244.0645 15.6471.0093 15.236-.005 11.977.0014 8.718.0076 8.31.0215 7.0301.0839m.1402 21.6932c-1.17-.0509-1.8053-.2453-2.2287-.408-.5606-.216-.96-.4771-1.3819-.895-.422-.4178-.6811-.8186-.9-1.378-.1644-.4234-.3624-1.058-.4171-2.228-.0595-1.2645-.072-1.6442-.079-4.848-.007-3.2037.0053-3.583.0607-4.848.05-1.169.2456-1.805.408-2.2282.216-.5613.4762-.96.895-1.3816.4188-.4217.8184-.6814 1.3783-.9003.423-.1651 1.0575-.3614 2.227-.4171 1.2655-.06 1.6447-.072 4.848-.079 3.2033-.007 3.5835.005 4.8495.0608 1.169.0508 1.8053.2445 2.228.408.5608.216.96.4754 1.3816.895.4217.4194.6816.8176.9005 1.3787.1653.4217.3617 1.056.4169 2.2263.0602 1.2655.0739 1.645.0796 4.848.0058 3.203-.0055 3.5834-.061 4.848-.051 1.17-.245 1.8055-.408 2.2294-.216.5604-.4763.96-.8954 1.3814-.419.4215-.8181.6811-1.3783.9-.4224.1649-1.0577.3617-2.2262.4174-1.2656.0595-1.6448.072-4.8493.079-3.2045.007-3.5825-.006-4.848-.0608M16.953 5.5864A1.44 1.44 0 1 0 18.39 4.144a1.44 1.44 0 0 0-1.437 1.4424M5.8385 12.012c.0067 3.4032 2.7706 6.1557 6.173 6.1493 3.4026-.0065 6.157-2.7701 6.1506-6.1733-.0065-3.4032-2.771-6.1565-6.174-6.1498-3.403.0067-6.156 2.771-6.1496 6.1738M8 12.0077a4 4 0 1 1 4.008 3.9921A3.9996 3.9996 0 0 1 8 12.0077', + GitHub: + 'M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12', + Discord: + 'M20.317 4.3698a19.7913 19.7913 0 00-4.8851-1.5152.0741.0741 0 00-.0785.0371c-.211.3753-.4447.8648-.6083 1.2495-1.8447-.2762-3.68-.2762-5.4868 0-.1636-.3933-.4058-.8742-.6177-1.2495a.077.077 0 00-.0785-.037 19.7363 19.7363 0 00-4.8852 1.515.0699.0699 0 00-.0321.0277C.5334 9.0458-.319 13.5799.0992 18.0578a.0824.0824 0 00.0312.0561c2.0528 1.5076 4.0413 2.4228 5.9929 3.0294a.0777.0777 0 00.0842-.0276c.4616-.6304.8731-1.2952 1.226-1.9942a.076.076 0 00-.0416-.1057c-.6528-.2476-1.2743-.5495-1.8722-.8923a.077.077 0 01-.0076-.1277c.1258-.0943.2517-.1923.3718-.2914a.0743.0743 0 01.0776-.0105c3.9278 1.7933 8.18 1.7933 12.0614 0a.0739.0739 0 01.0785.0095c.1202.099.246.1981.3728.2924a.077.077 0 01-.0066.1276 12.2986 12.2986 0 01-1.873.8914.0766.0766 0 00-.0407.1067c.3604.698.7719 1.3628 1.225 1.9932a.076.076 0 00.0842.0286c1.961-.6067 3.9495-1.5219 6.0023-3.0294a.077.077 0 00.0313-.0552c.5004-5.177-.8382-9.6739-3.5485-13.6604a.061.061 0 00-.0312-.0286zM8.02 15.3312c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9555-2.4189 2.157-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.9555 2.4189-2.1569 2.4189zm7.9748 0c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9554-2.4189 2.1569-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.946 2.4189-2.1568 2.4189Z', + 'MS Teams': + 'M3 5h10a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2Zm1 3v2h3v6h2v-6h3V8ZM19 3.5a2.5 2.5 0 1 1 0 5 2.5 2.5 0 0 1 0-5ZM16 10h6a1 1 0 0 1 1 1v4.5a3.5 3.5 0 0 1-3.5 3.5H16Z', +}; + +// Simple Icons brand marks for the social links; they inherit the text color. +const BrandIcon = ({ + brand, + ...props +}: { brand: Brand } & SVGProps) => ( + +); + +export default BrandIcon; diff --git a/components/home/ActivityCard.tsx b/components/home/ActivityCard.tsx new file mode 100644 index 0000000..978343a --- /dev/null +++ b/components/home/ActivityCard.tsx @@ -0,0 +1,75 @@ +import type { CSSProperties } from 'react'; +import { ACTIVITY_WEEKS, type OrgStats } from '@/lib/github'; +import { cn } from '@/lib/utils'; + +interface ActivityCardProps { + activity: OrgStats['activity']; + totalCommits: number; +} + +const formatDay = (date: string) => + new Intl.DateTimeFormat('en-US', { + month: 'short', + day: 'numeric', + timeZone: 'UTC', + }).format(new Date(`${date}T00:00:00Z`)); + +const level = (count: number) => + count === 0 ? 0 : count < 3 ? 1 : count < 6 ? 2 : count < 10 ? 3 : 4; +const opacity = [0, 0.3, 0.55, 0.8, 1]; + +const NARROW_WEEKS = 16; +const hiddenWhenNarrow = (ACTIVITY_WEEKS - NARROW_WEEKS) * 7; + +const ActivityCard = ({ activity, totalCommits }: ActivityCardProps) => ( +
+

Activity

+
+ {activity.map(({ date, count }, index) => ( + + + + ))} +
+ +
+); + +export default ActivityCard; diff --git a/components/home/BentoCell.tsx b/components/home/BentoCell.tsx new file mode 100644 index 0000000..ac11ffe --- /dev/null +++ b/components/home/BentoCell.tsx @@ -0,0 +1,56 @@ +import type { ComponentProps, ReactNode } from 'react'; +import { cn } from '@/lib/utils'; + +export type BentoArea = + | 'about' + | 'logo' + | 'stats' + | 'post' + | 'map' + | 'langs' + | 'activity' + | 'github' + | 'discord' + | 'teams' + | 'team'; + +interface BentoCellProps extends ComponentProps<'section'> { + area: BentoArea; + // A speech bubble revealed while the cell is hovered. + note?: ReactNode; + noteClassName?: string; +} + +const BentoCell = ({ + area, + note, + noteClassName, + className, + children, + style, + ...props +}: BentoCellProps) => ( +
+ {children} + {note && ( + + )} +
+); + +export default BentoCell; diff --git a/components/home/KarnatakaMap.tsx b/components/home/KarnatakaMap.tsx new file mode 100644 index 0000000..14ef8b8 --- /dev/null +++ b/components/home/KarnatakaMap.tsx @@ -0,0 +1,216 @@ +'use client'; + +import { Select } from '@base-ui/react/select'; +import { Check, ChevronsUpDown, MapPin } from 'lucide-react'; +import type { Map as MapLibreMap } from 'maplibre-gl'; +import { useEffect, useRef, useState } from 'react'; +import 'maplibre-gl/dist/maplibre-gl.css'; + +const campuses = { + manipal: [74.7873, 13.3524], // Tiger Circle Road, Madhav Nagar, Manipal 576104 + bengaluru: [77.5906, 13.1254], // Govindapura, Yelahanka, Bengaluru 560064 +} as const satisfies Record; + +const regions = [ + { id: 'manipal', label: 'Manipal', center: campuses.manipal, zoom: 13 }, + { + id: 'bengaluru', + label: 'Bengaluru', + center: campuses.bengaluru, + zoom: 13, + }, + // The whole state is framed by its bounds, since the cell's shape varies. + { + id: 'karnataka', + label: 'Karnataka', + bounds: [ + [74.05, 11.6], + [78.6, 18.45], + ], + }, +] as const satisfies ({ id: string; label: string } & ( + | { center: readonly [number, number]; zoom: number } + | { bounds: [[number, number], [number, number]] } +))[]; + +type RegionId = (typeof regions)[number]['id']; + +const styles = { + light: { + url: 'https://tiles.openfreemap.org/styles/positron', + background: '#eceff4', + water: '#c8d3e0', + }, + dark: { + url: 'https://tiles.openfreemap.org/styles/dark', + background: '#181825', + water: '#11111b', + }, +}; + +const currentTheme = (): keyof typeof styles => + document.documentElement.getAttribute('data-theme') === 'dark' + ? 'dark' + : 'light'; + +const KarnatakaMap = () => { + const container = useRef(null); + const map = useRef(null); + const [region, setRegion] = useState('manipal'); + const [loaded, setLoaded] = useState(false); + + useEffect(() => { + let cancelled = false; + let observer: MutationObserver | undefined; + + (async () => { + const { Map, Marker, setWorkerUrl } = await import('maplibre-gl'); + setWorkerUrl( + new URL('maplibre-gl/dist/maplibre-gl-worker.mjs', import.meta.url).href + ); + if (cancelled || !container.current) return; + + let theme = currentTheme(); + const start = regions[0]; + const instance = new Map({ + container: container.current, + style: styles[theme].url, + center: [...start.center], + zoom: start.zoom, + interactive: false, + attributionControl: { compact: true }, + fadeDuration: 0, + }); + map.current = instance; + // Label the canvas + instance + .getCanvas() + .setAttribute( + 'aria-label', + 'Map of Karnataka with the Manipal and Bengaluru campuses marked' + ); + + const tint = () => { + const palette = styles[currentTheme()]; + if (instance.getLayer('background')) + instance.setPaintProperty( + 'background', + 'background-color', + palette.background + ); + if (instance.getLayer('water')) + instance.setPaintProperty('water', 'fill-color', palette.water); + }; + instance.setMissingStyleImageResolver((id) => { + if (!instance.hasImage(id)) + instance.addImage(id, { + width: 1, + height: 1, + data: new Uint8Array(4), + }); + }); + instance.on('style.load', tint); + instance.once('load', () => { + setLoaded(true); + container.current + ?.querySelector('.maplibregl-compact-show') + ?.classList.remove('maplibregl-compact-show'); + }); + + for (const lngLat of Object.values(campuses)) { + const pin = document.createElement('div'); + pin.className = 'map-pin'; + pin.setAttribute('aria-hidden', 'true'); + new Marker({ element: pin }).setLngLat([...lngLat]).addTo(instance); + } + + // Follow the site theme, which ThemeToggle sets on . + observer = new MutationObserver(() => { + const next = currentTheme(); + if (next === theme) return; + theme = next; + instance.setStyle(styles[next].url); + }); + observer.observe(document.documentElement, { + attributes: true, + attributeFilter: ['data-theme'], + }); + })(); + + return () => { + cancelled = true; + observer?.disconnect(); + map.current?.remove(); + map.current = null; + }; + }, []); + + const goTo = (id: RegionId) => { + setRegion(id); + const target = regions.find((r) => r.id === id); + if (!target || !map.current) return; + const camera = + 'bounds' in target + ? map.current.cameraForBounds(target.bounds, { padding: 16 }) + : { center: [...target.center] as [number, number], zoom: target.zoom }; + if (!camera) return; + if (window.matchMedia('(prefers-reduced-motion: reduce)').matches) + map.current.jumpTo(camera); + else map.current.flyTo({ ...camera, duration: 2000, essential: false }); + }; + + return ( +
+
+ ({ value: id, label }))} + value={region} + onValueChange={(value) => value && goTo(value)} + disabled={!loaded} + > + + + + + + + {regions.map(({ id, label }) => ( + + + + + {label} + + + ))} + + + + + +
+ ); +}; + +export default KarnatakaMap; diff --git a/components/home/LanguagesCard.tsx b/components/home/LanguagesCard.tsx new file mode 100644 index 0000000..19d7396 --- /dev/null +++ b/components/home/LanguagesCard.tsx @@ -0,0 +1,43 @@ +import type { LanguageShare } from '@/lib/github'; + +const percent = (share: number) => + share >= 0.1 ? `${Math.round(share * 100)}%` : `${(share * 100).toFixed(1)}%`; + +const LanguagesCard = ({ languages }: { languages: LanguageShare[] }) => ( +
+

Languages

+
`${name} ${percent(share)}`) + .join(', ')} + className='bg-border flex h-3 w-full gap-0.5 overflow-hidden rounded-full' + > + {languages.map(({ name, share, color }) => ( + + ))} +
+
    + {languages.map(({ name, share, color }) => ( +
  • +
  • + ))} +
+
+); + +export default LanguagesCard; diff --git a/components/home/LinkCell.tsx b/components/home/LinkCell.tsx new file mode 100644 index 0000000..325a35c --- /dev/null +++ b/components/home/LinkCell.tsx @@ -0,0 +1,76 @@ +import { ArrowUpRight } from 'lucide-react'; +import Image from 'next/image'; +import type { ReactNode } from 'react'; +import Link from '@/components/common/TransitionLink'; +import BentoCell, { type BentoArea } from './BentoCell'; + +interface LinkCellProps { + area: BentoArea; + href: string; + icon: ReactNode; + title: string; + detail?: ReactNode; + note?: ReactNode; + image?: string; +} + +const LinkCell = ({ + area, + href, + icon, + title, + detail, + note, + image, +}: LinkCellProps) => { + const external = href.startsWith('http'); + const content = ( + <> + {image && ( + + )} + + {icon} + + + {title} + {detail && ( + {detail} + )} + +
diff --git a/components/layout/Header.tsx b/components/layout/Header.tsx index 51b9297..1732d7f 100644 --- a/components/layout/Header.tsx +++ b/components/layout/Header.tsx @@ -1,20 +1,14 @@ import Logo from './Logo'; -import MobileNav from './MobileNav'; import NavLinks from './NavLinks'; -import SectionName from './SectionName'; import ThemeToggle from './ThemeToggle'; const Header = () => { return (
- -
- -
- -