Skip to content

Commit c699997

Browse files
committed
add hook
1 parent 496cbc5 commit c699997

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/react/hooks.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
WorkbookElementData,
99
WorkbookSelection,
1010
WorkbookVariable,
11+
PluginStyle,
1112
} from '../types';
1213
import { deepEqual } from '../utils/deepEqual';
1314

@@ -246,3 +247,15 @@ 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 plugin style properties
253+
* @returns {PluginStyle} Style properties
254+
*/
255+
export function usePluginStyle(): PluginStyle {
256+
const client = useConfig();
257+
258+
return {
259+
backgroundColor: client?.backgroundColor,
260+
};
261+
}

src/types.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@ export type ScalarType = 'boolean' | 'datetime' | 'number' | 'integer' | 'text';
22
export type PrimitiveType = ScalarType | 'variant' | 'link';
33
export type ValueType = PrimitiveType | 'error';
44

5+
/**
6+
* Style properties that can be configured through the plugin format panel
7+
*/
8+
export interface PluginStyle {
9+
backgroundColor?: string;
10+
}
11+
512
/**
613
* All mutable workbook control variable types
714
*/

0 commit comments

Comments
 (0)