diff --git a/ui/apps/platform/src/Components/CodeViewer.cy.jsx b/ui/apps/platform/src/Components/CodeViewer.cy.jsx index 9457d6d90c8ac..8e65d9c97e409 100644 --- a/ui/apps/platform/src/Components/CodeViewer.cy.jsx +++ b/ui/apps/platform/src/Components/CodeViewer.cy.jsx @@ -42,13 +42,16 @@ describe(Cypress.spec.relative, () => { cy.mount(); // Default to light mode - cy.get('.pf-v5-theme-dark').should('not.exist'); + cy.get('[data-component-theme="light"]').should('exist'); + cy.get('[data-component-theme="dark"]').should('not.exist'); cy.get('button[aria-label="Set dark theme"]').click(); - cy.get('.pf-v5-theme-dark'); + cy.get('[data-component-theme="light"]').should('not.exist'); + cy.get('[data-component-theme="dark"]').should('exist'); cy.get('button[aria-label="Set light theme"]').click(); - cy.get('.pf-v5-theme-dark').should('not.exist'); + cy.get('[data-component-theme="light"]').should('exist'); + cy.get('[data-component-theme="dark"]').should('not.exist'); }); it('should share theme state across multiple instances', () => { @@ -59,18 +62,21 @@ describe(Cypress.spec.relative, () => { ); - cy.get('.pf-v5-theme-dark').should('not.exist'); + cy.get('[data-component-theme="light"]').should('have.length', 2); + cy.get('[data-component-theme="dark"]').should('have.length', 0); cy.get('button[aria-label="Set dark theme"]').eq(0); cy.get('button[aria-label="Set dark theme"]').eq(1); cy.get('button[aria-label="Set dark theme"]').eq(0).click(); - cy.get('.pf-v5-theme-dark').should('have.length', 2); + cy.get('[data-component-theme="light"]').should('have.length', 0); + cy.get('[data-component-theme="dark"]').should('have.length', 2); cy.get('button[aria-label="Set light theme"]').eq(0); cy.get('button[aria-label="Set light theme"]').eq(1); cy.get('button[aria-label="Set light theme"]').eq(1).click(); - cy.get('.pf-v5-theme-dark').should('not.exist'); + cy.get('[data-component-theme="light"]').should('have.length', 2); + cy.get('[data-component-theme="dark"]').should('have.length', 0); }); }); diff --git a/ui/apps/platform/src/Components/CodeViewer.tsx b/ui/apps/platform/src/Components/CodeViewer.tsx index 8a0effec417b2..f3d1b1fb8dba4 100644 --- a/ui/apps/platform/src/Components/CodeViewer.tsx +++ b/ui/apps/platform/src/Components/CodeViewer.tsx @@ -45,6 +45,15 @@ const defaultStyle = { overflowY: 'auto', } as const; +const lightThemeStyles = {} as const; + +// TODO This should be deleted when we move to proper PatternFly theming +const darkThemeStyles = { + '--pf-t--global--background--color--secondary--default': 'var(--pf-t--color--gray--95)', + '--pf-t--global--text--color--regular': 'var(--pf-t--color--white)', + '--pf-t--global--icon--color--regular': 'var(--pf-t--color--white)', +} as const; + export type CodeViewerProps = { code: string; language?: SupportedLanguages; @@ -94,11 +103,14 @@ export default function CodeViewer({ ); + const themeStyles = theme === 'light' ? lightThemeStyles : darkThemeStyles; + // TODO - When Tailwind is removed, we likely need to get rid of this font size override return ( .pf-v6-c-table__check { min-width: 44px; diff --git a/ui/apps/platform/src/services/PDFExportService.ts b/ui/apps/platform/src/services/PDFExportService.ts index a914106c8c57f..5518ab4c43b4a 100644 --- a/ui/apps/platform/src/services/PDFExportService.ts +++ b/ui/apps/platform/src/services/PDFExportService.ts @@ -62,24 +62,10 @@ function createPDFBodyElement() { * @param {HTMLElement} element */ function computeStyles(element) { - const isThemeDark = document.body.className.includes('theme-dark'); - - // if dark mode is enabled, we want to switch to light mode for exporting to PDF - if (isThemeDark) { - document.body.classList.remove('theme-dark'); - document.body.classList.add('theme-light'); - } - computedStyleToInlineStyle(element, { recursive: true, properties: ['width', 'height', 'fill', 'style', 'class', 'stroke', 'font', 'font-size'], }); - - // if dark mode was previously enabled, we want to switch back after styles are computed - if (isThemeDark) { - document.body.classList.remove('theme-light'); - document.body.classList.add('theme-dark'); - } } /**