The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
TimedTabs
Francesco Sansalvadoreff3ec35886be
diff --git a/apps/www/components/Sections/TimedTabs.tsx b/apps/www/components/Sections/TimedTabs.tsxnew file mode 100644index 00000000000..857e362a4d4--- /dev/null+++ b/apps/www/components/Sections/TimedTabs.tsx@@ -0,0 +1,173 @@+import React, { useState, useEffect, ReactNode } from 'react'+import { motion, useAnimation, AnimatePresence } from 'framer-motion'+import SectionContainer from '~/components/Layouts/SectionContainer'+import Link from 'next/link'+import { Button } from 'ui'+import CodeBlock from '../CodeBlock/CodeBlock'+import { Swiper, SwiperSlide } from 'swiper/react'++interface TabProps {+ label: string+ isActive: boolean+ onClick: VoidFunction+ progress: number | undefined+ intervalDuration?: number+}++const Tab = ({ isActive, label, onClick, progress, intervalDuration }: TabProps) => (+ <button+ onClick={onClick}+ className={`text-left text-lg flex flex-col group gap-1 transition-all ${+ // isActive ? 'grow-[1]' : 'grow-[0.5]'+ isActive ? 'flex-[2] text-scale-1200' : 'flex-[1] text-scale-1100'+ }`}+ aria-selected={isActive}+ role="tab"+ >+ <div className="w-full h-[2px] bg-scale-700 group-hover:bg-scale-800 rounded-full overflow-hidden">+ <motion.div+ className="bg-brand-900 h-full"+ style={{ width: `${isActive ? progress : 0}%` }}+ transition={{ duration: intervalDuration }}+ />+ </div>+ {label}+ </button>+)++interface Tab {+ label: string+ panel?: JSX.Element+ code?: string+}++interface Props {+ title: string+ paragraph: string+ tabs: Tab[]+ intervalDuration?: number+ updateFrequency?: number+}++const TimedTabs = ({+ title,+ paragraph,+ tabs,+ intervalDuration = 15,+ updateFrequency = 10,+}: Props) => {+ const [activeTab, setActiveTab] = useState(0)+ const [progress, setProgress] = useState(0)+ const [apiSwiper, setApiSwiper] = useState(undefined)+ const [intervalId, setIntervalId] = useState<any>(null)+ const controls = useAnimation()++ useEffect(() => {+ if (!apiSwiper) return+ // @ts-ignore+ apiSwiper.slideTo(activeTab)+ }, [activeTab])++ const startInterval = () => {+ const interval = setInterval(() => {+ setActiveTab((prevActiveTab) => (prevActiveTab === tabs.length - 1 ? 0 : prevActiveTab + 1))+ }, intervalDuration * 1000)+ setIntervalId(interval)+ }++ const restartInterval = (tabIndex: number) => {+ clearInterval(intervalId)+ setProgress(0)+ startInterval()+ setActiveTab(tabIndex)+ }++ useEffect(() => {+ // const interval = setInterval(() => {+ // setActiveTab((prevActiveTab) => (prevActiveTab === tabs.length - 1 ? 0 : prevActiveTab + 1))+ // }, intervalDuration * 1000) // Change tab every x seconds++ startInterval()++ return () => clearInterval(intervalId)+ }, [tabs.length, intervalDuration])++ const animation = {+ width: '100%',+ transition: { duration: intervalDuration, ease: 'linear' },+ }++ useEffect(() => {+ const progressIncrement = (100 / intervalDuration) * (updateFrequency / 1000)++ controls.start(animation)++ const progressInterval = setInterval(() => {+ setProgress((prevProgress) => (prevProgress + progressIncrement) % 101)+ }, updateFrequency)++ return () => {+ clearInterval(progressInterval)+ setProgress(0)+ }+ }, [activeTab, controls])++ const handleTabClick = (tabIndex: number) => {+ restartInterval(tabIndex)+ }++ return (+ <SectionContainer className="flex flex-col gap-8">+ <div className="flex flex-col lg:flex-row gap-8 xl:gap-10 justify-between">+ <div className="w-full lg:w-1/2 gap-2 flex flex-col">+ <h2 className="text-2xl sm:text-3xl xl:text-4xl max-w-[280px] sm:max-w-xs xl:max-w-[360px] tracking-[-1px]">+ {title}+ </h2>+ <p className="p max-w-sm">{paragraph}</p>+ <Link href="">+ <a className="">+ <Button type="default" size="small">+ Explore documentation+ </Button>+ </a>+ </Link>+ </div>+ <div className="w-full lg:w-1/2 min-h-[300px]">+ <Swiper+ // @ts-ignore+ onSwiper={setApiSwiper}+ style={{ zIndex: 0, marginRight: '1px' }}+ initialSlide={activeTab}+ spaceBetween={0}+ slidesPerView={1}+ speed={300}+ allowTouchMove={false}+ autoHeight={true}+ >+ {tabs.map((tab, i) => (+ <SwiperSlide key={i}>+ <CodeBlock key={i} lang="py" size="medium">+ {tab.code}+ </CodeBlock>+ </SwiperSlide>+ ))}+ </Swiper>+ </div>+ </div>+ <div className="w-full col-span-full flex gap-4 lg:gap-8 xl:gap-10" role="tablist">+ {tabs.map((tab, index) => (+ <Tab+ key={index}+ isActive={index === activeTab}+ label={tab.label}+ onClick={() => handleTabClick(index)}+ progress={index === activeTab ? progress : undefined}+ intervalDuration={intervalDuration}+ />+ ))}+ </div>+ </SectionContainer>+ )+}++export default TimedTabsdiff --git a/apps/www/data/products/vector/page.tsx b/apps/www/data/products/vector/page.tsxindex 6cb52dbd4a9..674626d71b0 100644--- a/apps/www/data/products/vector/page.tsx+++ b/apps/www/data/products/vector/page.tsx@@ -1,3 +1,4 @@+import { CodeBlock } from 'ui'import IntegrationsSVG from '../../../components/products/vector/IntegrationsSVG'export const pageData = {@@ -10,24 +11,28 @@ export const pageData = {],highlights: [{- title: 'Postgres pgvector',- paragraph: 'Unleash the power of vector embeddings with Postgres pgvector.',- image: 'asdfadsf',+ title: 'PostgreSQL + pgvector',+ paragraph:+ 'Every Supabase project is a dedicated Postgres instance. Use pgvector to store, query, and index your vector embeddings at scale.',+ image: '',},{title: 'Connect with OpenAI',- paragraph: 'Seamlessly integrate with Open AI for advanced AI capabilities.',- image: 'asdfadsf',+ paragraph:+ 'Easily connect to any LLM or embeddings API, including Hugging Face, SageMaker and more.',+ image: '',},{- title: 'SOC 2 Type 2 compliant',- paragraph: 'asdfadsf',- image: 'asdfadsf',+ title: 'Secure and Scalable',+ paragraph:+ 'Supabase is SOC2 type 2 compliant, and comes with an advanced permissions system.',+ image: '',},{- title: 'Hosted or Self-Hosted',- paragraph: 'Choose the deployment option that suits your needs.',- image: 'asdfadsf',+ title: 'Deploy Globally',+ paragraph:+ 'Choose from 12 Fully Managed datacenters or, or Self-Host on your own cloud or servers.',+ image: '',},],integrations: {@@ -71,6 +76,67 @@ export const pageData = {},],},+ APIsection: {+ title: (+ <>+ <span className="heading-gradient">Simple yet</span>+ <br />+ <span className="heading-gradient-brand">powerful APIs</span>+ </>+ ),+ paragraph:+ 'Easy-to-use client libraries for managing and querying vector stores in PostgreSQL.',+ tabs: [+ {+ label: 'Store',+ code: `+docs = vx.create_collection(name="docs", dimension=3)++# add records to the collection+docs.upsert(+ vectors=[+ (+ "vec0", # the vector's identifier+ [0.1, 0.2, 0.3], # the vector. list or np.array+ {"year": 1973} # associated metadata+ ),+ (+ "vec1",+ [0.7, 0.8, 0.9],+ {"year": 2012}+ )+ ]+)+ `,+ },+ {+ label: 'Search',+ code: `+# index the collection to be queried by cosine distance+docs.create_index(measure=vecs.IndexMeasure.cosine_distance)++# Available options for query measure are:+#+# vecs.IndexMeasure.cosine_distance+# vecs.IndexMeasure.l2_distance+# vecs.IndexMeasure.max_inner_product++# or use the default (cosine_distance)+docs.create_index()+ `,+ },+ {+ label: 'Query',+ code: `+# Query vectors with optional Metadata Filtering+docs.query(+ query_vector=[0.4,0.5,0.6],+ filters={"year": {"$eq": 2012}}, # metadata filters+)+ `,+ },+ ],+ },featuresSection: {title: (<>diff --git a/apps/www/pages/vector/Vector.tsx b/apps/www/pages/vector/Vector.tsxindex 659acdd0c37..d044fbe88ad 100644--- a/apps/www/pages/vector/Vector.tsx+++ b/apps/www/pages/vector/Vector.tsx@@ -12,11 +12,12 @@ import ProductHeaderCentered from '~/components/Sections/ProductHeaderCentered'import VectorStyles from './vector.module.css'import FeaturesSection from '~/components/Sections/FeaturesSection'import HighlightCards from '~/components/Sections/HighlightCards'+import UseCasesSection from '~/components/Sections/UseCasesSection'+import CenteredTitleImage from '~/components/Sections/CenteredTitleImage'+import TimedTabs from '~/components/Sections/TimedTabs'import { pageData } from '~/data/products/vector/page'import 'swiper/swiper.min.css'-import UseCasesSection from '../../components/Sections/UseCasesSection'-import CenteredTitleImage from '../../components/Sections/CenteredTitleImage'const Cursor = ({ className = '', color = 'none' }) => {return (@@ -146,6 +147,8 @@ function VectorPage() {<UseCasesSection {...pageData.useCasesSection} />+ <TimedTabs {...pageData.APIsection} />+<FeaturesSection {...pageData.featuresSection} /><CommunitySlider />