Created
May 21, 2025 22:37
-
-
Save romgrk/023d376d54f38812c2ba3f91b96eace0 to your computer and use it in GitHub Desktop.
Revisions
-
romgrk created this gist
May 21, 2025 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,65 @@ 'use client'; import * as React from 'react'; import { Flex } from '@joy-ui/react'; import { useRenderElement } from '@base-ui-components/react'; import './page.css'; import './perf-test.css' export default function Home() { const [show, setShow] = React.useState(false) return ( <Flex direction='column'> <h1>Test</h1> <button onClick={() => setShow(!show)}>run</button> {show && <Wrapper />} </Flex> ); } function Button(props: any) { const { render, className, ...otherProps } = props; otherProps.className = 'Button' const state = React.useMemo( () => ({ open: true, side: 'bottom', align: 'left', uncentered: true, }), [], ); const element = useRenderElement('button', props, { state, props: otherProps, }); return element; } function Wrapper() { return ( <div> {Array.from({ length: 10 }).map((i) => <div key={i as any}> <Button>test</Button> <Button>test</Button> <Button>test</Button> <Button>test</Button> <Button>test</Button> <Button>test</Button> <Button>test</Button> <Button>test</Button> <Button>test</Button> <Button>test</Button> </div> )} </div> ) } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,29 @@ .Button { &[data-open] { color: red; } &[data-side="bottom"] { border: 1px solid red; } &[data-align="left"] { background-color: rgba(255, 0, 0, 0.1); } &[data-uncentered] { border-style: dashed; } } .Button { &.state-open { color: red; } &.state-side--bottom { border: 1px solid red; } &.state-align--left { background-color: rgba(255, 0, 0, 0.1); } &.state-uncentered { border-style: dashed; } }