Skip to content

Commit

Permalink
Add options and theme props advertised in 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
paulsmirnov committed Aug 9, 2024
1 parent 7007c47 commit bb7d3eb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
9 changes: 5 additions & 4 deletions packages/miew-react/src/Viewer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,16 @@ function destroyMiewRef(miewRef) {
}

// eslint-disable-next-line react/prop-types
export default function Viewer({ onInit }) {
export default function Viewer({ onInit, options }) {
const miewRef = useRef();
const rootRef = useRef();

useLayoutEffect(() => {
const settings = { axes: false, fps: false };
createMiewRef(miewRef, { container: rootRef.current, settings }, onInit);
// eslint-disable-next-line react/prop-types
const settings = { axes: false, fps: false, ...options?.settings };
createMiewRef(miewRef, { ...options, container: rootRef.current, settings }, onInit);
return () => destroyMiewRef(miewRef);
}, [onInit]);
}, [onInit, options]);

return (
<div className={styles.root} ref={rootRef}>
Expand Down
8 changes: 7 additions & 1 deletion packages/miew-react/types/Viewer.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ import { Miew } from 'miew';

declare type ViewerProps = {
onInit?: (miew: Miew) => void;
options?: { [key: string]: any };
theme?: any;
};

declare const Viewer: ({ onInit }: ViewerProps) => import('@emotion/react/jsx-runtime').JSX.Element;
declare const Viewer: ({
onInit,
options,
theme,
}: ViewerProps) => import('@emotion/react/jsx-runtime').JSX.Element;
export default Viewer;

0 comments on commit bb7d3eb

Please sign in to comment.