mistercrunch commented on code in PR #31590: URL: https://github.com/apache/superset/pull/31590#discussion_r1968719133
########## superset-frontend/packages/superset-ui-core/src/theme/Theme.tsx: ########## @@ -0,0 +1,352 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +/* eslint-disable react-prefer-function-component/react-prefer-function-component */ +// eslint-disable-next-line no-restricted-syntax +import React from 'react'; +import { + theme as antdThemeImport, + ThemeConfig as AntdThemeConfig, + ConfigProvider, +} from 'antd-v5'; +import tinycolor from 'tinycolor2'; + +import { + ThemeProvider as EmotionThemeProvider, + CacheProvider as EmotionCacheProvider, +} from '@emotion/react'; +import createCache from '@emotion/cache'; +// import { merge } from 'lodash'; + +import { + AntdTokens, + SupersetTheme, + allowedAntdTokens, + SharedAntdTokens, + SystemColors, + ColorVariants, + DeprecatedColorVariations, + DeprecatedThemeColors, + LegacySupersetTheme, + FontSizeKey, +} from './types'; + +/* eslint-disable theme-colors/no-literal-colors */ + +export class Theme { + theme: SupersetTheme; + + private static readonly defaultTokens = { + // Default colors + colorPrimary: '#20a7c9', + colorError: '#e04355', + colorWarning: '#fcc700', + colorSuccess: '#5ac189', + colorInfo: '#66bcfe', + + // Forcing some default tokens + fontFamily: `'Inter', Helvetica, Arial`, + fontFamilyCode: `'Fira Code', 'Courier New', monospace`, + + // Extra tokens + transitionTiming: 0.3, + brandIconMaxWidth: 37, + fontSizeXS: '8', + fontSizeXXL: '28', + fontWeightNormal: '400', + fontWeightLight: '300', + fontWeightMedium: '500', + }; + + private antdConfig: AntdThemeConfig; + + private static readonly sizeMap: Record<FontSizeKey, string> = { + xs: 'fontSizeXS', + s: 'fontSizeSM', Review Comment: I hear you, had similar thoughts but decided to commit to the AntD token semantics that are well documented and supported across AntD components and beyond. More on it here -> https://ant.design/docs/react/customize-theme . Oh I get that we could match their 2 letters code in `FontSizeKey`, but I think it's defined elsewhere and used across places (didn't grep, but afraid to find I'd have to touch a bunch of files). Could be done as a follow up as this is all still an internal API -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org For additional commands, e-mail: notifications-h...@superset.apache.org