diff --git a/packages/@react-spectrum/s2/style/spectrum-theme.ts b/packages/@react-spectrum/s2/style/spectrum-theme.ts index cf626c62aee..281c759c421 100644 --- a/packages/@react-spectrum/s2/style/spectrum-theme.ts +++ b/packages/@react-spectrum/s2/style/spectrum-theme.ts @@ -760,10 +760,14 @@ export const style = createTheme({ code: 'source-code-pro, "Source Code Pro", Monaco, monospace' }, fontSize: new ExpandedProperty(['fontSize', 'lineHeight'], (value) => { - return { - '--fs': `pow(1.125, ${value})`, - fontSize: `round(${fontSizeCalc} / 16 * 1rem, 1px)` - }; + if (typeof value === 'number') { + return { + '--fs': `pow(1.125, ${value})`, + fontSize: `round(${fontSizeCalc} / 16 * 1rem, 1px)` + } as CSSProperties; + } + + return {fontSize: value}; }, fontSize), fontWeight: new ExpandedProperty(['fontWeight', 'fontVariationSettings', 'fontSynthesisWeight'], (value) => { return { diff --git a/packages/dev/s2-docs/pages/s2/SelectBoxGroup.mdx b/packages/dev/s2-docs/pages/s2/SelectBoxGroup.mdx index 140e21dba65..49dd45914c4 100644 --- a/packages/dev/s2-docs/pages/s2/SelectBoxGroup.mdx +++ b/packages/dev/s2-docs/pages/s2/SelectBoxGroup.mdx @@ -5,8 +5,9 @@ export default Layout; import docs from 'docs:@react-spectrum/s2'; export const tags = ['box']; +export const version = 'alpha'; -# SelectBoxGroup +# SelectBoxGroup {docs.exports.SelectBoxGroup.description} diff --git a/packages/dev/s2-docs/pages/s2/Toast.mdx b/packages/dev/s2-docs/pages/s2/Toast.mdx index 2ed3f80e3de..c240cbc4750 100644 --- a/packages/dev/s2-docs/pages/s2/Toast.mdx +++ b/packages/dev/s2-docs/pages/s2/Toast.mdx @@ -7,8 +7,9 @@ import {InterfaceType} from '../../src/types'; import {VersionBadge} from '../../src/VersionBadge'; export const tags = ['snackbar', 'notification', 'alert']; +export const version = 'alpha'; -# Toast +# Toast {docs.exports.UNSTABLE_ToastContainer.description} diff --git a/packages/dev/s2-docs/src/Code.tsx b/packages/dev/s2-docs/src/Code.tsx index 5fb710bdbe0..4bbf0940519 100644 --- a/packages/dev/s2-docs/src/Code.tsx +++ b/packages/dev/s2-docs/src/Code.tsx @@ -28,8 +28,10 @@ const mark = style({ borderWidth: 0, borderStartWidth: 2, borderStyle: 'solid', - marginX: 'calc(var(--code-padding-x) * -1)', - paddingX: 'calc(var(--code-padding-x) - self(borderStartWidth))', + marginStart: 'calc(var(--code-padding-start) * -1)', + marginEnd: 'calc(var(--code-padding-end) * -1)', + paddingStart: 'calc(var(--code-padding-start) - self(borderStartWidth))', + paddingEnd: '--code-padding-end', color: 'inherit' }); diff --git a/packages/dev/s2-docs/src/CodeBlock.tsx b/packages/dev/s2-docs/src/CodeBlock.tsx index 8a1264ca091..d5b016beb0e 100644 --- a/packages/dev/s2-docs/src/CodeBlock.tsx +++ b/packages/dev/s2-docs/src/CodeBlock.tsx @@ -24,11 +24,15 @@ const example = style({ }); const standaloneCode = style({ - '--code-padding-x': { - type: 'paddingTop', + '--code-padding-start': { + type: 'paddingStart', value: 32 }, - padding: '--code-padding-x', + '--code-padding-end': { + type: 'paddingEnd', + value: 32 + }, + padding: '--code-padding-start', marginY: 32, backgroundColor: 'layer-1', borderRadius: 'xl', @@ -89,7 +93,7 @@ export function CodeBlock({render, children, files, expanded, hidden, hideExampl ); return ( -
+
@@ -128,9 +132,11 @@ function TruncatedCode({children, maxLines = 6, ...props}: TruncatedCodeProps) { ) : ( -
-      {children}
-    
+
+
+        {children}
+      
+
); } diff --git a/packages/dev/s2-docs/src/CodePlatter.tsx b/packages/dev/s2-docs/src/CodePlatter.tsx index e687a89c5a7..ad7146a8651 100644 --- a/packages/dev/s2-docs/src/CodePlatter.tsx +++ b/packages/dev/s2-docs/src/CodePlatter.tsx @@ -7,27 +7,30 @@ import {createStackBlitz} from './StackBlitz'; import Download from '@react-spectrum/s2/icons/Download'; import {iconStyle, style} from '@react-spectrum/s2/style' with {type: 'macro'}; import {Key} from 'react-aria'; +import {Library} from './library'; import LinkIcon from '@react-spectrum/s2/icons/Link'; import OpenIn from '@react-spectrum/s2/icons/OpenIn'; import Polygon4 from '@react-spectrum/s2/icons/Polygon4'; import Prompt from '@react-spectrum/s2/icons/Prompt'; -import React, {ReactNode, useEffect, useRef, useState} from 'react'; +import React, {createContext, ReactNode, useContext, useEffect, useRef, useState} from 'react'; import {zip} from './zip'; const platterStyle = style({ backgroundColor: 'layer-2', borderRadius: 'lg', - '--code-padding-x': { - type: 'paddingTop', + '--code-padding-start': { + type: 'paddingStart', + value: 16 + }, + '--code-padding-end': { + type: 'paddingEnd', value: 16 }, '--code-padding-y': { type: 'paddingTop', value: 16 }, - position: 'relative', - maxHeight: 600, - overflow: 'auto' + position: 'relative' }); interface CodePlatterProps { @@ -38,21 +41,38 @@ interface CodePlatterProps { registryUrl?: string } +interface CodePlatterContextValue { + library: Library +} + +const CodePlatterContext = createContext({library: 'react-spectrum'}); +export function CodePlatterProvider(props: CodePlatterContextValue & {children: any}) { + return {props.children}; +} + export function CodePlatter({children, shareUrl, files, type, registryUrl}: CodePlatterProps) { let codeRef = useRef(null); let [showShadcn, setShowShadcn] = useState(false); let getText = () => codeRef.current!.querySelector('pre')!.textContent!; + let {library} = useContext(CodePlatterContext); + if (!type) { + if (library === 'react-aria') { + type = 'vanilla'; + } else if (library === 'react-spectrum') { + type = 's2'; + } + } return (
-
+
- {(shareUrl || files || type || registryUrl) && + {(shareUrl || files || type || registryUrl) && @@ -167,9 +187,23 @@ export function CodePlatter({children, shareUrl, files, type, registryUrl}: Code ); } +const pre = style({ + borderRadius: 'lg', + font: { + default: 'code-xs', + lg: 'code-sm' + }, + margin: 0, + paddingStart: '--code-padding-start', + paddingEnd: '--code-padding-end', + paddingY: '--code-padding-y', + width: 'fit', + minWidth: 'full' +}); + export function Pre({children}) { return ( -
+    
       {children}
     
); @@ -250,7 +284,7 @@ function ShadcnDialog({registryUrl}) { flexDirection: 'column', gap: 16 })}> - + npm yarn pnpm diff --git a/packages/dev/s2-docs/src/ExampleOutput.tsx b/packages/dev/s2-docs/src/ExampleOutput.tsx index c633299c96d..9cbbce510b3 100644 --- a/packages/dev/s2-docs/src/ExampleOutput.tsx +++ b/packages/dev/s2-docs/src/ExampleOutput.tsx @@ -12,7 +12,9 @@ interface ExampleOutputProps { export function ExampleOutput({component, props = {}, align = 'center', orientation = 'horizontal'}: ExampleOutputProps) { return ( -
- + {examples.map(example => {example})}
@@ -133,7 +133,13 @@ export function ExampleSwitcher({type = 'style', examples = DEFAULT_EXAMPLES, ch labelPosition="side" value={theme} onChange={onThemeChange} - styles={themePicker}> + styles={themePicker} + contextualHelp={ + + Vanilla CSS theme + This sets the --tint CSS variable used by the Vanilla CSS examples. + + }> Indigo Blue Cyan diff --git a/packages/dev/s2-docs/src/ExpandableCode.tsx b/packages/dev/s2-docs/src/ExpandableCode.tsx index 73791ef27ca..53ae4d37fc3 100644 --- a/packages/dev/s2-docs/src/ExpandableCode.tsx +++ b/packages/dev/s2-docs/src/ExpandableCode.tsx @@ -9,11 +9,11 @@ const example = style({ font: 'code-lg', maxHeight: { default: '[6lh]', - isExpanded: 'unset' + isExpanded: 800 }, overflow: { default: 'clip', - isExpanded: 'visible' + isExpanded: 'auto' }, position: 'relative', width: 'full', @@ -24,6 +24,13 @@ const example = style({ default: 'none', isExpanded: 'inline' } + }, + '--code-padding-end': { + type: 'paddingEnd', + value: { + default: 16, + isExpanded: 64 // Extra space for the toolbar + } } }); @@ -50,8 +57,8 @@ export function ExpandableCode({children, hasHighlightedLine}: {children: ReactN mask = 'linear-gradient(transparent, white 25% 50%, transparent), linear-gradient(to right, white 0% 85%, transparent)'; padding = '0px'; } else { - // only mask the bottom - mask = 'linear-gradient(white 0% 50%, transparent)'; + // only mask the bottom and right + mask = 'linear-gradient(white 0% 50%, transparent), linear-gradient(to right, white 0% 85%, transparent)'; } } diff --git a/packages/dev/s2-docs/src/Layout.tsx b/packages/dev/s2-docs/src/Layout.tsx index 072dca8fd11..5deae053fe0 100644 --- a/packages/dev/s2-docs/src/Layout.tsx +++ b/packages/dev/s2-docs/src/Layout.tsx @@ -12,8 +12,10 @@ import './anatomy.css'; import {ClassAPI} from './ClassAPI'; import {Code} from './Code'; import {CodeBlock} from './CodeBlock'; +import {CodePlatterProvider} from './CodePlatter'; import {ExampleSwitcher} from './ExampleSwitcher'; -import {getLibraryFromPage, getLibraryLabel} from './library'; +import {getLibraryFromPage, getLibraryFromUrl, getLibraryLabel} from './library'; +import {getTextWidth} from './textWidth'; import {H2, H3, H4} from './Headings'; import Header from './Header'; import {Link} from './Link'; @@ -23,10 +25,21 @@ import {PropTable} from './PropTable'; import {StateTable} from './StateTable'; import {style} from '@react-spectrum/s2/style' with {type: 'macro'}; import {TypeLink} from './types'; +import {VersionBadge} from './VersionBadge'; import {VisualExample} from './VisualExample'; +const h1 = style({ + font: 'heading-3xl', + fontSize: { + // On mobile, adjust heading to fit in the viewport, and clamp between a min and max font size. + default: 'clamp(35px, (100vw - 32px) / var(--width-per-em), 55px)', + lg: 'heading-3xl' + }, + marginY: 0 +}); + const components = { - h1: ({children, ...props}) =>

{children}

, + h1: ({children, ...props}) =>

{children}

, h2: H2, h3: H3, h4: H4, @@ -226,10 +239,13 @@ export function Layout(props: PageProps & {children: ReactElement}) { lg: 'auto' } })}> -
- {React.cloneElement(children, {components})} -
+ +
+ {currentPage.exports?.version && } + {React.cloneElement(children, {components})} +
+
{hasToC &&