Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions src/components/Examples/ExamplesGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ import React, { useCallback } from 'react';
import Badge from 'src/components/ui/Badge';
import Icon from 'src/components/Icon';
import { IconName } from 'src/components/Icon/types';
import { ProductName, products as dataProducts } from 'src/components/ui/ProductTile/data';
import cn from 'src/utilities/cn';
import { Image, ImageProps } from '../Image';
import { DEFAULT_EXAMPLE_LANGUAGES } from '../../data/examples/';
import { DEFAULT_EXAMPLE_LANGUAGES, products as dataProducts } from '../../data/examples/';
import { Example } from '../../data/examples/types';

const ExamplesGrid = ({
Expand All @@ -22,25 +21,25 @@ const ExamplesGrid = ({
return productImage ? <Image image={productImage} alt={name} className="h-full" /> : null;
}, []);

const badgeColorForProduct = useCallback((product: ProductName) => {
const badgeColorForProduct = useCallback((product: string) => {
switch (product) {
case 'platform':
return 'text-slate-600';
case 'chat':
return 'text-violet-400';
case 'spaces':
return 'text-pink-500';
case 'liveSync':
return 'text-blue-600';
case 'liveObjects':
case 'liveobjects':
return 'text-green-600';
case 'aiTransport':
case 'ai_transport':
return 'text-cyan-500';
default:
return 'text-orange-700';
}
}, []);

const displayProductLabel = useCallback(
(product: ProductName, dataProducts: { [key: string]: { label: string } }) =>
(product: string, dataProducts: { [key: string]: { label: string } }) =>
dataProducts[product] ? (
<Badge key={product} className={cn('uppercase', badgeColorForProduct(product))}>
{dataProducts[product].label}
Expand Down Expand Up @@ -100,7 +99,7 @@ const ExamplesGrid = ({
<p className="ui-text-h4 text-neutral-1300 dark:text-neutral-000">{highlightSearchTerm(name)}</p>
<p className="ui-text-p3 mt-2 text-neutral-900 dark:text-neutral-500">{highlightSearchTerm(description)}</p>
<div className="mt-4 flex gap-x-1">
{products ? products.map((product) => displayProductLabel(product as ProductName, dataProducts)) : null}
{products ? products.map((product) => displayProductLabel(product, dataProducts)) : null}
{/* {useCases ? useCases.map((useCase) => displayUseCaseLabel(useCase)) : null} */}
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Examples/ExamplesRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const getDependencies = (id: string, products: string[], activeLanguage: Languag
nanoid: '^5.0.7',
minifaker: '1.34.1',
'franken-ui': '^2.0.0',
...(products.includes('auth') ? { cors: '^2.8.5' } : {}),
...(products.includes('platform') ? { cors: '^2.8.5' } : {}),
...(products.includes('chat')
? { '@ably/chat': '~1.3.1', '@ably/chat-react-ui-kit': '~0.3.0', clsx: '^2.1.1' }
: {}),
Expand Down
16 changes: 8 additions & 8 deletions src/data/examples/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const examples: Example[] = [
id: 'auth-generate-jwt',
name: 'Generate JWT',
description: 'Generate a JSON Web Token (JWT) for authenticating users.',
products: ['auth'],
products: ['platform'],
layout: 'single-horizontal',
visibleFiles: ['src/script.ts', 'App.tsx', 'index.tsx'],
metaTitle: `Authenticate with Ably using JWTs`,
Expand All @@ -27,7 +27,7 @@ export const examples: Example[] = [
id: 'auth-request-token',
name: 'Request an Ably Token',
description: 'Request an Ably Token for authenticating users. JWTs are recommended for most use cases.',
products: ['auth'],
products: ['platform'],
layout: 'single-horizontal',
visibleFiles: ['src/script.ts', 'App.tsx', 'index.tsx'],
metaTitle: `Authenticate with Ably Token`,
Expand Down Expand Up @@ -342,23 +342,23 @@ export const examples: Example[] = [
];

export const products = {
auth: {
label: 'Authentication',
platform: {
label: 'Platform',
},
pubsub: {
label: 'Pub/Sub',
},
chat: {
label: 'Chat',
},
liveobjects: {
label: 'LiveObjects',
ai_transport: {
label: 'AI Transport',
},
spaces: {
label: 'Spaces',
},
ai_transport: {
label: 'AI Transport',
liveobjects: {
label: 'LiveObjects',
},
};

Expand Down