Skip to content

Conversation

@bacurrah
Copy link
Contributor

@bacurrah bacurrah commented Oct 29, 2025

View the current build

Closes #27
Closes #23

This PR refactors Widget state into a serializable format that can be easily saved and loaded.
This format includes per-widget settings that automatically appear in the Settings menu.

Adding a new widget

  1. Import your widget into WidgetMap.tsx
  2. Add a new entry to WidgetMap. It should use the following format:
    const WidgetMap = {
      mywidget: {                        // Lowercase name, this is used for serialization
        component: MyWidget,             // The widget type you imported
        size: { width: 2, height: 1 },   // The default size of the widget
        resizable: { x: true, y: true }, // (Optional) Disables resizing on one or both axes
      },
    };

Adding widget settings

  1. Create a new interface in your Widget file

    export interface MyWidgetSettings {
      settingOne: boolean;
      settingTwo: string;
    }
  2. Import the WidgetState type

    import { WidgetState } from "../Widget";
  3. Add a settings parameter to your Widget function

    export function MyWidget({ settings }: WidgetState<MyWidgetSettings>) {
      // ...
    }
    • You can now use any setting in your interface to control your widget (e.g. settings.SettingOne)
  4. Import your interface and add a default configuration in WidgetMap.tsx

    const WidgetMap = {
      mywidget: {
        // ...
        settings: {
          settingOne: true,
          settingTwo: "mysetting",
        } satisfies MyWidgetSettings, // This checks for validity at build time
      },
    };

Copy link
Contributor

@harryalloyd harryalloyd left a comment

Choose a reason for hiding this comment

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

lgtm

@bacurrah bacurrah merged commit aad096f into main Oct 29, 2025
1 check passed
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.

As a user, I want my homepage to be saved when I close it As a user, I want to be able to remove widgets

4 participants