tables.tsx 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. import {useContext} from 'react';
  2. import styled from '@emotion/styled';
  3. import Sample, {SampleThemeContext} from 'docs-ui/components/sample';
  4. import space from 'sentry/styles/space';
  5. // eslint-disable-next-line no-restricted-imports
  6. import {lightColors} from 'sentry/utils/theme';
  7. import ColorSwatch from './colorSwatch';
  8. type ColorGroup = {
  9. colors: Array<keyof typeof lightColors>;
  10. id: string;
  11. };
  12. const Wrap = styled('div')`
  13. display: grid;
  14. grid-template-columns: repeat(auto-fit, minmax(16em, 1fr));
  15. gap: ${space(2)};
  16. & > * {
  17. grid-column-end: span 1;
  18. }
  19. `;
  20. const ColorTable = ({colorGroups}: {colorGroups: ColorGroup[]}) => {
  21. const theme = useContext(SampleThemeContext);
  22. return (
  23. <Wrap>
  24. {colorGroups.map(group => {
  25. return <ColorSwatch key={group.id} colors={group.colors} theme={theme} />;
  26. })}
  27. </Wrap>
  28. );
  29. };
  30. const neutralColors: ColorGroup[] = [
  31. {
  32. id: 'gray500',
  33. colors: ['gray500'],
  34. },
  35. {
  36. id: 'gray400',
  37. colors: ['gray400'],
  38. },
  39. {
  40. id: 'gray300',
  41. colors: ['gray300'],
  42. },
  43. {
  44. id: 'gray200',
  45. colors: ['gray200'],
  46. },
  47. {
  48. id: 'gray100',
  49. colors: ['gray100'],
  50. },
  51. ];
  52. const accentColors: ColorGroup[] = [
  53. {
  54. id: 'purple',
  55. colors: ['purple400', 'purple300', 'purple200', 'purple100'],
  56. },
  57. {
  58. id: 'blue',
  59. colors: ['blue400', 'blue300', 'blue200', 'blue100'],
  60. },
  61. {
  62. id: 'green',
  63. colors: ['green400', 'green300', 'green200', 'green100'],
  64. },
  65. {
  66. id: 'yellow',
  67. colors: ['yellow400', 'yellow300', 'yellow200', 'yellow100'],
  68. },
  69. {
  70. id: 'red',
  71. colors: ['red400', 'red300', 'red200', 'red100'],
  72. },
  73. {
  74. id: 'Pink',
  75. colors: ['pink400', 'pink300', 'pink200', 'pink100'],
  76. },
  77. ];
  78. export const NeutralTable = () => (
  79. <Sample showThemeSwitcher>
  80. <ColorTable colorGroups={neutralColors} />
  81. </Sample>
  82. );
  83. export const AccentTable = () => (
  84. <Sample showThemeSwitcher>
  85. <ColorTable colorGroups={accentColors} />
  86. </Sample>
  87. );