-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
116 additions
and
27 deletions.
There are no files selected for viewing
This file contains 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 characters
21 changes: 21 additions & 0 deletions
21
packages/malloy-render/src/component/malloy-modal/malloy-modal-wc.tsx
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import {ComponentOptions} from 'component-register'; | ||
|
||
export type MalloyModalWCProps = { | ||
stylesheet?: CSSStyleSheet; | ||
}; | ||
|
||
export function MalloyModalWC( | ||
props: MalloyModalWCProps, | ||
{element}: ComponentOptions | ||
) { | ||
const root = element.renderRoot; | ||
if (root instanceof ShadowRoot && props.stylesheet) { | ||
root.adoptedStyleSheets.push(props.stylesheet); | ||
} | ||
|
||
/* | ||
Move child nodes into ShadowDOM. This probably only works if modal root elements stay consistent. | ||
*/ | ||
const allChildren = [...element['childNodes']]; | ||
return <div>{...allChildren}</div>; | ||
} |
32 changes: 32 additions & 0 deletions
32
packages/malloy-render/src/component/malloy-modal/malloy-modal.tsx
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import {Portal} from 'solid-js/web'; | ||
import {JSX, JSXElement} from 'solid-js'; | ||
import {useConfig} from '../render'; | ||
|
||
export function MalloyModal(props: { | ||
style?: string | JSX.CSSProperties; | ||
children?: JSXElement; | ||
ref?: HTMLDivElement | ((el: HTMLDivElement) => void); | ||
}) { | ||
const config = useConfig(); | ||
return ( | ||
<Portal mount={config.modalElement}> | ||
<div ref={props.ref} style={props.style}> | ||
<div> | ||
<malloy-modal stylesheet={config.stylesheet}> | ||
<div>{props.children}</div> | ||
</malloy-modal> | ||
</div> | ||
</div> | ||
</Portal> | ||
); | ||
} | ||
|
||
declare module 'solid-js' { | ||
// eslint-disable-next-line @typescript-eslint/no-namespace | ||
namespace JSX { | ||
interface IntrinsicElements { | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
'malloy-modal': any; | ||
} | ||
} | ||
} |
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters