Skip to content
Merged
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
2 changes: 2 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

The `rivet.gg` domain is deprecated and should never be used in this codebase.

**ALWAYS use `github.com/rivet-dev/rivet` - NEVER use `rivet-dev/rivetkit` or `rivet-gg/*`**

## Commands

### Build Commands
Expand Down
1 change: 0 additions & 1 deletion website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
"@fortawesome/free-brands-svg-icons": "^7.1.0",
"@fortawesome/free-solid-svg-icons": "^7.1.0",
"@fortawesome/react-fontawesome": "^3.1.0",
"@giscus/react": "^3.1.0",
"@headlessui/react": "^2.2.9",
"@heroicons/react": "^2.2.0",
"@rivet-gg/api": "25.5.3",
Expand Down
151 changes: 0 additions & 151 deletions website/public/giscus.css

This file was deleted.

30 changes: 0 additions & 30 deletions website/src/components/Comments.tsx

This file was deleted.

144 changes: 66 additions & 78 deletions website/src/components/TabsScript.astro
Original file line number Diff line number Diff line change
Expand Up @@ -50,64 +50,7 @@
function initializeCodeGroups() {
const codeGroupContainers = document.querySelectorAll('[data-code-group-container]');
codeGroupContainers.forEach((container) => {
const isWorkspace = container.hasAttribute('data-code-group-workspace');

if (isWorkspace) {
initializeWorkspaceCodeGroup(container);
} else {
initializeTabCodeGroup(container);
}
});
}

function initializeTabCodeGroup(container: Element) {
const tabsList = container.querySelector('[data-code-group-tabs]');
const contentContainer = container.querySelector('[data-code-group-content-container]');
const source = container.querySelector('[data-code-group-source]');

if (!tabsList || !contentContainer || !source) return;

// Already initialized
if (tabsList.children.length > 0) return;

// Find all code blocks in source (they have data-code-block attribute)
const codeBlocks = source.querySelectorAll('[data-code-block]');
let visibleIndex = 0;
codeBlocks.forEach((block, index) => {
const title = block.getAttribute('data-code-title') || 'Code';
const id = block.getAttribute('data-code-id') || `code-${index}`;
const isHidden = block.getAttribute('data-code-hide') === 'true';

// Skip hidden blocks (don't create tabs for them, don't add to DOM)
if (isHidden) {
return;
}

// Create tab button
const button = document.createElement('button');
button.type = 'button';
button.setAttribute('data-code-group-trigger', id);
button.className = [
'relative inline-flex min-h-[2.75rem] items-center justify-center whitespace-nowrap',
'rounded-none border-b-2 bg-transparent px-4 py-2.5 text-sm font-semibold',
'ring-offset-background transition-none',
'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2',
'disabled:pointer-events-none disabled:opacity-50',
visibleIndex === 0 ? 'border-b-primary text-white' : 'border-b-transparent text-muted-foreground'
].join(' ');
button.textContent = title;
tabsList.appendChild(button);

// Create content wrapper and move code block
const clonedBlock = block.cloneNode(true) as HTMLElement;

const contentWrapper = document.createElement('div');
contentWrapper.setAttribute('data-code-group-content', id);
contentWrapper.className = visibleIndex === 0 ? '' : 'hidden';
contentWrapper.appendChild(clonedBlock);
contentContainer.appendChild(contentWrapper);

visibleIndex++;
initializeWorkspaceCodeGroup(container);
});
}

Expand Down Expand Up @@ -169,6 +112,63 @@

}

// Responsive layout: switch CodeGroup from sidebar to top tabs when narrow
const CODE_GROUP_NARROW_THRESHOLD = 500;

function setupCodeGroupResponsiveLayout() {
const containers = document.querySelectorAll('[data-code-group-container]');

containers.forEach((container) => {
const body = container.querySelector('[data-code-group-body]') as HTMLElement;
const sidebar = container.querySelector('[data-code-group-sidebar]') as HTMLElement;

if (!body || !sidebar) return;

// Skip if already observed
if (container.hasAttribute('data-code-group-observed')) return;
container.setAttribute('data-code-group-observed', 'true');

let currentLayout: string | null = null;

const observer = new ResizeObserver((entries) => {
for (const entry of entries) {
const width = entry.contentRect.width;
const newLayout = width < CODE_GROUP_NARROW_THRESHOLD ? 'tabs' : 'sidebar';

if (newLayout === currentLayout) continue;
currentLayout = newLayout;

const isNarrow = newLayout === 'tabs';

// Toggle body layout direction
body.classList.toggle('flex-col', isNarrow);

// Toggle sidebar between vertical and horizontal
sidebar.classList.toggle('flex-col', !isNarrow);
sidebar.classList.toggle('w-[160px]', !isNarrow);
sidebar.classList.toggle('py-2', !isNarrow);
sidebar.classList.toggle('overflow-y-auto', !isNarrow);

sidebar.classList.toggle('flex-row', isNarrow);
sidebar.classList.toggle('px-2', isNarrow);
sidebar.classList.toggle('py-1.5', isNarrow);
sidebar.classList.toggle('overflow-x-auto', isNarrow);
sidebar.classList.toggle('gap-1', isNarrow);

// Toggle trigger item classes
sidebar.querySelectorAll('[data-code-group-trigger]').forEach((trigger) => {
trigger.classList.toggle('w-full', !isNarrow);
trigger.classList.toggle('text-left', !isNarrow);
trigger.classList.toggle('whitespace-nowrap', isNarrow);
trigger.classList.toggle('shrink-0', isNarrow);
});
}
});

observer.observe(container);
});
}

const CODE_COLLAPSE_HEIGHT = 500;

function initializeCollapsibleCodeBlocks() {
Expand Down Expand Up @@ -209,10 +209,12 @@
// Run on page load and after view transitions
initializeTabs();
initializeCodeGroups();
setupCodeGroupResponsiveLayout();
initializeCollapsibleCodeBlocks();
document.addEventListener('astro:after-swap', () => {
initializeTabs();
initializeCodeGroups();
setupCodeGroupResponsiveLayout();
initializeCollapsibleCodeBlocks();
});

Expand Down Expand Up @@ -270,30 +272,16 @@
const codeGroupContainer = codeGroupTrigger.closest('[data-code-group-container]');
if (!codeGroupContainer) return;

const isWorkspace = codeGroupContainer.hasAttribute('data-code-group-workspace');

// Update trigger styles
// Update trigger styles (sidebar style)
const triggers = codeGroupContainer.querySelectorAll('[data-code-group-trigger]');
triggers.forEach((trigger) => {
const isActive = trigger.getAttribute('data-code-group-trigger') === triggerId;
if (isWorkspace) {
// Sidebar style
if (isActive) {
trigger.classList.add('text-white', 'bg-white/10');
trigger.classList.remove('text-zinc-500', 'hover:text-zinc-300', 'hover:bg-white/5');
} else {
trigger.classList.remove('text-white', 'bg-white/10');
trigger.classList.add('text-zinc-500', 'hover:text-zinc-300', 'hover:bg-white/5');
}
if (isActive) {
trigger.classList.add('text-white', 'bg-white/10');
trigger.classList.remove('text-zinc-500', 'hover:text-zinc-300', 'hover:bg-white/5');
} else {
// Tab style (underline)
if (isActive) {
trigger.classList.add('border-b-primary', 'text-white');
trigger.classList.remove('border-b-transparent', 'text-muted-foreground');
} else {
trigger.classList.remove('border-b-primary', 'text-white');
trigger.classList.add('border-b-transparent', 'text-muted-foreground');
}
trigger.classList.remove('text-white', 'bg-white/10');
trigger.classList.add('text-zinc-500', 'hover:text-zinc-300', 'hover:bg-white/5');
}
});

Expand Down
Loading
Loading