Skip to content

Conversation

@alisonjlai
Copy link
Contributor

@alisonjlai alisonjlai commented Sep 23, 2025

Adds a new style API with

  • Add style on PluginInstance. Defines the PluginStyle type, currently supporting backgroundColor.
  • getStyle() – fetches the current style config via wb:plugin:style:get
  • subscribeToStyle() – listens for live updates via wb:plugin:style:update
  • Implements a usePluginStyle() React hook

Will update readme when this is finalized.

Sample plugin app:

function App() {
  const styleColors = usePluginStyle();

  return (
    <div
      style={{ backgroundColor: styleColors?.backgroundColor }}
    >
        ...
    </div>
  );

},

style: {
subscribeToStyle(callback: (style: any) => void) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

super small, can we just call these subscribe and get? Makes more sense to do style.subscribe() than style.subscribeToStyle()

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you change getStyle to get?

peternandersson
peternandersson previously approved these changes Oct 6, 2025
Copy link
Contributor

@peternandersson peternandersson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise, LGTM

},

style: {
subscribe(callback: (style: any) => void) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
subscribe(callback: (style: any) => void) {
subscribe(callback: (style: PluginStyle) => void) {

@alisonjlai alisonjlai merged commit b11330f into main Oct 7, 2025
1 check passed
@alisonjlai alisonjlai deleted the alison/format-color-plugin branch October 7, 2025 18:44
@alisonjlai alisonjlai changed the title Adds usePluginStyle hook and PluginStyle type [Style API] Adds usePluginStyle hook and PluginStyle type Oct 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants