Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. import React from 'react';
  2. import styled, { ThemeProvider } from 'styled-components';
  3.  
  4. type Props = {
  5. children: React.ReactNode;
  6. };
  7.  
  8. function Cell(props: Props) {
  9. const theme = {
  10. color: convertColor(props.children),
  11. };
  12.  
  13. function convertColor(value: any) {
  14. switch (value) {
  15. case 1:
  16. return 'tomato';
  17. case 2:
  18. return 'royalblue';
  19. }
  20. }
  21.  
  22. return (
  23. <ThemeProvider theme={theme}>
  24. <StyledCell>{props.children}</StyledCell>
  25. </ThemeProvider>
  26. );
  27. }
  28.  
  29. export const StyledCell = styled.td`
  30. display: flex;
  31. justify-content: center;
  32. align-items: center;
  33. inline-size: 50px;
  34. block-size: 50px;
  35. margin: 5px;
  36. border: 1px solid black;
  37. border-radius: 50%;
  38. font-size: 0;
  39. background-color: ${(props) => props.theme.color} !important;
  40. user-select: none;
  41. `;
  42.  
  43. export default Cell;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement