Skip to content

Connect, collaborate, and grow with a community of TypeScript developers

contributors grid redesign, fixes #837 (#881)

PickleNike53747bba089
diff --git a/apps/web/src/app/[locale]/_components/community/community.tsx b/apps/web/src/app/[locale]/_components/community/community.tsx
index 19dc24a8..845ebbce 100644
--- a/apps/web/src/app/[locale]/_components/community/community.tsx
+++ b/apps/web/src/app/[locale]/_components/community/community.tsx
@@ -1,16 +1,56 @@
'use client';
-import { For } from 'million/react';
import { GitBranch } from '@repo/ui/icons';
import { clsx } from 'clsx';
import { type CSSProperties } from 'react';
import { useInView } from 'react-intersection-observer';
import { contributors } from '../../../../../public/contributors';
import styles from './community.module.css';
-import Image from 'next/image';
+import { useEffect, useRef } from 'react';
+import { Contributor } from './contributor';
// million-ignore
export function Community() {
+ const innerScrollerRef = useRef<HTMLDivElement | null>(null);
+ const innerScrollerRef2 = useRef<HTMLDivElement | null>(null);
+ const innerScrollerRef3 = useRef<HTMLDivElement | null>(null);
+ const innerScrollerRef4 = useRef<HTMLDivElement | null>(null);
+
+ useEffect(() => {
+ if (innerScrollerRef.current) {
+ const scrollerContent = Array.from(innerScrollerRef.current.children) as HTMLElement[];
+ scrollerContent.forEach((child) => {
+ const duplicatedNode = child.cloneNode(true) as HTMLElement;
+ duplicatedNode.setAttribute('aria-hidden', 'true');
+ innerScrollerRef.current!.appendChild(duplicatedNode);
+ });
+ }
+ if (innerScrollerRef2.current) {
+ const scrollerContent = Array.from(innerScrollerRef2.current.children) as HTMLElement[];
+ scrollerContent.forEach((child) => {
+ const duplicatedNode = child.cloneNode(true) as HTMLElement;
+ duplicatedNode.setAttribute('aria-hidden', 'true');
+ innerScrollerRef2.current!.appendChild(duplicatedNode);
+ });
+ }
+ if (innerScrollerRef3.current) {
+ const scrollerContent = Array.from(innerScrollerRef3.current.children) as HTMLElement[];
+ scrollerContent.forEach((child) => {
+ const duplicatedNode = child.cloneNode(true) as HTMLElement;
+ duplicatedNode.setAttribute('aria-hidden', 'true');
+ innerScrollerRef3.current!.appendChild(duplicatedNode);
+ });
+ }
+ if (innerScrollerRef4.current) {
+ const scrollerContent = Array.from(innerScrollerRef4.current.children) as HTMLElement[];
+ scrollerContent.forEach((child) => {
+ const duplicatedNode = child.cloneNode(true) as HTMLElement;
+ duplicatedNode.setAttribute('aria-hidden', 'true');
+ innerScrollerRef4.current!.appendChild(duplicatedNode);
+ });
+ }
+ }, []);
+
type WrapperStyle = CSSProperties & {
'--bottom': string;
};
@@ -43,10 +83,8 @@ export function Community() {
<div className="rounded-full bg-gradient-to-r from-[#31bdc6] to-[#3178c6] p-[1px] brightness-90 contrast-150 dark:brightness-125 dark:contrast-100">
<div className="rounded-full bg-white/80 px-3 py-1 dark:bg-black/80">
<span className="flex items-center bg-gradient-to-r from-[#31bdc6] to-[#3178c6] bg-clip-text text-transparent">
- <GitBranch className="h-4 w-4 stroke-[#31bdc6] stroke-2 sm:mr-2 lg:mr-0 xl:mr-2" />
- <span className="hidden sm:block lg:hidden xl:block">
- By developers, for developers
- </span>
+ <GitBranch className="h-4 w-4 stroke-[#31bdc6] stroke-2 sm:mr-2" />
+ <span className="hidden sm:block">By developers, for developers</span>
</span>
</div>
</div>
@@ -57,12 +95,12 @@ export function Community() {
TypeHero is free, open-source, and built by developers just like you. These are some
of the contributors who made this possible so far.
</p>
- <div className="flex flex-col-reverse gap-3 sm:flex-row lg:flex-col-reverse xl:flex-row">
+ <div className="flex flex-col-reverse gap-3 sm:flex-row">
<a
target="_blank"
rel="noreferrer"
href="https://discord.gg/trashdev"
- className="group mx-auto flex items-center gap-2 rounded-xl bg-neutral-200 px-3 py-2 text-sm font-bold duration-300 hover:bg-[#5865F2] hover:text-white dark:bg-neutral-800 dark:hover:bg-[#5865F2] lg:ml-0 lg:mr-auto"
+ className="group mx-auto flex items-center gap-2 rounded-xl bg-neutral-200 px-3 py-2 text-sm font-bold duration-300 hover:bg-[#5865F2] hover:text-white dark:bg-neutral-800 dark:hover:bg-[#5865F2]"
>
<svg
className="h-4 w-4 fill-current group-hover:rotate-[360deg]"
@@ -96,30 +134,64 @@ export function Community() {
</a>
</div>
</div>
- <div className="relative flex-1 pb-36 lg:pb-0 lg:pl-4">
- {/* width = w-12(3rem) * 5items + gap-x-3(0.75rem) * 4gaps = 18rem */}
- {/* sm width = w-16(4rem) * 7items + gap-x-3(0.75rem) * 6gaps = 23rem */}
- {/* // TODO: xl width whatever */}
- <div className="honeycomboverride mx-auto flex w-[18rem] flex-wrap gap-x-3 gap-y-1 sm:w-[32.5rem] sm:[&>*:nth-child(13n_+_1)]:ml-[2.375rem] lg:[&>*:nth-child(13n_+_1)]:ml-0 [&>*:nth-child(9n_+_1)]:ml-[2.375rem] sm:[&>*:nth-child(9n_+_1)]:ml-0">
+ {/* honeycomb grid */}
+ <div className="hidden flex-1 pb-0 pl-6 xl:block">
+ {/* xl width = w-16(4rem) * 8items + px-1.5(0.75rem) * 8paddings = 38rem */}
+ <div className="honeycomboverride ml-auto flex flex-wrap xl:w-[38rem] ">
{contributors.map((contributor) => (
- <a
- className="group rounded-full duration-300 hover:scale-125 focus:outline-none focus:duration-0 focus-visible:ring-0 active:scale-105 active:duration-100"
- href={contributor.html_url}
- key={contributor.id}
- rel="noopener"
- target="_blank"
- >
- <Image
- className="honeycombchild h-12 w-12 rounded-2xl bg-cover duration-300 group-hover:rounded-[2rem] group-focus:outline-none group-focus:duration-0 group-focus-visible:ring-2 group-active:rounded-3xl group-active:duration-100 sm:h-16 sm:w-16 sm:rounded-3xl"
- src={contributor.avatar_url}
- width={64}
- height={64}
- alt={`${contributor.login}'s GitHub avatar`}
- />
- </a>
+ <Contributor contributor={contributor} key={contributor.id} />
))}
</div>
</div>
+ {/* autoscrolled */}
+ <div className="pb-16 lg:pb-0 lg:pl-8 xl:hidden">
+ <div className="infinite-scroll-x-container mx-auto hover:shadow-[0_0_10rem_10rem_#fff8] dark:hover:shadow-[0_0_10rem_10rem_#0008] lg:w-[25rem] xl:w-[35rem]">
+ <div
+ ref={innerScrollerRef}
+ className="infinite-scroll-x relative flex w-max flex-nowrap py-1.5"
+ >
+ {contributors.slice(0, contributors.length / 4).map((contributor) => (
+ <Contributor contributor={contributor} key={contributor.id} />
+ ))}
+ </div>
+ </div>
+ <div className="infinite-scroll-x-container mx-auto hover:shadow-[0_0_10rem_10rem_#fff8] dark:hover:shadow-[0_0_10rem_10rem_#0008] lg:w-[25rem] xl:w-[35rem]">
+ <div
+ ref={innerScrollerRef2}
+ className="infinite-scroll-x-reverse relative flex w-max flex-nowrap py-1.5"
+ >
+ {contributors
+ .slice(contributors.length / 4, (contributors.length / 4) * 2)
+ .map((contributor) => (
+ <Contributor contributor={contributor} key={contributor.id} />
+ ))}
+ </div>
+ </div>
+ <div className="infinite-scroll-x-container mx-auto hover:shadow-[0_0_10rem_10rem_#fff8] dark:hover:shadow-[0_0_10rem_10rem_#0008] lg:w-[25rem] xl:w-[35rem]">
+ <div
+ ref={innerScrollerRef3}
+ className="infinite-scroll-x relative flex w-max flex-nowrap py-1.5"
+ >
+ {contributors
+ .slice((contributors.length / 4) * 2, (contributors.length / 4) * 3)
+ .map((contributor) => (
+ <Contributor contributor={contributor} key={contributor.id} />
+ ))}
+ </div>
+ </div>
+ <div className="infinite-scroll-x-container mx-auto hover:shadow-[0_0_10rem_10rem_#fff8] dark:hover:shadow-[0_0_10rem_10rem_#0008] lg:w-[25rem] xl:w-[35rem]">
+ <div
+ ref={innerScrollerRef4}
+ className="infinite-scroll-x-reverse relative flex w-max flex-nowrap py-1.5"
+ >
+ {contributors
+ .slice((contributors.length / 4) * 3, contributors.length)
+ .map((contributor) => (
+ <Contributor contributor={contributor} key={contributor.id} />
+ ))}
+ </div>
+ </div>
+ </div>
</div>
</div>
</section>
diff --git a/apps/web/src/app/[locale]/_components/community/contributor.tsx b/apps/web/src/app/[locale]/_components/community/contributor.tsx
new file mode 100644
index 00000000..441523be
--- /dev/null
+++ b/apps/web/src/app/[locale]/_components/community/contributor.tsx
@@ -0,0 +1,31 @@
+'use client';
+
+import Image from 'next/image';
+
+interface Contributor {
+ login: string;
+ avatar_url: string;
+ html_url: string;
+}
+
+export function Contributor({ contributor }: { contributor: Contributor }) {
+ return (
+ <a
+ className="group relative rounded-full px-1.5 duration-300 hover:z-50 hover:scale-[1.2] focus:outline-none focus:duration-0 focus-visible:ring-0 active:scale-105 active:duration-100 lg:py-0.5"
+ href={contributor.html_url}
+ rel="noopener"
+ target="_blank"
+ >
+ <span className="pointer-events-none absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 scale-90 whitespace-nowrap rounded-full border bg-white/75 px-3 py-1 text-sm opacity-0 shadow-xl backdrop-blur-md duration-300 group-hover:scale-100 group-hover:opacity-100 dark:bg-black/50">
+ {contributor.login}
+ </span>
+ <Image
+ className="h-12 w-12 rounded-2xl bg-cover duration-300 group-hover:rounded-[2rem] group-focus:outline-none group-focus:duration-0 group-focus-visible:ring-2 group-active:rounded-3xl group-active:duration-100 sm:h-16 sm:w-16 sm:rounded-3xl"
+ alt={`${contributor.login}'s GitHub avatar`}
+ src={contributor.avatar_url}
+ height={64}
+ width={64}
+ />
+ </a>
+ );
+}
diff --git a/apps/web/src/styles/globals.css b/apps/web/src/styles/globals.css
index f54454ae..7d37e387 100644
--- a/apps/web/src/styles/globals.css
+++ b/apps/web/src/styles/globals.css
@@ -244,32 +244,6 @@ main {
@apply mx-auto max-w-[1400px] px-4 md:px-24;
}
-/* overrides a conflicting style on the honeycomb grid */
-.honeycomboverride > *:first-child {
- margin-left: 2.375rem /* 38px */ !important;
-}
-
-@media (min-width: 1025px) {
- .honeycomboverride > *:first-child {
- margin-left: -4.75rem !important;
- }
- .honeycomboverride > *:nth-child(9) {
- margin-left: -2.375rem !important;
- }
- .honeycomboverride > *:nth-child(14) {
- margin-left: 0rem !important;
- }
- .honeycomboverride > *:nth-child(23) {
- margin-left: 2.375rem !important;
- }
- .honeycomboverride > *:nth-child(23) {
- margin-left: 2.375rem !important;
- }
- .honeycomboverride > *:nth-child(13n + 23) {
- margin-left: 2.375rem !important;
- }
-}
-
@property --gradient-angle {
syntax: '<angle>'; /* <- defined as type angle for the transition to work */
initial-value: 360deg;
@@ -526,3 +500,45 @@ main {
a {
@apply focus:outline-none focus-visible:ring-2;
}
+
+.infinite-scroll-x-container {
+ overflow: hidden;
+ mask: linear-gradient(to right, transparent, white 20%, white 80%, transparent);
+ -webkit-mask: linear-gradient(to right, transparent, white 20%, white 80%, transparent);
+}
+.infinite-scroll-x {
+ animation: infinite-scroll-x 120s linear infinite;
+}
+
+.infinite-scroll-x-reverse {
+ animation: infinite-scroll-x 120s linear infinite reverse;
+}
+
+.infinite-scroll-x:hover,
+.infinite-scroll-x-reverse:hover {
+ animation-play-state: paused;
+}
+
+@keyframes infinite-scroll-x {
+ to {
+ transform: translateX(-50%);
+ }
+}
+
+@media (min-width: 1280px) {
+ .honeycomboverride > *:first-child {
+ margin-left: -4.75rem !important;
+ }
+ .honeycomboverride > *:nth-child(8) {
+ margin-left: 0rem !important;
+ }
+ .honeycomboverride > *:nth-child(10) {
+ margin-left: -2.375rem !important;
+ }
+ .honeycomboverride > *:nth-child(26) {
+ margin-left: 2.375rem !important;
+ }
+ .honeycomboverride > *:nth-child(15n + 26) {
+ margin-left: 2.375rem !important;
+ }
+}