Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Widget Config Magnify #1689

Merged
merged 2 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/docs/customwidgets.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ This `WidgetConfigType` is shared between all types of widgets. That is to say,
| "color" | (optional) A string representing a color as would be used in CSS. Hex codes and custom CSS properties are included. This defaults to `"var(--secondary-text-color)"` which is a color wave uses for text that should be differentiated from other text. Out of the box, it is `"#c3c8c2"`. |
| "label" | (optional) A string representing the label that appears underneath the widget. It will also act as a tooltip on hover if the `"description"` key isn't filled out. It is null by default. |
| "description" | (optional) A description of what the widget does. If it is specified, this serves as a tooltip on hover. It is null by default. |
| "magnified" | (optional) A boolean indicating whether or not the widget should launch magnfied. It is false by default. |
| "blockdef" | This is where the the non-visual portion of the widget is defined. Note that all further definition takes place inside a meta object inside this one. |

<a name="font-awesome-icons" />
Expand Down
11 changes: 4 additions & 7 deletions frontend/app/workspace/workspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,14 @@ const Widgets = memo(() => {
);
});

async function handleWidgetSelect(blockDef: BlockDef) {
createBlock(blockDef);
async function handleWidgetSelect(widget: WidgetConfigType) {
const blockDef = widget.blockdef;
createBlock(blockDef, widget.magnified);
}

const Widget = memo(({ widget }: { widget: WidgetConfigType }) => {
return (
<div
className="widget"
onClick={() => handleWidgetSelect(widget.blockdef)}
title={widget.description || widget.label}
>
<div className="widget" onClick={() => handleWidgetSelect(widget)} title={widget.description || widget.label}>
<div className="widget-icon" style={{ color: widget.color }}>
<i className={makeIconClass(widget.icon, true, { defaultIcon: "browser" })}></i>
</div>
Expand Down
1 change: 1 addition & 0 deletions frontend/types/gotypes.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1159,6 +1159,7 @@ declare global {
color?: string;
label?: string;
description?: string;
magnified?: boolean;
blockdef: BlockDef;
};

Expand Down
1 change: 1 addition & 0 deletions pkg/wconfig/settingsconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,7 @@ type WidgetConfigType struct {
Color string `json:"color,omitempty"`
Label string `json:"label,omitempty"`
Description string `json:"description,omitempty"`
Magnified bool `json:"magnified,omitempty"`
BlockDef waveobj.BlockDef `json:"blockdef"`
}

Expand Down
Loading