Skip to content

Commit 39cc30f

Browse files
committed
adding some zesty images 🌶️
1 parent 4506d0a commit 39cc30f

File tree

8 files changed

+106
-2344
lines changed

8 files changed

+106
-2344
lines changed

.speakeasy/gen.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ management:
66
speakeasyVersion: 1.495.1
77
generationVersion: 2.515.4
88
releaseVersion: 2.2.6
9-
configChecksum: 231056298e32bcbdbe85ed747f3eb244
9+
configChecksum: a4ff9835698013bb8c7bb828a7e2be76
1010
repoURL: https://github.com/speakeasy-api/speakeasy-code-samples-ts.git
1111
installationURL: https://github.com/speakeasy-api/speakeasy-code-samples-ts
1212
published: true

.speakeasy/workflow.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ speakeasyVersion: 1.495.1
22
sources:
33
speakeasy-OAS:
44
sourceNamespace: speakeasy-oas
5-
sourceRevisionDigest: sha256:4286e1907ba21377cded4e079899d46bbebefe2c403b5445e75349bc4e816acc
5+
sourceRevisionDigest: sha256:e536544d55620a79d50578204eb81fba11c6c419701bba423d897f2418d40a2d
66
sourceBlobDigest: sha256:74092062b98c511fb2035986fe307d2d5de39443dac827b7bdddb853268f768c
77
tags:
88
- latest
@@ -11,10 +11,10 @@ targets:
1111
code_samples_typescript_sdk:
1212
source: speakeasy-OAS
1313
sourceNamespace: speakeasy-oas
14-
sourceRevisionDigest: sha256:4286e1907ba21377cded4e079899d46bbebefe2c403b5445e75349bc4e816acc
14+
sourceRevisionDigest: sha256:e536544d55620a79d50578204eb81fba11c6c419701bba423d897f2418d40a2d
1515
sourceBlobDigest: sha256:74092062b98c511fb2035986fe307d2d5de39443dac827b7bdddb853268f768c
1616
codeSamplesNamespace: speakeasy-oas-typescript-code-samples
17-
codeSamplesRevisionDigest: sha256:d384f1e2acef6d6a2415cd201c65ba9ac8b174b998bea0fdd37163c72dacb704
17+
codeSamplesRevisionDigest: sha256:3a52773bea327c93e288622e24477f9c093cebab089f6e48ca84594db21a43e6
1818
workflow:
1919
workflowVersion: 1.0.0
2020
speakeasyVersion: latest

README.md

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@
1919
> This SDK is not yet ready for production use. To complete setup please follow the steps outlined in your [workspace](https://app.speakeasy.com/org/speakeasy-self/speakeasy-self). Delete this section before > publishing to a package manager.
2020
2121
<div align="center">
22-
<img src="https://github.com/user-attachments/assets/f5ab386f-39bb-4ae2-aa0d-54e2f95b656d" alt="Description" width="750"/>
22+
<picture>
23+
<source media="(prefers-color-scheme: dark)" srcset="./images/code-samples-demo-dark.webm">
24+
<img alt="animation of viewing code, switching programming languages, and copying the displayed text" src="./images/code-samples-demo-light.webm">
25+
</picture>
2326
<p><em>CodeSamples React Component in Action</em></p>
2427
</div>
2528

@@ -28,13 +31,13 @@
2831

2932
Speakeasy Code Samples API: REST APIs for retrieving SDK usage snippets from the Speakeasy Code Samples API.
3033

34+
3135
For more information about the API: [The Speakeasy Platform Documentation](/docs)
3236
<!-- End Summary [summary] -->
3337

3438
<!-- Start Table of Contents [toc] -->
3539
## Table of Contents
3640
<!-- $toc-max-depth=2 -->
37-
* [@speakeasyapi/code-samples](#speakeasyapicode-samples)
3841
* [SDK Installation](#sdk-installation)
3942
* [Requirements](#requirements)
4043
* [SDK Example Usage](#sdk-example-usage)
@@ -148,46 +151,39 @@ run();
148151
### React Component
149152

150153
This library includes a React component that fetches and highlights code
151-
snippets using `highlight.js`. Along with displaying the snippet, it shows a
154+
snippets using `codehike`. Along with displaying the snippet, it shows a
152155
loading state during fetching and provides a fallback view if an error occurs.
153156

154157
```tsx
155158
import { SpeakeasyCodeSamplesCore } from "@speakeasyapi/code-samples/core";
156159
import {
157-
CodeSample,
160+
CodeSampleFilenameTitle,
161+
CodeSamplesViewer,
158162
SpeakeasyCodeSamplesProvider,
159163
} from "@speakeasyapi/code-samples/react";
160-
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
161-
162-
const queryClient = new QueryClient();
163164

164165
const speakeasyCodeSamples = new SpeakeasyCodeSamplesCore({
165166
apiKey: "<YOUR_API_KEY_HERE>",
166167
registryUrl: "https://spec.speakeasy.com/org/ws/my-source",
167168
});
168169

169-
// Retries are handled by the underlying SDK.
170-
queryClient.setQueryDefaults(["@speakeasyapi/code-samples"], { retry: false });
171-
172-
queryClient.setMutationDefaults(["@speakeasyapi/code-samples"], {
173-
retry: false,
174-
});
175-
176170
function App() {
177171
return (
178-
<QueryClientProvider client={queryClient}>
179-
<SpeakeasyCodeSamplesProvider client={speakeasyCodeSamples}>
180-
<CodeSample operationId="getPetById" language="typescript" />
181-
</SpeakeasyCodeSamplesProvider>
182-
</QueryClientProvider>
172+
<SpeakeasyCodeSamplesProvider client={speakeasyCodeSamples}>
173+
<CodeSamplesViewer
174+
copyable
175+
defaultLang={"typescript"}
176+
title={CodeSampleFilenameTitle}
177+
operation={"getPassageText"}
178+
// client={speakeasyCodeSamples}
179+
// 👆optional, if you want to pass the client directly
180+
// instead of using the provider
181+
/>
182+
</SpeakeasyCodeSamplesProvider>
183183
);
184184
}
185185
```
186186

187-
> [!NOTE]
188-
> To apply styles to the highlighted code, import a `highlight.js` theme CSS
189-
> file into your project using methods like a `<link>` tag.
190-
191187
<!-- Start Authentication [security] -->
192188
## Authentication
193189

example/src/App.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,13 @@ function App() {
1616
// samples viewer
1717
return (
1818
<SpeakeasyCodeSamplesProvider client={coreSdk}>
19-
<h1 className="">Speakeasy Code Samples</h1>
20-
<div style={{ width: "50%", marginInline: "auto" }}>
19+
<div style={{ width: "700px", marginInline: "auto" }}>
2120
<CodeSamplesViewer
2221
copyable
2322
defaultLang={"typescript"}
2423
title={CodeSampleFilenameTitle}
2524
operation={"getPassageText"}
26-
// client={coreSdk}
25+
// client={coreSdk} 👈 optional, if you want to pass the client directly
2726
/>
2827
</div>
2928
</SpeakeasyCodeSamplesProvider>

images/code-samples-demo-dark.webm

285 KB
Binary file not shown.

images/code-samples-demo-light.webm

226 KB
Binary file not shown.

0 commit comments

Comments
 (0)