Skip to content

Commit 433dc41

Browse files
devvaannshabose
authored andcommitted
feat: styles bar dock position should be saved across reloads
1 parent 8db6786 commit 433dc41

4 files changed

Lines changed: 23 additions & 0 deletions

File tree

src/LiveDevelopment/LivePreviewConstants.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,6 @@ define(function main(require, exports, module) {
4343
exports.PREFERENCE_SHOW_RULER_LINES = "livePreviewShowMeasurements";
4444

4545
exports.PREFERENCE_SHOW_STYLES_BAR = "livePreviewShowStylesBar";
46+
47+
exports.PREFERENCE_STYLES_BAR_DOCK = "livePreviewStylesBarDock";
4648
});

src/LiveDevelopment/main.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ define(function main(require, exports, module) {
7272
elemHighlights: CONSTANTS.HIGHLIGHT_HOVER, // default value, this will get updated when the extension loads
7373
showRulerLines: false, // default value, this will get updated when the extension loads
7474
showStylesBar: true, // default value, this will get updated when the extension loads
75+
stylesBarDock: "bottom", // default dock side, this will get updated when the extension loads
7576
syncSourceAndPreview: true, // default value, this will get updated when the extension loads
7677
imageGalleryAutoOpen: true, // auto-open gallery on first image click per session
7778
isPaidUser: false, // will be updated when we fetch entitlements
@@ -344,6 +345,13 @@ define(function main(require, exports, module) {
344345
MultiBrowserLiveDev.updateConfig(config);
345346
}
346347

348+
function updateStylesBarDockConfig() {
349+
const prefValue = PreferencesManager.get(CONSTANTS.PREFERENCE_STYLES_BAR_DOCK);
350+
const config = MultiBrowserLiveDev.getConfig();
351+
config.stylesBarDock = prefValue || "bottom";
352+
MultiBrowserLiveDev.updateConfig(config);
353+
}
354+
347355
EventDispatcher.makeEventDispatcher(exports);
348356

349357
// private api
@@ -368,6 +376,7 @@ define(function main(require, exports, module) {
368376
exports.updateElementHighlightConfig = updateElementHighlightConfig;
369377
exports.updateRulerLinesConfig = updateRulerLinesConfig;
370378
exports.updateStylesBarConfig = updateStylesBarConfig;
379+
exports.updateStylesBarDockConfig = updateStylesBarDockConfig;
371380
exports.getConnectionIds = MultiBrowserLiveDev.getConnectionIds;
372381
exports.getLivePreviewDetails = MultiBrowserLiveDev.getLivePreviewDetails;
373382
exports.hideHighlight = MultiBrowserLiveDev.hideHighlight;

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,13 @@ define(function (require, exports, module) {
121121
description: Strings.LIVE_DEV_SETTINGS_SHOW_STYLES_BAR_PREFERENCE
122122
});
123123

124+
// live preview styles bar dock side preference (where the bar docks); persists user choice
125+
const PREFERENCE_STYLES_BAR_DOCK = CONSTANTS.PREFERENCE_STYLES_BAR_DOCK;
126+
PreferencesManager.definePreference(PREFERENCE_STYLES_BAR_DOCK, "string", "bottom", {
127+
description: Strings.LIVE_DEV_SETTINGS_STYLES_BAR_DOCK_PREFERENCE,
128+
values: ["top", "bottom", "left", "right"]
129+
});
130+
124131
const LIVE_PREVIEW_PANEL_ID = "live-preview-panel";
125132
const LIVE_PREVIEW_IFRAME_ID = "panel-live-preview-frame";
126133
const MDVIEWR_IFRAME_ID = "panel-md-preview-frame";
@@ -1549,10 +1556,14 @@ define(function (require, exports, module) {
15491556
PreferencesManager.on("change", PREFERENCE_SHOW_STYLES_BAR, function() {
15501557
LiveDevelopment.updateStylesBarConfig();
15511558
});
1559+
PreferencesManager.on("change", PREFERENCE_STYLES_BAR_DOCK, function() {
1560+
LiveDevelopment.updateStylesBarDockConfig();
1561+
});
15521562
// Initialize element highlight, ruler lines and styles bar config on startup
15531563
LiveDevelopment.updateElementHighlightConfig();
15541564
LiveDevelopment.updateRulerLinesConfig();
15551565
LiveDevelopment.updateStylesBarConfig();
1566+
LiveDevelopment.updateStylesBarDockConfig();
15561567

15571568
LiveDevelopment.openLivePreview();
15581569
LiveDevelopment.on(LiveDevelopment.EVENT_OPEN_PREVIEW_URL, _openLivePreviewURL);

src/nls/root/strings.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ define({
184184
"LIVE_DEV_SETTINGS_ELEMENT_HIGHLIGHT_PREFERENCE": "Inspect element in Live Preview on 'hover' or 'click'. Defaults to 'hover'",
185185
"LIVE_DEV_SETTINGS_SHOW_RULER_LINES_PREFERENCE": "Show measurements when elements are selected in live preview. Defaults to 'false'",
186186
"LIVE_DEV_SETTINGS_SHOW_STYLES_BAR_PREFERENCE": "Show the styles bar when elements are selected in live preview. Defaults to 'true'",
187+
"LIVE_DEV_SETTINGS_STYLES_BAR_DOCK_PREFERENCE": "Which side the live preview styles bar docks to: 'top', 'bottom', 'left' or 'right'. Defaults to 'bottom'",
187188
"LIVE_DEV_TOOLBOX_SELECT_PARENT": "Select Parent",
188189
"LIVE_DEV_TOOLBOX_EDIT_TEXT": "Edit Text",
189190
"LIVE_DEV_TOOLBOX_DOUBLE_CLICK_HINT": "Double-click",

0 commit comments

Comments
 (0)