From f4dd2a90ded506c7ea4b8c825d63b47873fac0a6 Mon Sep 17 00:00:00 2001 From: Toby Brown Date: Thu, 18 Jan 2024 16:39:38 +0000 Subject: [PATCH] everything is cleaner now --- components/slack/arrows.js | 7 + components/slack/catchall.js | 62 +++++ components/slack/channels.js | 173 +++++++++++++ components/slack/project.js | 73 ++++++ components/slack/projects.js | 83 +++++++ components/slack/quote.js | 24 ++ pages/slack.js | 468 +++-------------------------------- 7 files changed, 452 insertions(+), 438 deletions(-) create mode 100644 components/slack/arrows.js create mode 100644 components/slack/catchall.js create mode 100644 components/slack/channels.js create mode 100644 components/slack/project.js create mode 100644 components/slack/projects.js create mode 100644 components/slack/quote.js diff --git a/components/slack/arrows.js b/components/slack/arrows.js new file mode 100644 index 00000000..2c6774af --- /dev/null +++ b/components/slack/arrows.js @@ -0,0 +1,7 @@ +export function LeftArrow() { + return +} + +export function RightArrow() { + return +} diff --git a/components/slack/catchall.js b/components/slack/catchall.js new file mode 100644 index 00000000..91a46461 --- /dev/null +++ b/components/slack/catchall.js @@ -0,0 +1,62 @@ +import { Box, Image, Link, Text } from 'theme-ui' +import Icon from '@hackclub/icons' + +export default function Join() { + return ( + + + + + There's a whole new world for you to discover. + + + I'm ready to join + + + + + + ) +} diff --git a/components/slack/channels.js b/components/slack/channels.js new file mode 100644 index 00000000..f4095e4e --- /dev/null +++ b/components/slack/channels.js @@ -0,0 +1,173 @@ +import { Badge, Card, Flex, Grid, Heading, Image, Text } from 'theme-ui' +import Icon from '@hackclub/icons' +import NextLink from 'next/link' +import useSWR from 'swr' +import fetcher from '../../lib/fetcher' + +const withCommas = x => x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',') + +export default function Channels() { + const { data: millionCount } = useSWR( + 'https://jia.haas.hackclub.com/api/currentNumber', + fetcher, + { refreshInterval: 10_000 } + ) + return ( + div': { + px: [2, 3], + py: 4, + display: 'flex', + flexDirection: 'column', + justifyContent: 'center', + gridColumn: ['span 1', 'span 3'] + }, + a: { + position: 'relative', + ':hover,:focus': { + svg: { + transform: 'translateX(28px) translateY(-28px)', + opacity: 0 + } + } + }, + svg: { + position: 'absolute', + top: 2, + right: 2, + fill: 'white', + transition: 'transform 0.25s ease-in-out, opacity 0.25s ease-in-out' + }, + h3: { + variant: 'text.headline', + color: 'white', + lineHeight: 'title', + m: 0, + '+ p': { + mt: 2, + color: 'white', + opacity: 0.75, + fontSize: 2, + lineHeight: 'caption' + } + } + }} + > + + t.util.gx('cyan', 'blue') + }} + > + + + #ship + + Launch your latest projects & get feedback + + + t.util.gx('yellow', 'orange') + }} + > + + + #scrapbook + + A daily diary of project updates + + + #counttoamillion + + We’re at{' '} + + {millionCount ? withCommas(millionCount.number) : '???'} + + ! + + + +

#gamedev

+
+ +

#design

+
+ +

#code

+
+ +

#photography

+
+ + + + #music + + Music notes + + + + `linear-gradient(-184deg, ${colors.red} 0%, ${colors.red} 16.6666%, ${colors.orange} 16.6666%, ${colors.orange} 33.333%, ${colors.yellow} 33.333%, ${colors.yellow} 50%, ${colors.green} 50%, ${colors.green} 66.6666%, ${colors.blue} 66.6666%, ${colors.blue} 83.3333%, ${colors.purple} 83.3333%, ${colors.purple} 100%)` + }} + > +

#lgbtq

+
+
+ ) +} diff --git a/components/slack/project.js b/components/slack/project.js new file mode 100644 index 00000000..e44e9b1d --- /dev/null +++ b/components/slack/project.js @@ -0,0 +1,73 @@ +import { Box, Image, Text } from 'theme-ui' +import { VisibilityContext } from 'react-horizontal-scrolling-menu' +import { useContext } from 'react' + +export default function Project({ + title, + description, + sx, + color, + img, + itemId +}) { + const visible = useContext(VisibilityContext) + const isVisible = visible.isItemVisible(itemId) + + return ( + + `linear-gradient(to bottom, ${color[0]}, ${color[1]})`, + color: 'white', + overflow: 'clip', + width: '70rem', + height: '100%', + overflowX: 'auto', + transition: '700ms cubic-bezier(0.075, 0.02, 0.165, 1)', + transformOrigin: 'center', + sx + }} + itemId={itemId} + > + + + {title} + + + {description} + + + + + ) +} diff --git a/components/slack/projects.js b/components/slack/projects.js new file mode 100644 index 00000000..ae2acaaa --- /dev/null +++ b/components/slack/projects.js @@ -0,0 +1,83 @@ +const projects = [ + { + title: 'Brainwave device for thought-based computer interaction.', + description: + "BCI's team organizes in #nest Velit voluptate deserunt consequat. Velit voluptate deserunt consequat.Velit voluptate deserunt consequat.", + img: 'bci', + color: ['#ec3750', '#F58695'], + itemId: 1 + }, + { + title: 'A free domain service.', + description: + 'Obl.ong’s team organizes in #oblong Velit voluptate deserunt consequat. Velit voluptate deserunt consequat.Velit voluptate deserunt consequat.', + img: 'oblong', + color: ['#ff8c37', '#F2A510'] + }, + { + title: 'An open source VPN.', + description: + "Burrow's team organizes in #burrow Velit voluptate deserunt consequat. Velit voluptate deserunt consequat.Velit voluptate deserunt consequat.", + img: 'burrow', + color: ['#f1c40f', '#FAE078'] + }, + { + title: 'Free compute infrastructure.', + description: + "Nest's team organizes in #nest Velit voluptate deserunt consequat. Velit voluptate deserunt consequat.Velit voluptate deserunt consequat.", + img: 'nest', + color: ['#33d6a6', '#51F5C5'] + }, + { + title: 'A chat app and cell phone carrier.', + description: + "Nest's team organizes in #nest Velit voluptate deserunt consequat. Velit voluptate deserunt consequat.Velit voluptate deserunt consequat.", + img: 'purplebubble', + color: ['#5bc0de', '#88e5f8'] + } +] + +export default projects + +/* +Here lies the horizontal scroll menu. It's not currently in use, but it's here if anyone every wants it! - Toby + const triggerRef = useRef(null) + gsap.registerPlugin(ScrollTrigger) + useEffect(() => { + const sections = gsap.utils.toArray('.project') + + const projects = gsap.to(sections, { + xPercent: -100 * (sections.length - 1), + ease: 'none', + duration: 1, + scrollTrigger: { + trigger: triggerRef.current, + start: 'top top', + end: () => '+=' + document.querySelector('.container').offsetWidth, + scrub: 1.25, + pin: true, + anticipatePin: 1, + invalidateOnRefresh: true, + snap: 0.5 * (1 / (sections.length - 1)) + }, + onUpdate: function () { + const progress = this.progress() + if (progress < 1 / 6) { + setColors(['red', '#F58695']) + } else if (progress < 2 / 6) { + setColors(['orange', '#F2A510']) + } else if (progress < 3 / 6) { + setColors(['yellow', '#FAE078']) + } else if (progress < 4 / 6) { + setColors(['green', '#51F5C5']) + } else if (progress < 5 / 6) { + setColors(['cyan', '#88e5f8']) + } else { + setColors(['purple', '#d786ff']) + } + } + }) + return () => { + projects.kill() + } + }, [])*/ diff --git a/components/slack/quote.js b/components/slack/quote.js new file mode 100644 index 00000000..f1c0dcea --- /dev/null +++ b/components/slack/quote.js @@ -0,0 +1,24 @@ +import { Box, Flex, Image, Text } from 'theme-ui' + +export default function Quote({ text, person, age, location, img }) { + return ( + + + "{text}" + + + + + {person}, {age} from {location} + + + + ) +} diff --git a/pages/slack.js b/pages/slack.js index 3836e4c0..5d101c19 100644 --- a/pages/slack.js +++ b/pages/slack.js @@ -1,102 +1,38 @@ import Meta from '@hackclub/meta' import Head from 'next/head' -import NextLink from 'next/link' -import useSWR from 'swr' -import { - Badge, - Box, - Card, - Container, - Flex, - Grid, - Heading, - Image, - Link, - Text -} from 'theme-ui' +import { Box, Container, Flex, Grid, Heading, Text } from 'theme-ui' import Footer from '../components/footer' import ForceTheme from '../components/force-theme' -import Icon from '../components/icon' import Nav from '../components/nav' import Header from '../components/slack/header' -import fetcher from '../lib/fetcher' import { thousands } from '../lib/members' -import { useRef, useState, useContext } from 'react' -import Slider from 'react-slick' - -import { ScrollMenu, VisibilityContext } from 'react-horizontal-scrolling-menu' +import { useRef, useState } from 'react' +import Project from '../components/slack/project' +import Quote from '../components/slack/quote' +import { ScrollMenu } from 'react-horizontal-scrolling-menu' import 'react-horizontal-scrolling-menu/dist/styles.css' - -const withCommas = x => x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',') - -const projects = [ - { - title: 'Brainwave device for thought-based computer interaction.', - description: - "BCI's team organizes in #nest Velit voluptate deserunt consequat. Velit voluptate deserunt consequat.Velit voluptate deserunt consequat.", - img: 'bci', - color: ['#ec3750', '#F58695'], - itemId: 1 - }, - { - title: 'A free domain service.', - description: - 'Obl.ong’s team organizes in #oblong Velit voluptate deserunt consequat. Velit voluptate deserunt consequat.Velit voluptate deserunt consequat.', - img: 'oblong', - color: ['#ff8c37', '#F2A510'] - }, - { - title: 'An open source VPN.', - description: - "Burrow's team organizes in #burrow Velit voluptate deserunt consequat. Velit voluptate deserunt consequat.Velit voluptate deserunt consequat.", - img: 'burrow', - color: ['#f1c40f', '#FAE078'] - }, - { - title: 'Free compute infrastructure.', - description: - "Nest's team organizes in #nest Velit voluptate deserunt consequat. Velit voluptate deserunt consequat.Velit voluptate deserunt consequat.", - img: 'nest', - color: ['#33d6a6', '#51F5C5'] - }, - { - title: 'A chat app and cell phone carrier.', - description: - "Nest's team organizes in #nest Velit voluptate deserunt consequat. Velit voluptate deserunt consequat.Velit voluptate deserunt consequat.", - img: 'purplebubble', - color: ['#5bc0de', '#88e5f8'] - } -] +import Channels from '../components/slack/channels' +import projects from '../components/slack/projects' +import Join from '../components/slack/catchall' +import SlackEvents from '../components/slack/slack-events' +import { LeftArrow, RightArrow } from '../components/slack/arrows' const SlackPage = () => { - const { data: millionCount } = useSWR( - 'https://jia.haas.hackclub.com/api/currentNumber', - fetcher, - { refreshInterval: 10_000 } - ) - const nameInputRef = useRef(null) - const [items, setItems] = useState(projects) - const [selected, setSelected] = useState([]) - const [position, setPosition] = useState(0) + const [currentIndex, setCurrentIndex] = useState(0) - const { isLastItemVisible, scrollNext } = useContext(VisibilityContext) - const { isFirstItemVisible, scrollPrev } = useContext(VisibilityContext) - - const isItemSelected = id => !!selected.find(el => el === id) - - const handleClick = - id => - ({ getItemById, scrollToItem }) => { - const itemSelected = isItemSelected(id) - - setSelected(currentSelected => - itemSelected - ? currentSelected.filter(el => el !== id) - : currentSelected.concat(id) - ) + const handleLeftClick = () => { + if (currentIndex > 0) { + setCurrentIndex(currentIndex - 1) } + } + + const handleRightClick = () => { + if (currentIndex < projects.length - 1) { + setCurrentIndex(currentIndex + 1) + } + } return ( <> @@ -125,164 +61,7 @@ const SlackPage = () => { programming language, ask for advice, or just hang out. Find the worlds that suit you. - div': { - px: [2, 3], - py: 4, - display: 'flex', - flexDirection: 'column', - justifyContent: 'center', - gridColumn: ['span 1', 'span 3'] - }, - a: { - position: 'relative', - ':hover,:focus': { - svg: { - transform: 'translateX(28px) translateY(-28px)', - opacity: 0 - } - } - }, - svg: { - position: 'absolute', - top: 2, - right: 2, - fill: 'white', - transition: - 'transform 0.25s ease-in-out, opacity 0.25s ease-in-out' - }, - h3: { - variant: 'text.headline', - color: 'white', - lineHeight: 'title', - m: 0, - '+ p': { - mt: 2, - color: 'white', - opacity: 0.75, - fontSize: 2, - lineHeight: 'caption' - } - } - }} - > - - t.util.gx('cyan', 'blue') - }} - > - - - #ship - - Launch your latest projects & get feedback - - - t.util.gx('yellow', 'orange') - }} - > - - - #scrapbook - - A daily diary of project updates - - - #counttoamillion - - We’re at{' '} - - {millionCount ? withCommas(millionCount.number) : '???'} - - ! - - - -

#gamedev

-
- -

#design

-
- -

#code

-
- -

#photography

-
- - - - #music - - Music notes - - - - `linear-gradient(-184deg, ${colors.red} 0%, ${colors.red} 16.6666%, ${colors.orange} 16.6666%, ${colors.orange} 33.333%, ${colors.yellow} 33.333%, ${colors.yellow} 50%, ${colors.green} 50%, ${colors.green} 66.6666%, ${colors.blue} 66.6666%, ${colors.blue} 83.3333%, ${colors.purple} 83.3333%, ${colors.purple} 100%)` - }} - > -

#lgbtq

-
-
+ { overflow: 'hidden' }} > - {/* { > Live from our Slack... - */} + Where the makers hang out... @@ -319,11 +98,12 @@ const SlackPage = () => { width: 'fit-content', position: 'relative', display: 'grid', - paddingLeft: '25vw' + paddingLeft: '25vw', + overflowX: 'hidden' }} className="container" > - + {projects.map((project, index) => ( { img={project.img} color={project.color} itemId={project.itemId} - handleClick={handleClick} - isItemSelected={isItemSelected} - id={index} + selected={index === currentIndex} + key={index} /> ))} - scrollPrev()}>Left - scrollNext()}> - Right - { location="VT" /> - - - - - There's a whole new world for you to discover. - - - I'm ready to join - - - - - +