Skip to content

Commit 5682370

Browse files
committed
feat(devtools): add SEO tab navigation and enhance SocialPreviewsSection
This commit introduces a navigation bar in the SeoTab component, allowing users to switch between 'Social Previews' and 'SERP Preview' sections. It also updates the SocialPreviewsSection to conditionally render its title based on a new prop, improving flexibility in display options. New styles for the navigation elements are added to enhance the user interface.
1 parent a2f1d81 commit 5682370

4 files changed

Lines changed: 103 additions & 8 deletions

File tree

packages/devtools/src/styles/use-styles.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,32 @@ const stylesFactory = (theme: DevtoolsStore['settings']['theme']) => {
119119
margin-bottom: 2rem;
120120
border-radius: 0.75rem;
121121
`,
122+
seoSubNav: css`
123+
display: flex;
124+
flex-direction: row;
125+
gap: 0;
126+
margin-bottom: 1rem;
127+
border-bottom: 1px solid ${t(colors.gray[200], colors.gray[800])};
128+
`,
129+
seoSubNavLabel: css`
130+
padding: 0.5rem 1rem;
131+
font-size: 0.875rem;
132+
font-weight: 500;
133+
color: ${t(colors.gray[600], colors.gray[400])};
134+
background: none;
135+
border: none;
136+
border-bottom: 2px solid transparent;
137+
margin-bottom: -1px;
138+
cursor: pointer;
139+
font-family: inherit;
140+
&:hover {
141+
color: ${t(colors.gray[800], colors.gray[200])};
142+
}
143+
`,
144+
seoSubNavLabelActive: css`
145+
color: ${t(colors.gray[900], colors.gray[100])};
146+
border-bottom-color: ${t(colors.gray[900], colors.gray[100])};
147+
`,
122148
seoPreviewSection: css`
123149
display: flex;
124150
flex-direction: row;
Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,39 @@
1+
import { Show, createSignal } from 'solid-js'
12
import { MainPanel } from '@tanstack/devtools-ui'
3+
import { useStyles } from '../../styles/use-styles'
24
import { SocialPreviewsSection } from './social-previews'
5+
import { SerpPreviewSection } from './serp-preview'
6+
7+
type SeoSubView = 'social-previews' | 'serp-preview'
38

49
export const SeoTab = () => {
10+
const [activeView, setActiveView] = createSignal<SeoSubView>('social-previews')
11+
const styles = useStyles()
12+
513
return (
614
<MainPanel withPadding>
7-
<SocialPreviewsSection />
15+
<nav class={styles().seoSubNav} aria-label="SEO sections">
16+
<button
17+
type="button"
18+
class={`${styles().seoSubNavLabel} ${activeView() === 'social-previews' ? styles().seoSubNavLabelActive : ''}`}
19+
onClick={() => setActiveView('social-previews')}
20+
>
21+
Social previews
22+
</button>
23+
<button
24+
type="button"
25+
class={`${styles().seoSubNavLabel} ${activeView() === 'serp-preview' ? styles().seoSubNavLabelActive : ''}`}
26+
onClick={() => setActiveView('serp-preview')}
27+
>
28+
SERP Preview
29+
</button>
30+
</nav>
31+
<Show when={activeView() === 'social-previews'}>
32+
<SocialPreviewsSection noTitle />
33+
</Show>
34+
<Show when={activeView() === 'serp-preview'}>
35+
<SerpPreviewSection noTitle />
36+
</Show>
837
</MainPanel>
938
)
1039
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import {
2+
Section,
3+
SectionDescription,
4+
SectionIcon,
5+
SectionTitle,
6+
} from '@tanstack/devtools-ui'
7+
import { PageSearch } from '@tanstack/devtools-ui/icons'
8+
9+
const DUMMY_SERP = {
10+
title: 'Example Page Title - Your Site Name',
11+
description:
12+
'This is a short meta description that shows how your page might appear in Google search results. Keep it under 160 characters.',
13+
url: 'https://example.com/page-path',
14+
}
15+
16+
export function SerpPreviewSection(props: { noTitle?: boolean } = {}) {
17+
return (
18+
<Section>
19+
{!props.noTitle && (
20+
<SectionTitle>
21+
<SectionIcon>
22+
<PageSearch />
23+
</SectionIcon>
24+
SERP Preview
25+
</SectionTitle>
26+
)}
27+
<SectionDescription>
28+
See how your title tag and meta description to see your website's SERP
29+
snippet preview in Google search results.
30+
</SectionDescription>
31+
<div>
32+
<p>{DUMMY_SERP.title}</p>
33+
<p>{DUMMY_SERP.description}</p>
34+
<p>{DUMMY_SERP.url}</p>
35+
</div>
36+
</Section>
37+
)
38+
}

packages/devtools/src/tabs/seo-tab/social-previews.tsx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ function SocialPreview(props: {
146146
)
147147
}
148148

149-
export function SocialPreviewsSection() {
149+
export function SocialPreviewsSection(props: { noTitle?: boolean } = {}) {
150150
const [reports, setReports] = createSignal<Array<SocialReport>>(analyzeHead())
151151
const styles = useStyles()
152152

@@ -184,12 +184,14 @@ export function SocialPreviewsSection() {
184184

185185
return (
186186
<Section>
187-
<SectionTitle>
188-
<SectionIcon>
189-
<SocialBubble />
190-
</SectionIcon>
191-
Social previews
192-
</SectionTitle>
187+
{!props.noTitle && (
188+
<SectionTitle>
189+
<SectionIcon>
190+
<SocialBubble />
191+
</SectionIcon>
192+
Social previews
193+
</SectionTitle>
194+
)}
193195
<SectionDescription>
194196
See how your current page will look when shared on popular social
195197
networks. The tool checks for essential meta tags and highlights any

0 commit comments

Comments
 (0)