mistercrunch commented on code in PR #31590:
URL: https://github.com/apache/superset/pull/31590#discussion_r1930903668


##########
superset-frontend/packages/superset-ui-core/src/theme/types.ts:
##########
@@ -0,0 +1,334 @@
+/**
+ * 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 @typescript-eslint/no-unused-vars */
+// eslint-disable-next-line no-restricted-syntax
+import { theme as antdThemeImport } from 'antd-v5';
+
+/**
+ * Grab all antd tokens via getDesignToken(...).
+ * (Same as in the original file.)
+ */
+export type AntdTokens = ReturnType<typeof antdThemeImport.getDesignToken>;
+
+/** Minimal color system references. */
+export interface SystemColors {
+  colorPrimary: string;
+  colorError: string;
+  colorWarning: string;
+  colorSuccess: string;
+  colorInfo: string;
+}
+
+export interface ColorVariants {
+  bg: string;
+  border: string;
+  hover: string;
+  active: string;
+  textHover: string;
+  text: string;
+  borderHover: string;
+  bgHover: string;
+  textActive: string;
+}
+
+export interface DeprecatedColorVariations {
+  base: string;
+  light1: string;
+  light2: string;
+  light3: string;
+  light4: string;
+  light5: string;
+  dark1: string;
+  dark2: string;
+  dark3: string;
+  dark4: string;
+  dark5: string;
+}
+
+export interface DeprecatedThemeColors {
+  primary: DeprecatedColorVariations;
+  error: DeprecatedColorVariations;
+  warning: DeprecatedColorVariations;
+  success: DeprecatedColorVariations;
+  info: DeprecatedColorVariations;
+  grayscale: DeprecatedColorVariations;
+}
+
+export interface LegacySupersetTheme {
+  // Old colors structure with light/dark semantics still heavily referenced 
in code base
+  // TODO: replace/realign with antd-type tokens
+  colors: DeprecatedThemeColors;
+  transitionTiming: number;
+}
+
+export interface SupersetSpecificTokens {
+  // Brand-related
+  brandIconMaxWidth: number;
+
+  // Font-related
+  fontSizeXS: string;
+  fontSizeXXL: string;
+  fontWeightNormal: string;
+  fontWeightLight: string;
+  fontWeightMedium: string;
+}
+
+/**
+ * This array is used to define which keys from the full Antd token set
+ * we actually allow in the SupersetTheme.
+ */
+export const allowedAntdTokens = [

Review Comment:
   ### about the token list
   About allowing/denying certain tokens, I started with a deny list of 
patterns, mostly filtering out they're "system colors" 
(https://ant.design/docs/spec/colors#system-level-color-system) as I wanted 
only the "functional colors" to flow through. We do have needs around data viz 
palettes but felt like functional colors were not the right thing for us. I 
really polluted the token namespace with lots of things I'd argue that we 
shouldn't use in Superset.
   
   I'd say we really need a flood gate here, and though being explicit about it 
was right, and proper ts types are really needed here, so that the compiler can 
tell you if you're imagining tokens or not.
   
   I'd say we could be more thoughtful about limiting this list, but didn't 
want to run a process to classify all tokens (useful/not-useful) as it's pretty 
subjective and in many ways AntD's team has done that work already.
   
   # about sizing/spacing
   Unclear what we want to do here, but allowing for a more `compact` theme 
would be achieved through these tokens. It would be interesting to apply AntD's 
compactAlgorightm and what it looks like for Superset. Haven't done it yet but 
should be super easy to just apply it and take a tour of the app. 



##########
superset-frontend/packages/superset-ui-core/src/theme/types.ts:
##########
@@ -0,0 +1,334 @@
+/**
+ * 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 @typescript-eslint/no-unused-vars */
+// eslint-disable-next-line no-restricted-syntax
+import { theme as antdThemeImport } from 'antd-v5';
+
+/**
+ * Grab all antd tokens via getDesignToken(...).
+ * (Same as in the original file.)
+ */
+export type AntdTokens = ReturnType<typeof antdThemeImport.getDesignToken>;
+
+/** Minimal color system references. */
+export interface SystemColors {
+  colorPrimary: string;
+  colorError: string;
+  colorWarning: string;
+  colorSuccess: string;
+  colorInfo: string;
+}
+
+export interface ColorVariants {
+  bg: string;
+  border: string;
+  hover: string;
+  active: string;
+  textHover: string;
+  text: string;
+  borderHover: string;
+  bgHover: string;
+  textActive: string;
+}
+
+export interface DeprecatedColorVariations {
+  base: string;
+  light1: string;
+  light2: string;
+  light3: string;
+  light4: string;
+  light5: string;
+  dark1: string;
+  dark2: string;
+  dark3: string;
+  dark4: string;
+  dark5: string;
+}
+
+export interface DeprecatedThemeColors {
+  primary: DeprecatedColorVariations;
+  error: DeprecatedColorVariations;
+  warning: DeprecatedColorVariations;
+  success: DeprecatedColorVariations;
+  info: DeprecatedColorVariations;
+  grayscale: DeprecatedColorVariations;
+}
+
+export interface LegacySupersetTheme {
+  // Old colors structure with light/dark semantics still heavily referenced 
in code base
+  // TODO: replace/realign with antd-type tokens
+  colors: DeprecatedThemeColors;
+  transitionTiming: number;
+}
+
+export interface SupersetSpecificTokens {
+  // Brand-related
+  brandIconMaxWidth: number;
+
+  // Font-related
+  fontSizeXS: string;
+  fontSizeXXL: string;
+  fontWeightNormal: string;
+  fontWeightLight: string;
+  fontWeightMedium: string;
+}
+
+/**
+ * This array is used to define which keys from the full Antd token set
+ * we actually allow in the SupersetTheme.
+ */
+export const allowedAntdTokens = [

Review Comment:
   ### about the token list
   About allowing/denying certain tokens, I started with a deny list of 
patterns, mostly filtering out they're "system colors" 
(https://ant.design/docs/spec/colors#system-level-color-system) as I wanted 
only the "functional colors" to flow through. We do have needs around data viz 
palettes but felt like functional colors were not the right thing for us. I 
really polluted the token namespace with lots of things I'd argue that we 
shouldn't use in Superset.
   
   I'd say we really need a flood gate here, and though being explicit about it 
was right, and proper ts types are really needed here, so that the compiler can 
tell you if you're imagining tokens or not.
   
   I'd say we could be more thoughtful about limiting this list, but didn't 
want to run a process to classify all tokens (useful/not-useful) as it's pretty 
subjective and in many ways AntD's team has done that work already.
   
   ### about sizing/spacing
   Unclear what we want to do here, but allowing for a more `compact` theme 
would be achieved through these tokens. It would be interesting to apply AntD's 
compactAlgorightm and what it looks like for Superset. Haven't done it yet but 
should be super easy to just apply it and take a tour of the app. 



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to