Skip to content

Commit 8c17148

Browse files
committed
Add some native HTML attributes <perspective-viewer>
Signed-off-by: Andrew Stein <steinlink@gmail.com>
1 parent 6907ef9 commit 8c17148

2 files changed

Lines changed: 23 additions & 1 deletion

File tree

examples/react-example/src/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ const App: React.FC = () => {
124124
<>
125125
<PerspectiveViewer table={state.table} />
126126
<PerspectiveViewer
127+
className="my-perspective-viewer"
127128
table={state.table}
128129
config={state.config}
129130
onClick={onClick}

packages/perspective-react/src/index.tsx

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,16 @@ export interface PerspectiveViewerProps {
3434
onConfigUpdate?: (config: pspViewer.ViewerConfigUpdate) => void;
3535
onClick?: (data: pspViewer.PerspectiveClickEventDetail) => void;
3636
onSelect?: (data: pspViewer.PerspectiveSelectEventDetail) => void;
37+
38+
// Applicable props from `React.HTMLAttributes`, which we cannot extend
39+
// directly because Perspective changes the signature of `onClick`.
40+
className?: string | undefined;
41+
hidden?: boolean | undefined;
42+
id?: string | undefined;
43+
slot?: string | undefined;
44+
style?: React.CSSProperties | undefined;
45+
tabIndex?: number | undefined;
46+
title?: string | undefined;
3747
}
3848

3949
function PerspectiveViewerImpl(props: PerspectiveViewerProps) {
@@ -64,7 +74,18 @@ function PerspectiveViewerImpl(props: PerspectiveViewerProps) {
6474
usePspListener(viewer, "perspective-select", props.onSelect);
6575
usePspListener(viewer, "perspective-config-update", props.onConfigUpdate);
6676

67-
return <perspective-viewer ref={setViewer} />;
77+
return (
78+
<perspective-viewer
79+
ref={setViewer}
80+
id={props.id}
81+
className={props.className}
82+
hidden={props.hidden}
83+
slot={props.slot}
84+
style={props.style}
85+
tabIndex={props.tabIndex}
86+
title={props.title}
87+
/>
88+
);
6889
}
6990

7091
/**

0 commit comments

Comments
 (0)