import React from 'react'; import classNames from 'classnames'; import scrollIntoView from 'scroll-into-view'; import highlightElement from './helpers/highlight'; import Variant from './Variant'; type TestProps = { pickedVariants: { [testId: string]: string; }; onChangeVariant: (testId: string, variantId: string) => void; } & TestData; function findTestElementById(id: string): HTMLElement | null { return document.querySelector(`.ABTestWrapper[data-test="${id}"]`); } const Test: React.FC = ({ id, title, isEnabled, variants, pickedVariants, onChangeVariant, }) => { const onHover = (): void => { const element = findTestElementById(id); if (!element) return; scrollIntoView(element); highlightElement(id, element); }; return (
  • {title}
      {variants.map((variant) => ( onChangeVariant(id, variantId)} isSelected={pickedVariants[id] === variant.id} /> ))}
  • ); }; export default Test;