-
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.
Merge pull request #2013 from malloydata/feat/tooltip-anchoring
feat: tooltip anchoring
- Loading branch information
Showing
5 changed files
with
112 additions
and
24 deletions.
There are no files selected for viewing
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>; | ||
} |
30 changes: 30 additions & 0 deletions
30
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,30 @@ | ||
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}> | ||
<malloy-modal stylesheet={config.stylesheet}> | ||
<div ref={props.ref} style={props.style}> | ||
{props.children} | ||
</div> | ||
</malloy-modal> | ||
</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