@@ -2,10 +2,13 @@ import { BiRegularInfoCircle } from "solid-icons/bi";
22import { Codeblock } from "./Codeblock" ;
33import {
44 createChunkRequest ,
5+ createChunkRequestTS ,
56 hybridSearchRequest ,
7+ hybridSearchRequestTS ,
68} from "../utils/createCodeSnippets" ;
79import { DatasetContext } from "../contexts/DatasetContext" ;
8- import { useContext } from "solid-js" ;
10+ import { createSignal , useContext } from "solid-js" ;
11+ import { Button } from "terracotta" ;
912
1013export const CodeExamples = ( ) => {
1114 const { datasetId } = useContext ( DatasetContext ) ;
@@ -18,7 +21,7 @@ export const CodeExamples = () => {
1821 Initial Request Examples
1922 </ h2 >
2023 < div class = "flex flex-col space-y-4" >
21- < p > 1. Add a searchable chunk</ p >
24+ < p class = "font-medium" > 1. Add a searchable chunk</ p >
2225 < div class = "flex w-fit space-x-4 rounded-md border border-blue-600/20 bg-blue-50 px-4 py-4" >
2326 < div class = "flex" >
2427 < div class = "flex-shrink-0" >
@@ -44,10 +47,13 @@ export const CodeExamples = () => {
4447 </ div >
4548 </ div >
4649 </ div >
47- < Codeblock content = { createChunkRequest ( datasetId ( ) ) } />
50+ < CodeExample
51+ fetchContent = { createChunkRequest ( datasetId ( ) ) }
52+ tsContent = { createChunkRequestTS ( datasetId ( ) ) }
53+ />
4854 </ div >
4955 < div class = "flex flex-col space-y-4" >
50- < p class = "mt-3" > 2. Start Searching</ p >
56+ < p class = "mt-3 font-medium " > 2. Start Searching</ p >
5157 < div class = "flex w-fit space-x-4 rounded-md border border-blue-600/20 bg-blue-50 px-4 py-4" >
5258 < div class = "flex" >
5359 < div class = "flex-shrink-0" >
@@ -71,8 +77,43 @@ export const CodeExamples = () => {
7177 </ div >
7278 </ div >
7379 </ div >
74- < Codeblock content = { hybridSearchRequest ( datasetId ( ) ) } />
80+ < CodeExample
81+ fetchContent = { hybridSearchRequest ( datasetId ( ) ) }
82+ tsContent = { hybridSearchRequestTS ( datasetId ( ) ) }
83+ />
7584 </ div >
7685 </ section >
7786 ) ;
7887} ;
88+
89+ const CodeExample = ( props : { tsContent : string ; fetchContent : string } ) => {
90+ const [ selectedTab , setSelectedTab ] = createSignal ( "fetch" ) ;
91+
92+ return (
93+ < div >
94+ < div class = "mb-4 flex gap-4 border-b pb-1" >
95+ < Button
96+ classList = { {
97+ "font-medium" : true ,
98+ "text-fuchsia-800" : selectedTab ( ) === "fetch" ,
99+ } }
100+ onClick = { ( ) => setSelectedTab ( "fetch" ) }
101+ >
102+ Using Fetch
103+ </ Button >
104+ < Button
105+ classList = { {
106+ "font-medium" : true ,
107+ "text-fuchsia-800" : selectedTab ( ) === "ts" ,
108+ } }
109+ onClick = { ( ) => setSelectedTab ( "ts" ) }
110+ >
111+ Using the TS SDK
112+ </ Button >
113+ </ div >
114+ < Codeblock
115+ content = { selectedTab ( ) === "ts" ? props . tsContent : props . fetchContent }
116+ />
117+ </ div >
118+ ) ;
119+ } ;
0 commit comments