mistercrunch commented on issue #20159:
URL: https://github.com/apache/superset/issues/20159#issuecomment-2701757965
Here's another option: leverage/extend Component-specific overrides to
support the long tail of configurability.
Here's an example of how component-level overrides are defined (standard
AntD ThemeConfig)
```
import type { ThemeConfig } from 'antd';
const theme: ThemeConfig = {
token: {
colorPrimary: '#1890ff',
borderRadius: 6,
fontFamily: "Comic Sans",
fontSize: "10",
},
components: {
Viz: {
fontFamily: "Verdana",
fontSize: "10",
},
TableViz: {
fontFamily: "Monospace",
fontSize: "8",
},
},
};
export default theme;
```
Here's how the viz plugin could get a handle on the theme, with some
specific context
```js
// defining the context of the theme, here I'm using 2 component
"namespaces", saying essentially
// "fetch all the tokens, but make sure to apply overrides for Viz and
TableViz (in that order of precedence)"
const context = ['Viz', 'TableViz']
// Here we have our own `useTheme` method that will apply the right token
overrides
const theme = theme.useTheme(context)
// In this case, fontFamily matches the most specific "context" passed to
the call
assert theme.fontFamily == "Monospace"
```
In this approach, we don't create more tokens, we just offer a way for
themers to target specific namespaces with overrides.
--
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]