Theme.stories.tsx 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing,
  13. * software distributed under the License is distributed on an
  14. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
  15. * OF ANY KIND, either express or implied. See the License for the
  16. * specific language governing permissions and limitations
  17. * under the License.
  18. */
  19. import { supersetTheme } from '@superset-ui/core';
  20. const colorTypes = ['primary', 'error', 'warning', 'success', 'info'];
  21. const AntDFunctionalColors = () => {
  22. // Define color types and variants dynamically
  23. const variants = [
  24. 'active',
  25. 'textActive',
  26. 'text',
  27. 'textHover',
  28. 'hover',
  29. 'borderHover',
  30. 'border',
  31. 'bgHover',
  32. 'bg',
  33. ];
  34. return (
  35. <table
  36. style={{ borderCollapse: 'collapse', width: '100%', textAlign: 'left' }}
  37. >
  38. <thead>
  39. <tr>
  40. <th style={{ border: '1px solid #ddd', padding: '8px' }}>Type</th>
  41. {variants.map(variant => (
  42. <th
  43. key={variant}
  44. style={{ border: '1px solid #ddd', padding: '8px' }}
  45. >
  46. {variant}
  47. </th>
  48. ))}
  49. </tr>
  50. </thead>
  51. <tbody>
  52. {colorTypes.map(type => (
  53. <tr key={type}>
  54. <td style={{ border: '1px solid #ddd', padding: '8px' }}>
  55. <strong>{type}</strong>
  56. </td>
  57. {variants.map(variant => {
  58. // Map to actual theme token names
  59. const tokenName = `color${type.charAt(0).toUpperCase() + type.slice(1)}${variant.charAt(0).toUpperCase() + variant.slice(1)}`;
  60. const color = (supersetTheme as any)[tokenName];
  61. return (
  62. <td
  63. key={variant}
  64. style={{
  65. border: '1px solid #ddd',
  66. padding: '8px',
  67. backgroundColor: color || 'transparent',
  68. color: color === 'transparent' ? 'black' : undefined,
  69. }}
  70. >
  71. {color ? <code>{color}</code> : '-'}
  72. </td>
  73. );
  74. })}
  75. </tr>
  76. ))}
  77. </tbody>
  78. </table>
  79. );
  80. };
  81. export const ThemeColors = () => (
  82. <div>
  83. <h1>Theme Colors</h1>
  84. <h2>Ant Design Theme Colors</h2>
  85. <h3>Functional Colors</h3>
  86. <AntDFunctionalColors />
  87. <h2>Current SupersetTheme Object</h2>
  88. <p>The current theme uses Ant Design's flat token structure:</p>
  89. <pre>
  90. <code>{JSON.stringify(supersetTheme, null, 2)}</code>
  91. </pre>
  92. </div>
  93. );
  94. /*
  95. * */
  96. export default {
  97. title: 'Core Packages/@superset-ui-theme',
  98. };
  99. export const Default = () => <ThemeColors />;