From 2935842387169ff12a985c0688c383a90b204caf Mon Sep 17 00:00:00 2001
From: Isaac Hellendag <2823852+hellendag@users.noreply.github.com>
Date: Mon, 22 Apr 2024 15:20:11 -0500
Subject: [PATCH] [ui] Repair Polars logo for dark mode (#21341)
## Summary & Motivation
Resolves https://github.com/dagster-io/dagster/issues/19261.
Added an OpTags storybook example to show all of the possible tags.
## How I Tested These Changes
yarn storybook, switch between light/dark.
---
.../packages/ui-core/src/graph/OpTags.tsx | 24 ++++++++++++++++---
.../src/graph/__stories__/OpTags.stories.tsx | 18 ++++++++++++++
.../ui-core/src/insights/InsightsIcon.tsx | 5 ++--
3 files changed, 41 insertions(+), 6 deletions(-)
create mode 100644 js_modules/dagster-ui/packages/ui-core/src/graph/__stories__/OpTags.stories.tsx
diff --git a/js_modules/dagster-ui/packages/ui-core/src/graph/OpTags.tsx b/js_modules/dagster-ui/packages/ui-core/src/graph/OpTags.tsx
index b0adb5cda56da..b992278699294 100644
--- a/js_modules/dagster-ui/packages/ui-core/src/graph/OpTags.tsx
+++ b/js_modules/dagster-ui/packages/ui-core/src/graph/OpTags.tsx
@@ -94,7 +94,14 @@ interface OpTagsProps {
reversed?: boolean;
}
-export const KNOWN_TAGS = {
+type KnownTag = {
+ color: string | null;
+ icon?: StaticImageData | string;
+ content: string;
+ reversed?: boolean;
+};
+
+export const KNOWN_TAGS: Record = {
jupyter: {
color: '#929292',
icon: jupyter,
@@ -412,6 +419,7 @@ export const KNOWN_TAGS = {
color: '#24292E',
icon: polars,
content: 'Polars',
+ reversed: true,
},
catboost: {
color: null,
@@ -577,6 +585,15 @@ export const AssetComputeKindTag = ({
);
};
+export const extractIconSrc = (knownTag: KnownTag | undefined) => {
+ // Storybook imports SVGs are string but nextjs imports them as object.
+ // This is a temporary work around until we can get storybook to import them the same way as nextjs
+ if (typeof knownTag?.icon !== 'undefined') {
+ return typeof knownTag.icon === 'string' ? (knownTag.icon as any) : knownTag.icon?.src;
+ }
+ return '';
+};
+
export const OpTags = React.memo(({tags, style, reduceColor, reduceText}: OpTagsProps) => {
return (
@@ -587,6 +604,7 @@ export const OpTags = React.memo(({tags, style, reduceColor, reduceText}: OpTags
// This is useful when the icon requires mulltiple colors. like Airflow.
const color = known?.color || null;
const reversed = known && 'reversed' in known ? known.reversed : false;
+
return (
{
{
+ const tags: IOpTag[] = Object.keys(KNOWN_TAGS).map((label) => ({label, onClick: () => {}}));
+ return (
+
+
+
+ );
+};
diff --git a/js_modules/dagster-ui/packages/ui-core/src/insights/InsightsIcon.tsx b/js_modules/dagster-ui/packages/ui-core/src/insights/InsightsIcon.tsx
index 5626eeca7db83..44a2512411adc 100644
--- a/js_modules/dagster-ui/packages/ui-core/src/insights/InsightsIcon.tsx
+++ b/js_modules/dagster-ui/packages/ui-core/src/insights/InsightsIcon.tsx
@@ -1,7 +1,7 @@
// eslint-disable-next-line no-restricted-imports
import {Colors, Icon, IconName, IconNames, IconWrapper} from '@dagster-io/ui-components';
-import {KNOWN_TAGS} from '../graph/OpTags';
+import {KNOWN_TAGS, extractIconSrc} from '../graph/OpTags';
type IntegrationIconName = keyof typeof KNOWN_TAGS;
export type InsightsIconType = IconName | IntegrationIconName;
@@ -17,12 +17,11 @@ export const InsightsIcon = (props: InsightsIconProps) => {
return ;
} else {
const known = KNOWN_TAGS[props.name as IntegrationIconName];
- const src = 'icon' in known ? known.icon.src : '';
return (