Skip to content

Commit

Permalink
fix(app): point to correct host in manifest
Browse files Browse the repository at this point in the history
  • Loading branch information
rektdeckard committed Dec 24, 2024
1 parent e51169a commit 46bb9e5
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 15 deletions.
2 changes: 1 addition & 1 deletion public/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Phosphor Icons",
"description": "A friendly icon family for Penpot",
"host": "http://localhost:4400",
"host": "https://phosphor-icons.github.io",
"code": "/penpot/plugin.js",
"icon": "/penpot/icon.png",
"permissions": [
Expand Down
4 changes: 2 additions & 2 deletions src/model.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { PenpotTheme } from "@penpot/plugin-types";
import { Theme } from "@penpot/plugin-types";
import { IconEntry, IconStyle } from "@phosphor-icons/core";

export type ThemePluginEvent = {
type: "theme";
content: PenpotTheme;
content: Theme;
};

export type PluginMessageEvent = ThemePluginEvent;
Expand Down
34 changes: 22 additions & 12 deletions src/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { IconStyle } from "@phosphor-icons/core";
import type { PluginMessageEvent, UIMessageEvent, InsertIconEvent } from "./model";
import type {
PluginMessageEvent,
UIMessageEvent,
InsertIconEvent,
} from "./model";

penpot.ui.open("Phosphor Icons", `/penpot/?theme=${penpot.getTheme()}`, {
penpot.ui.open("Phosphor Icons", `/penpot/?theme=${penpot.theme}`, {
width: 350,
height: 580,
});
Expand All @@ -19,26 +23,32 @@ penpot.ui.onMessage<string>(async (message) => {
default:
return;
}
})
});

function sendMessage(message: PluginMessageEvent) {
penpot.ui.sendMessage(message);
}

async function handleInsertIcon(data: InsertIconEvent) {
const { entry, svg, raw, weight } = data.content;
const markup = raw ? await (async () => {
try {
const text = await fetchRawIcon(entry.name, weight);
return text;
} catch (_) {
// TODO: notify somehow?
return svg;
}
})() : svg;
const markup = raw
? await (async () => {
try {
const text = await fetchRawIcon(entry.name, weight);
return text;
} catch (_) {
// TODO: notify somehow?
return svg;
}
})()
: svg;

const center = penpot.viewport.center;
const shape = penpot.createShapeFromSvg(markup);
if (!shape) {
return;
}

shape.name = entry.pascal_name;
shape.proportionLock = true;
if (!raw) shape.resize(24, 24);
Expand Down

0 comments on commit 46bb9e5

Please sign in to comment.