diff --git a/CHANGELOG.md b/CHANGELOG.md index 86d311c..69d058f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ Added: - `Report Bugs` and `Changelog` buttons to `Settings > About` - Markdown parsing for settings descriptions +- Option to have a button to open the settings next to your profile picture Fixed: - Fonts looking blurry diff --git a/src/js/Info.js b/src/js/Info.js index 80ba54a..7d4f99c 100644 --- a/src/js/Info.js +++ b/src/js/Info.js @@ -8,11 +8,17 @@ export default class Info { * @property {String} [text] * @property {String} [tooltip] * @property {String} [icon] - * @property {{fg: String, bg: String}} [color] defaults to {fg: "sidebar-text", bg: "button"} + * @property {DribbblishInfoColor} [color] * @property {Number} [order=0] order < 0 = More to the Left | order > 0 = More to the Right * @property {onClick} [onClick] */ + /** + * @typedef {Object} DribbblishInfoColor + * @property {String} [fg] + * @property {String} [bg] + */ + /** * @callback onClick * @returns {void} @@ -58,9 +64,9 @@ export default class Info { if (info.tooltip != null) elem.setAttribute("title", info.tooltip); if (info.onClick != null) elem.setAttribute("clickable", ""); if (info.color != null) { - const { bg, fg } = info.color; - if (bg != null) elem.style.backgroundColor = bg; + const { fg, bg } = info.color; if (fg != null) elem.style.color = fg; + if (bg != null) elem.style.backgroundColor = bg; } if (info.order != 0) elem.style.order = info.order; elem.innerHTML = `${info.text ?? ""}${info.icon ?? ""}`; diff --git a/src/js/main.js b/src/js/main.js index 3e0e2d3..68ddc2f 100644 --- a/src/js/main.js +++ b/src/js/main.js @@ -10,6 +10,7 @@ import Info from "./Info"; import svgArrowDown from "svg/arrow-down"; import svgCode from "svg/code"; import svgWifiSlash from "svg/wifi-slash"; +import svgCog from "svg/cog"; const Dribbblish = { config: new ConfigMenu(), @@ -18,6 +19,25 @@ const Dribbblish = { // To expose to external scripts window.Dribbblish = Dribbblish; +Dribbblish.config.register({ + type: "checkbox", + key: "openSettingsInfo", + name: "Open Settings Icon", + description: "Show an icon next to your profile image to open the dribbblish settings", + defaultValue: true, + onChange: (val) => + Dribbblish.info[val ? "set" : "remove"]("settings", { + icon: svgCog, + color: { + fg: "var(--spice-subtext)", + bg: "rgba(var(--spice-rgb-subtext), calc(0.1 + var(--is_light) * 0.05))" + }, + order: 999, + tooltip: "Open Dribbblish Settings", + onClick: () => Dribbblish.config.open() + }) +}); + Dribbblish.config.register({ type: "checkbox", key: "rightBigCover", @@ -751,7 +771,7 @@ waitForElement([".main-topBar-container"], ([topBarContainer]) => { .then((response) => response.json()) .then((data) => { const isDev = process.env.DRIBBBLISH_VERSION == "Dev"; - Dribbblish.info.set("upd", isDev || data.tag_name > process.env.DRIBBBLISH_VERSION ? { text: `v${data.tag_name}`, tooltip: "Open Release page to download", icon: svgArrowDown, onClick: () => window.open("https://github.com/JulienMaille/dribbblish-dynamic-theme/releases/latest", "_blank") } : null); + Dribbblish.info.set("update", isDev || data.tag_name > process.env.DRIBBBLISH_VERSION ? { text: `v${data.tag_name}`, tooltip: "Open Release page to download", icon: svgArrowDown, onClick: () => window.open("https://github.com/JulienMaille/dribbblish-dynamic-theme/releases/latest", "_blank") } : null); Dribbblish.info.set("dev", isDev ? { tooltip: "Dev build", icon: svgCode } : null); }) .catch(console.error); @@ -766,7 +786,7 @@ window.addEventListener("offline", () => Dribbblish.info.set("offline", { tooltip: "Offline", icon: svgWifiSlash, - order: 999, + order: 998, color: { fg: "#ffffff", bg: "#ff2323" diff --git a/src/svg/cog.svg b/src/svg/cog.svg new file mode 100644 index 0000000..c003872 --- /dev/null +++ b/src/svg/cog.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file