Skip to content

Commit 63ae9f8

Browse files
committed
feat: add checkmark icon in the current active mode
1 parent 1a81c82 commit 63ae9f8

File tree

1 file changed

+13
-1
lines changed
  • src/extensionsIntegrated/Phoenix-live-preview

1 file changed

+13
-1
lines changed

src/extensionsIntegrated/Phoenix-live-preview/main.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,12 +237,24 @@ define(function (require, exports, module) {
237237
Strings.LIVE_PREVIEW_EDIT_HIGHLIGHT_ON
238238
];
239239

240+
const rawMode = PreferencesManager.get(PREFERENCE_LIVE_PREVIEW_MODE) || "preview";
241+
// this is to take care of invalid values in the pref file
242+
const currentMode = ["preview", "highlight", "edit"].includes(rawMode) ? rawMode : "preview";
243+
240244
const dropdown = new DropdownButton.DropdownButton("", items, function(item, index) {
241-
if (item === Strings.LIVE_PREVIEW_EDIT_HIGHLIGHT_ON) {
245+
if (item === Strings.LIVE_PREVIEW_MODE_PREVIEW) {
246+
// using empty spaces to keep content aligned
247+
return currentMode === "preview" ? `✓ ${item}` : `${'\u00A0'.repeat(4)}${item}`;
248+
} else if (item === Strings.LIVE_PREVIEW_MODE_HIGHLIGHT) {
249+
return currentMode === "highlight" ? `✓ ${item}` : `${'\u00A0'.repeat(4)}${item}`;
250+
} else if (item === Strings.LIVE_PREVIEW_MODE_EDIT) {
251+
return currentMode === "edit" ? `✓ ${item}` : `${'\u00A0'.repeat(4)}${item}`;
252+
} else if (item === Strings.LIVE_PREVIEW_EDIT_HIGHLIGHT_ON) {
242253
const isHoverMode = PreferencesManager.get(PREFERENCE_PROJECT_ELEMENT_HIGHLIGHT) !== "click";
243254
if(isHoverMode) {
244255
return `✓ ${Strings.LIVE_PREVIEW_EDIT_HIGHLIGHT_ON}`;
245256
}
257+
return `${'\u00A0'.repeat(4)}${Strings.LIVE_PREVIEW_EDIT_HIGHLIGHT_ON}`;
246258
}
247259
return item;
248260
});

0 commit comments

Comments
 (0)