Skip to content

Commit 63853e3

Browse files
BillLeoutsakosvl346Bill Leoutsakos
andauthored
refactor(emcn): share product page heading recipe (#8253)
* improvement(ui): share product page heading recipe * test: include shared heading export in logs error mock --------- Co-authored-by: Bill Leoutsakos <billleoutsakos@Bills-MacBook-Pro.local>
1 parent 7b21069 commit 63853e3

7 files changed

Lines changed: 19 additions & 10 deletions

File tree

‎apps/sim/app/o/[organizationId]/home/organization-home.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use client'
22

33
import { useCallback, useEffect, useState, useSyncExternalStore } from 'react'
4-
import { toast } from '@sim/emcn'
4+
import { cn, pageHeadingClassName, toast } from '@sim/emcn'
55
import { useQueryClient } from '@tanstack/react-query'
66
import Link from 'next/link'
77
import { useQueryStates } from 'nuqs'
@@ -388,7 +388,7 @@ function OrganizationHomeContent({
388388
<div className='min-h-0 flex-1 overflow-y-auto [scrollbar-gutter:stable_both-edges]'>
389389
{/* Asymmetric padding biases the group up so the full cluster (heading + input + steps) sits at the optical center */}
390390
<div className='flex min-h-full flex-col items-center justify-center px-6 pt-[2vh] pb-[22vh]'>
391-
<h1 className='mb-7 max-w-chat text-balance font-season text-[26px] text-[var(--text-primary)] leading-[1.15] tracking-[-0.01em] sm:text-[28px]'>
391+
<h1 className={cn(pageHeadingClassName, 'mb-7 max-w-chat')}>
392392
{requestMode === 'assistant'
393393
? `Search ${organization.name}`
394394
: requestMode === 'plan'

‎apps/sim/app/o/[organizationId]/search/search-results-view.tsx‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
import { type ReactNode, useRef } from 'react'
2-
import { cn, scrollFadeAttributes, scrollFadeClass, useScrollEdges } from '@sim/emcn'
2+
import {
3+
cn,
4+
pageHeadingClassName,
5+
scrollFadeAttributes,
6+
scrollFadeClass,
7+
useScrollEdges,
8+
} from '@sim/emcn'
39
import { HEADER_ACTION_CLUSTER, PAGE_HEADER_BAR } from '@/components/page-header-bar'
410
import type { WorkspaceSearchFilters } from '@/lib/api/contracts/knowledge'
511
import type { SearchResource } from '@/lib/mothership/generated/resources'
@@ -70,7 +76,7 @@ export function SearchResultsView({
7076
<div className='min-h-0 flex-1 overflow-y-auto [scrollbar-gutter:stable_both-edges]'>
7177
{/* Asymmetric padding biases the group up so heading and field sit at the optical center, as on Home */}
7278
<div className='flex min-h-full flex-col items-center justify-center px-6 pt-[2vh] pb-[22vh]'>
73-
<h1 className='mb-7 max-w-chat text-balance font-season text-[26px] text-[var(--text-primary)] leading-[1.15] tracking-[-0.01em] sm:text-[28px]'>
79+
<h1 className={cn(pageHeadingClassName, 'mb-7 max-w-chat')}>
7480
Search {organization.name}
7581
</h1>
7682
<div className='w-full max-w-chat'>{composer}</div>

‎apps/sim/app/workspace/[workspaceId]/components/error/error.tsx‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use client'
22

33
import { type ReactNode, useEffect } from 'react'
4-
import { Chip } from '@sim/emcn'
4+
import { Chip, pageHeadingClassName } from '@sim/emcn'
55
import { TriangleAlert } from '@sim/emcn/icons'
66
import { createLogger } from '@sim/logger'
77

@@ -43,9 +43,7 @@ export function ErrorShell({ title, description, icon, children }: ErrorShellPro
4343
</div>
4444
</div>
4545
<div className='flex flex-col items-center gap-2'>
46-
<h2 className='text-balance font-season text-[26px] text-[var(--text-primary)] leading-[1.15] tracking-[-0.01em] sm:text-[28px]'>
47-
{title}
48-
</h2>
46+
<h2 className={pageHeadingClassName}>{title}</h2>
4947
<p className='max-w-[340px] text-[14px] text-[var(--text-tertiary)] leading-[1.55]'>
5048
{description}
5149
</p>

‎apps/sim/app/workspace/[workspaceId]/home/home.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use client'
22

33
import { useCallback, useEffect, useRef, useState } from 'react'
4-
import { cn, toast } from '@sim/emcn'
4+
import { cn, pageHeadingClassName, toast } from '@sim/emcn'
55
import { createLogger } from '@sim/logger'
66
import { useQueryClient } from '@tanstack/react-query'
77
import { useParams } from 'next/navigation'
@@ -434,7 +434,7 @@ function HomeContent({ chatId, userName, userId }: HomeProps) {
434434
<div className='h-full overflow-y-auto [scrollbar-gutter:stable_both-edges]'>
435435
{/* Asymmetric padding biases the group up so the full cluster (heading + input + suggestions) sits at the optical center */}
436436
<div className='flex min-h-full flex-col items-center justify-center px-6 pt-[2vh] pb-[22vh]'>
437-
<h1 className='mb-7 max-w-chat text-balance font-season text-[26px] text-[var(--text-primary)] leading-[1.15] tracking-[-0.01em] sm:text-[28px]'>
437+
<h1 className={cn(pageHeadingClassName, 'mb-7 max-w-chat')}>
438438
What should we get done{firstName ? `, ${firstName}` : ''}?
439439
</h1>
440440
<div ref={initialViewInputRef} className='relative w-full max-w-chat'>

‎apps/sim/app/workspace/[workspaceId]/logs/error.test.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { createRoot, type Root } from 'react-dom/client'
66
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
77

88
vi.mock('@sim/emcn', () => ({
9+
pageHeadingClassName: 'test-page-heading',
910
Chip: ({ children, ...props }: { children: ReactNode } & Record<string, unknown>) => (
1011
<button {...props}>{children}</button>
1112
),

‎packages/emcn/src/components/index.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ export {
198198
overflowTextClipClass,
199199
overflowTextFadeClass,
200200
} from './overflow-text/overflow-text'
201+
export { pageHeadingClassName } from './page-heading/page-heading'
201202
export {
202203
Popover,
203204
PopoverAnchor,
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/** Typography shared by the centered product page and error headings. */
2+
export const pageHeadingClassName =
3+
'text-balance font-season text-[26px] text-[var(--text-primary)] leading-[1.15] tracking-[-0.01em] sm:text-[28px]'

0 commit comments

Comments
 (0)