Skip to content

Commit

Permalink
improve dev menu, fix shelter-ui build script
Browse files Browse the repository at this point in the history
  • Loading branch information
yellowsink committed Nov 27, 2024
1 parent 797aea6 commit 78d5d4b
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/shelter-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"module": "dist/index.jsx",
"types": "dist/index.d.ts",
"scripts": {
"prepare": "tsc && node esbuild.mjs"
"prepare": "rimraf dist && tsc && mv dist/src/* dist && rmdir dist/src && node esbuild.mjs"
},
"devDependencies": {
"esbuild": "^0.20.1",
Expand Down
22 changes: 19 additions & 3 deletions packages/shelter/src/components/DevUI.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@ import { devModeReservedId, enableDevmode, stopDevmode } from "../devmode";
import { installedPlugins } from "../plugins";
import { createMemo, Show } from "solid-js";

export default () => {
// fullVersion shows the header and the toggle for always showing the mini menu
export default (props: { fullVersion?: boolean }) => {
const devModeOn = createMemo(() => devModeReservedId in installedPlugins());

return (
<div>
<Header tag={HeaderTags.EYEBROW}>Developer Tools</Header>
<Show when={props.fullVersion}>
<Header tag={HeaderTags.EYEBROW}>Developer Tools</Header>
</Show>

<SwitchItem value={dbStore.logDispatch} onChange={(v) => (dbStore.logDispatch = v)}>
Log FluxDispatcher events to the console
</SwitchItem>
Expand Down Expand Up @@ -58,7 +62,19 @@ export default () => {
{(plugin) => <PluginCard id={devModeReservedId} plugin={plugin} />}
</Show>

<Divider mt />
<Divider mt mb />

<Show when={props.fullVersion}>
<SwitchItem
checked={dbStore.alwaysDevMenu}
onChange={(v) => (dbStore.alwaysDevMenu = v)}
note={
"The developer tools menu icon shows when lune dev mode is enabled, turning this on shows it at all times."
}
>
Always show developer tools menu icon
</SwitchItem>
</Show>
</div>
);
};
2 changes: 1 addition & 1 deletion packages/shelter/src/components/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export default () => {
</Button>
</div>
</div>
<DevUi />
<DevUi fullVersion />
<Plugins />
</div>
</>
Expand Down
3 changes: 2 additions & 1 deletion packages/shelter/src/devmode/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { css, classes } from "./devmode.css";
import { log } from "../util";
import DevUI from "../components/DevUI";
import { createEffect } from "solid-js";
import { dbStore } from "../storage";

// any string would work here but this is funnier
export const devModeReservedId = "__DEVMODE_PLUGIN_DO_NOT_USE_OR_YOU_WILL_BE_FIRED";
Expand Down Expand Up @@ -42,7 +43,7 @@ export async function initDevmode() {
unobs1?.();
unobs2?.();

if (devModeIsOn()) {
if (devModeIsOn() || dbStore.alwaysDevMenu) {
unobs1 = observe(`[class*="anchor"]`, (e: HTMLAnchorElement) => {
if (e.href === "https://support.discord.com/") {
e.href = "#";
Expand Down

0 comments on commit 78d5d4b

Please sign in to comment.