Skip to content

Commit 907a5e8

Browse files
committed
feat: add starter bar live preview disable config option
1 parent 5f3d75a commit 907a5e8

4 files changed

Lines changed: 22 additions & 2 deletions

File tree

src/LiveDevelopment/LivePreviewConstants.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,7 @@ define(function main(require, exports, module) {
4444

4545
exports.PREFERENCE_SHOW_STYLES_BAR = "livePreviewShowStylesBar";
4646

47+
exports.PREFERENCE_SHOW_STARTER_BAR = "livePreviewShowStarterBar";
48+
4749
exports.PREFERENCE_STYLES_BAR_POSITION = "livePreviewStylesBarPosition";
4850
});

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+
showStarterBar: true, // default value, this will get updated when the extension loads
7576
stylesBarPosition: "", // saved dock side ("top"/"bottom"); empty = default bottom
7677
syncSourceAndPreview: true, // default value, this will get updated when the extension loads
7778
imageGalleryAutoOpen: true, // auto-open gallery on first image click per session
@@ -345,6 +346,13 @@ define(function main(require, exports, module) {
345346
MultiBrowserLiveDev.updateConfig(config);
346347
}
347348

349+
function updateStarterBarConfig() {
350+
const prefValue = PreferencesManager.get(CONSTANTS.PREFERENCE_SHOW_STARTER_BAR);
351+
const config = MultiBrowserLiveDev.getConfig();
352+
config.showStarterBar = prefValue !== false; // defaults to true (on)
353+
MultiBrowserLiveDev.updateConfig(config);
354+
}
355+
348356
function updateStylesBarPositionConfig() {
349357
const prefValue = PreferencesManager.get(CONSTANTS.PREFERENCE_STYLES_BAR_POSITION);
350358
const config = MultiBrowserLiveDev.getConfig();
@@ -376,6 +384,7 @@ define(function main(require, exports, module) {
376384
exports.updateElementHighlightConfig = updateElementHighlightConfig;
377385
exports.updateRulerLinesConfig = updateRulerLinesConfig;
378386
exports.updateStylesBarConfig = updateStylesBarConfig;
387+
exports.updateStarterBarConfig = updateStarterBarConfig;
379388
exports.updateStylesBarPositionConfig = updateStylesBarPositionConfig;
380389
exports.getConnectionIds = MultiBrowserLiveDev.getConnectionIds;
381390
exports.getLivePreviewDetails = MultiBrowserLiveDev.getLivePreviewDetails;

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

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

124+
// live preview starter bar preference (show/hide the starter bar on empty pages); on by default
125+
const PREFERENCE_SHOW_STARTER_BAR = CONSTANTS.PREFERENCE_SHOW_STARTER_BAR;
126+
PreferencesManager.definePreference(PREFERENCE_SHOW_STARTER_BAR, "boolean", true, {
127+
description: Strings.LIVE_DEV_SETTINGS_SHOW_STARTER_BAR_PREFERENCE
128+
});
129+
124130
// live preview styles bar position preference; persists where the user last dragged the bar
125131
const PREFERENCE_STYLES_BAR_POSITION = CONSTANTS.PREFERENCE_STYLES_BAR_POSITION;
126132
PreferencesManager.definePreference(PREFERENCE_STYLES_BAR_POSITION, "string", "", {
@@ -1555,13 +1561,17 @@ define(function (require, exports, module) {
15551561
PreferencesManager.on("change", PREFERENCE_SHOW_STYLES_BAR, function() {
15561562
LiveDevelopment.updateStylesBarConfig();
15571563
});
1564+
PreferencesManager.on("change", PREFERENCE_SHOW_STARTER_BAR, function() {
1565+
LiveDevelopment.updateStarterBarConfig();
1566+
});
15581567
PreferencesManager.on("change", PREFERENCE_STYLES_BAR_POSITION, function() {
15591568
LiveDevelopment.updateStylesBarPositionConfig();
15601569
});
15611570
// Initialize element highlight, ruler lines and styles bar config on startup
15621571
LiveDevelopment.updateElementHighlightConfig();
15631572
LiveDevelopment.updateRulerLinesConfig();
15641573
LiveDevelopment.updateStylesBarConfig();
1574+
LiveDevelopment.updateStarterBarConfig();
15651575
LiveDevelopment.updateStylesBarPositionConfig();
15661576

15671577
LiveDevelopment.openLivePreview();

src/nls/root/strings.js

Lines changed: 1 addition & 2 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_SHOW_STARTER_BAR_PREFERENCE": "Show the starter bar when the live preview page is empty. Defaults to 'true'",
187188
"LIVE_DEV_SETTINGS_STYLES_BAR_POSITION_PREFERENCE": "Saved position of the live preview styles bar, set automatically when the bar is dragged. Empty places the bar at its default spot",
188189
"LIVE_DEV_TOOLBOX_SELECT_PARENT": "Select Parent",
189190
"LIVE_DEV_TOOLBOX_EDIT_TEXT": "Edit Text",
@@ -438,8 +439,6 @@ define({
438439
"LIVE_DEV_INSERT_SHOW_LESS": "Show less",
439440
"LIVE_DEV_INSERT_CREATE": "Create",
440441
"LIVE_DEV_STARTER_BAR_LABEL": "Your page is empty — add an element",
441-
"LIVE_DEV_STARTER_BAR_ADD": "Add your first element",
442-
"LIVE_DEV_STARTER_BAR_COLLAPSE": "Collapse",
443442
"LIVE_DEV_IMAGE_GALLERY_USE_IMAGE": "Download image",
444443
"LIVE_DEV_IMAGE_GALLERY_SELECT_DOWNLOAD_FOLDER": "Choose image download folder",
445444
"LIVE_DEV_IMAGE_GALLERY_SEARCH_PLACEHOLDER": "Search images\u2026",

0 commit comments

Comments
 (0)