searchResultWrapper.tsx 803 B

12345678910111213141516171819202122232425262728293031323334
  1. import * as React from 'react';
  2. import {css} from '@emotion/react';
  3. import styled from '@emotion/styled';
  4. interface Props extends React.HTMLAttributes<HTMLDivElement> {
  5. highlighted?: boolean;
  6. }
  7. function scrollIntoView(element: HTMLDivElement) {
  8. element?.scrollIntoView?.(true);
  9. }
  10. const SearchResultWrapper = styled(({highlighted, ...props}: Props) => (
  11. <div {...props} ref={highlighted ? scrollIntoView : undefined} />
  12. ))`
  13. cursor: pointer;
  14. display: block;
  15. color: ${p => p.theme.textColor};
  16. padding: 10px;
  17. scroll-margin: 120px;
  18. ${p =>
  19. p.highlighted &&
  20. css`
  21. color: ${p.theme.purple300};
  22. background: ${p.theme.backgroundSecondary};
  23. `};
  24. &:not(:first-child) {
  25. border-top: 1px solid ${p => p.theme.innerBorder};
  26. }
  27. `;
  28. export default SearchResultWrapper;