UNPKG

cherry-styled-components

Version:

Cherry is a design system for the modern web. Designed in Figma, built in React using Typescript.

24 lines (23 loc) 893 B
"use client"; "use client"; import { Fragment, jsx } from "react/jsx-runtime"; import { useState } from "react"; import { useServerInsertedHTML } from "next/navigation"; import { ServerStyleSheet, StyleSheetManager } from "styled-components"; //#region src/lib/styled-components/registry.tsx function StyledComponentsRegistry({ children }) { const [styledComponentsStyleSheet] = useState(() => new ServerStyleSheet()); const isServer = typeof window === "undefined"; useServerInsertedHTML(() => { const styles = styledComponentsStyleSheet.getStyleElement(); styledComponentsStyleSheet.instance.clearTag(); return /* @__PURE__ */ jsx(Fragment, { children: styles }); }); return /* @__PURE__ */ jsx(StyleSheetManager, { sheet: isServer ? styledComponentsStyleSheet.instance : void 0, enableVendorPrefixes: true, children }); } //#endregion export { StyledComponentsRegistry };