209 |
221 |
{
225 | notWrappingCopyRef.current = el;
226 | notWrappingCopyRefCb(el);
227 | }}
228 | style={{
229 | ...invisibleStyle,
230 | flexWrap: "nowrap",
231 | }}
232 | >
233 |
234 | {children && typeof children === "function"
235 | ? children(false)
236 | : children}
237 |
238 |
239 |
240 |
251 |
{
255 | wrappingCopyRef.current = el;
256 | wrappingCopyRefCb(el);
257 | }}
258 | style={{
259 | ...invisibleStyle,
260 | flexWrap: "wrap",
261 | }}
262 | >
263 |
264 | {children && typeof children === "function"
265 | ? children(false)
266 | : children}
267 |
268 |
269 |
270 |
290 |
303 |
304 | {children && typeof children === "function"
305 | ? children(isWrapped)
306 | : children}
307 |
308 |
309 |
310 |
311 | );
312 | }
313 |
--------------------------------------------------------------------------------
/src/usage/ExampleSelector.tsx:
--------------------------------------------------------------------------------
1 | import { ChevronsUpDownIcon } from "lucide-react";
2 | import {
3 | ReactElement,
4 | useEffect,
5 | useLayoutEffect,
6 | useMemo,
7 | useState,
8 | } from "react";
9 | import {
10 | DropdownMenu,
11 | DropdownMenuContent,
12 | DropdownMenuRadioGroup,
13 | DropdownMenuRadioItem,
14 | DropdownMenuTrigger,
15 | } from "../components/ui/dropdown-menu";
16 | import { AdaptingContentExampleCE } from "./custom-element-react-examples/AdaptingContentExampleCE";
17 | import { BasicUsageExampleCE } from "./custom-element-react-examples/BasicUsageExampleCE";
18 | import { ConditionallyNestedExampleCE } from "./custom-element-react-examples/ConditionallyNestedExampleCE";
19 | import { DeepNestingExampleCE } from "./custom-element-react-examples/DeepNestingExampleCE";
20 | import { DynamicContentExampleCE } from "./custom-element-react-examples/DynamicContentExampleCE";
21 | import { InfiniteLoopCE } from "./custom-element-react-examples/InfiniteLoopCE";
22 | import { NestedExampleCE } from "./custom-element-react-examples/NestedExampleCE";
23 | import { OrderAndReverseCE } from "./custom-element-react-examples/OrderAndReverseCE";
24 | import { SingleChildExampleCE } from "./custom-element-react-examples/SingleChildExampleCE";
25 | import { AdaptingContentExample } from "./examples/AdaptingContentExample";
26 | import { AllPropsShowcaseExample } from "./examples/AllPropsShowcaseExample";
27 | import { BasicUsageExample } from "./examples/BasicUsageExample";
28 | import { ConditionallyNestedExample } from "./examples/ConditionallyNestedExample";
29 | import { DeepNestingExample } from "./examples/DeepNestingExample";
30 | import { HolyGrailToolbarExample } from "./examples/HolyGrailToolbarExample";
31 | import { InfiniteLoop } from "./examples/InfiniteLoop";
32 | import { NestedExample } from "./examples/NestedExample";
33 | import { OrderAndReverse } from "./examples/OrderAndReverse";
34 | import { SingleChildExample } from "./examples/SingleChildExample";
35 | import { SmallerHeight } from "./examples/SmallerHeight";
36 | import adaptingContentMutatingHtml from "./html-examples/adapting-content-mutating.html?raw";
37 | import adaptingContentHtml from "./html-examples/adapting-content.html?raw";
38 | import basicExampleHtml from "./html-examples/basic-usage.html?raw";
39 | import conditionallyNestedHtml from "./html-examples/conditionally-nested.html?raw";
40 | import deepNestingHtml from "./html-examples/deep-nesting.html?raw";
41 | import dynamicContentHtml from "./html-examples/dynamic-content.html?raw";
42 | import holyGrailHtml from "./html-examples/holy-grail.html?raw";
43 | import singleChildHtml from "./html-examples/single-child.html?raw";
44 | import twoLevelsNestingHtml from "./html-examples/two-levels-nesting.html?raw";
45 | import { Resizer } from "./Resizer";
46 |
47 | export function ExampleSelector() {
48 | const [reactExample, setReactExample] = useState("Basic Usage");
49 | const [htmlExample, setHtmlExample] = useState("Basic Usage");
50 |
51 | // show all examples / including internal ones that are more like
52 | // test and don't really showcase anything
53 | const [showAll, setShowAll] = useState(false);
54 | const [showCEReact, setShowCEReact] = useState(false);
55 |
56 | useEffect(() => {
57 | const searchParams = new URLSearchParams(window.location.search);
58 | setShowAll(searchParams.has("show-all"));
59 | setShowCEReact(searchParams.has("show-ce"));
60 | if (searchParams.has("show-ce")) {
61 | setReactExample("CE Basic Usage");
62 | }
63 | }, []);
64 |
65 | let reactDemoExamples: Map