Skip to content

Commit

Permalink
readability
Browse files Browse the repository at this point in the history
  • Loading branch information
mayank99 committed Mar 26, 2024
1 parent 314da76 commit ddf15f4
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions packages/itwinui-react/src/core/utils/components/ShadowRoot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,15 @@ const supportsDSD =
const supportsAdoptedStylesheets =
isBrowser && 'adoptedStyleSheets' in Document.prototype;

type ShadowRootProps = { children: React.ReactNode; css?: string };

/**
* Wrapper around `<template>` element that attaches shadow root to its parent
* and moves its children into the shadow root.
*
* @private
*/
export const ShadowRoot = ({
children,
css,
}: {
children: React.ReactNode;
css?: string;
}) => {
export const ShadowRoot = ({ children, css }: ShadowRootProps) => {
const isFirstRender = useIsFirstRender();

if (!isBrowser) {
Expand All @@ -47,13 +43,7 @@ export const ShadowRoot = ({

// ----------------------------------------------------------------------------

const ClientShadowRoot = ({
children,
css,
}: {
children: React.ReactNode;
css?: string;
}) => {
const ClientShadowRoot = ({ children, css }: ShadowRootProps) => {
const templateRef = React.useRef<HTMLTemplateElement>(null);
const shadowRoot = useShadowRoot(templateRef, { css });

Expand Down

0 comments on commit ddf15f4

Please sign in to comment.