File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change 88 WorkbookElementData ,
99 WorkbookSelection ,
1010 WorkbookVariable ,
11+ PluginThemeColors ,
1112} from '../types' ;
1213import { deepEqual } from '../utils/deepEqual' ;
1314
@@ -246,3 +247,19 @@ export function useActionEffect(configId: string, effect: () => void) {
246247 return client . config . registerEffect ( configId , effectRef . current ) ;
247248 } , [ client , configId , effect ] ) ;
248249}
250+
251+ /**
252+ * React hook for accessing workbook theme colors with live updates
253+ * @returns {PluginThemeColors | undefined } Theme colors from the workbook if available
254+ */
255+ export function useThemeColors ( ) : PluginThemeColors | undefined {
256+ const client = usePlugin ( ) ;
257+ const [ themeColors , setThemeColors ] = useState ( client . themeColors ) ;
258+
259+ useEffect ( ( ) => {
260+ setThemeColors ( client . themeColors ) ;
261+ return client . subscribeToThemeColors ( setThemeColors ) ;
262+ } , [ client ] ) ;
263+
264+ return themeColors ;
265+ }
You can’t perform that action at this time.
0 commit comments