diff --git a/src/components/navigation-header/components/sandbox-dropdown/__tests__/sandbox-dropdown.test.tsx b/src/components/navigation-header/components/sandbox-dropdown/__tests__/sandbox-dropdown.test.tsx index 954a923625..87f436d024 100644 --- a/src/components/navigation-header/components/sandbox-dropdown/__tests__/sandbox-dropdown.test.tsx +++ b/src/components/navigation-header/components/sandbox-dropdown/__tests__/sandbox-dropdown.test.tsx @@ -59,7 +59,7 @@ describe('SandboxDropdown', () => { // Click to open fireEvent.click(button) - expect(screen.getByText('HashiCorp Sandboxes')).toBeInTheDocument() + expect(screen.getByText('Vault Sandboxes')).toBeInTheDocument() // Click to close fireEvent.click(button) @@ -75,7 +75,7 @@ describe('SandboxDropdown', () => { // Open dropdown fireEvent.click(button) - expect(screen.getByText('HashiCorp Sandboxes')).toBeInTheDocument() + expect(screen.getByText('Vault Sandboxes')).toBeInTheDocument() // Press escape fireEvent.keyDown(button, { key: 'Escape' }) @@ -91,7 +91,7 @@ describe('SandboxDropdown', () => { // Open dropdown fireEvent.click(button) - expect(screen.getByText('HashiCorp Sandboxes')).toBeInTheDocument() + expect(screen.getByText('Vault Sandboxes')).toBeInTheDocument() // Click outside fireEvent.mouseDown(document.body) diff --git a/src/components/navigation-header/components/sandbox-dropdown/index.tsx b/src/components/navigation-header/components/sandbox-dropdown/index.tsx index 0f1573dea9..182d7d189e 100644 --- a/src/components/navigation-header/components/sandbox-dropdown/index.tsx +++ b/src/components/navigation-header/components/sandbox-dropdown/index.tsx @@ -6,7 +6,6 @@ import { KeyboardEvent, useRef, useState } from 'react' import { useId } from '@react-aria/utils' import { IconChevronDown16 } from '@hashicorp/flight-icons/svg-react/chevron-down-16' -import { IconArrowRight16 } from '@hashicorp/flight-icons/svg-react/arrow-right-16' import { useRouter } from 'next/router' import { useCurrentProduct } from 'contexts' import { useInstruqtEmbed } from 'contexts/instruqt-lab' @@ -23,6 +22,7 @@ import s from './sandbox-dropdown.module.css' import { SandboxLab } from 'types/sandbox' import { ProductSlug } from 'types/products' import { buildLabIdWithConfig } from 'lib/build-instruqt-url' +import { useTheme } from 'next-themes' interface SandboxDropdownProps { ariaLabel: string @@ -47,6 +47,8 @@ const SandboxDropdown = ({ ariaLabel, label }: SandboxDropdownProps) => { lab.products.includes(currentProduct.slug) ) + const isOnSandboxPage = router.query?.productSlug === currentProduct?.slug + // Handles closing the menu if there is a click outside of it and it is open. useOnClickOutside([menuRef], () => setIsOpen(false), isOpen) @@ -146,8 +148,23 @@ const SandboxDropdown = ({ ariaLabel, label }: SandboxDropdownProps) => { setIsOpen(false) } + const { theme, systemTheme } = useTheme() + const isLightTheme = + theme === 'light' || (theme === 'system' && systemTheme === 'light') return ( -
+
- - {/* Divider */} -
+ {/* Available Product Sandboxes Section */} { - const trackName = lab.instruqtTrack?.split('/').pop() || lab.labId + const trackName = + lab.instruqtTrack?.split('/').pop()?.split('?')[0] || lab.labId return ( lab.labId === newLabId || lab.labId === baseLabId || trackName === baseLabId || - lab.instruqtTrack === newLabId + lab.instruqtTrack === newLabId || + lab.instruqtTrack?.split('?')[0] === baseLabId || + (lab.scenario && newLabId.includes(lab.scenario)) ) }) @@ -253,8 +254,6 @@ function InstruqtProvider({ children }: InstruqtProviderProps): JSX.Element { if (newLabId !== labId || !active) { setLabId(newLabId) setActive(true) - - // Track sandbox open event immediately trackSandboxEvent(SANDBOX_EVENT.SANDBOX_OPEN, { labId: newLabId, page: router.asPath, diff --git a/src/pages/[productSlug]/sandbox/sandbox.module.css b/src/pages/[productSlug]/sandbox/sandbox.module.css index 204f3a80fb..746b657ec6 100644 --- a/src/pages/[productSlug]/sandbox/sandbox.module.css +++ b/src/pages/[productSlug]/sandbox/sandbox.module.css @@ -59,19 +59,30 @@ .sandboxCard { cursor: pointer; transition: transform 0.2s ease, box-shadow 0.2s ease; - width: 80vw; max-width: 420px; + width: 100%; + height: 100%; + box-sizing: border-box; + display: flex; + flex-direction: column; &:hover { transform: translateY(-2px); box-shadow: var(--token-elevation-high-box-shadow); } @media (max-width: 900px) { + max-width: 100%; width: 100%; - max-width: none; } } +.card { + width: 100%; + height: 100%; + display: flex; + flex-direction: column; +} + .otherSandboxCard { cursor: pointer; transition: transform 0.2s ease, box-shadow 0.2s ease; @@ -156,3 +167,18 @@ line-height: var(--token-typography-body-200-line-height); } } + +.cardsFlexContainer { + display: flex; + flex-wrap: wrap; + gap: 2rem; + justify-content: flex-start; +} + +.sandboxGrid li, +.sandboxGrid > div, +.sandboxGrid > div > div { + height: 100%; + width: 100%; + box-sizing: border-box; +}