diff --git a/apps/remix-ide/src/app/components/vertical-icons.js b/apps/remix-ide/src/app/components/vertical-icons.js index 6f92f3f729..f1c3827c8d 100644 --- a/apps/remix-ide/src/app/components/vertical-icons.js +++ b/apps/remix-ide/src/app/components/vertical-icons.js @@ -163,6 +163,15 @@ export class VerticalIcons extends Plugin { this.events.emit('showContent', name) } + onThemeChanged (themeType) { + const invert = themeType === 'dark' ? 1 : 0 + const active = this.view.querySelector('.active') + if (active) { + const image = active.querySelector('.image') + image.style.setProperty('filter', `invert(${invert})`) + } + } + /** * Toggles the side panel for plugin * @param {string} name Name of profile of the module to activate diff --git a/libs/remix-ui/vertical-icons-panel/src/lib/components/Settings.tsx b/libs/remix-ui/vertical-icons-panel/src/lib/components/Settings.tsx index db15eeaa7e..79239158d8 100644 --- a/libs/remix-ui/vertical-icons-panel/src/lib/components/Settings.tsx +++ b/libs/remix-ui/vertical-icons-panel/src/lib/components/Settings.tsx @@ -1,7 +1,7 @@ /* eslint-disable no-use-before-define */ // eslint-disable-next-line @typescript-eslint/no-unused-vars import { VerticalIcons } from 'libs/remix-ui/vertical-icons-panel/types/vertical-icons-panel' -import React, { useEffect } from 'react' +import React, { useEffect, useRef } from 'react' import { Chevron } from './Chevron' import Icon from './Icon' @@ -11,25 +11,30 @@ interface SettingsProps { addActive: (name: string) => void removeActive: () => void scrollableRef: React.MutableRefObject - onThemeChanged: (themeType: any) => void } -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function Settings ({ scrollableRef, verticalIconsPlugin, itemContextAction, addActive, removeActive, onThemeChanged }: SettingsProps) { - useEffect(() => { - // const themeModule = verticalIconsPlugin.registry.get('themeModule').api - // themeModule.events.on('themeChanged', (theme: any) => { - // onThemeChanged(theme.quality) - // }) - return () => { - document.addEventListener('themeChanged', (theme: any) => { - // onThemeChanged(theme.quality) - console.log('this is what theme contains', theme) - }) +function Settings ({ scrollableRef, verticalIconsPlugin, itemContextAction, addActive, removeActive }: SettingsProps) { + const settingsRef = useRef(null) + function onThemeChanged (themeType: any) { + const invert = themeType === 'dark' ? 1 : 0 + // @ts-ignore + const active = settingsRef.current.querySelector('.active') + if (active) { + // @ts-ignore + const image = settingsRef.current.querySelector('.remixui_image') + image.style.setProperty('filter', `invert(${invert})`) } - }) + } + + useEffect(() => { + const themeModule = verticalIconsPlugin.registry.get('themeModule').api + themeModule.events.on('themeChanged', (theme: any) => { + onThemeChanged(theme.quality) + console.log('There was a theme change and is caught in settings. This is the theme payload ', theme) + }) + }, []) return ( -
+
{ onThemeChanged(theme.quality) + console.log('There was a theme change. This is the theme payload ', theme) }) }, []) @@ -83,6 +84,7 @@ export function RemixUiVerticalIconsPanel ({ const themeModule = verticalIconsPlugin.registry.get('themeModule').api themeModule.events.on('themeChanged', (theme: any) => { onThemeChanged(theme.quality) + console.log('There was a theme change. This is the theme payload ', theme) }) }, []) @@ -130,7 +132,6 @@ export function RemixUiVerticalIconsPanel ({ removeActive={removeActive} itemContextAction={itemContextAction} scrollableRef={scrollableRef} - onThemeChanged={onThemeChanged} /> ) : null}