forked from ChromeDevTools/devtools-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create Welcome panel in rn_inspector (#8)
* Create Welcome panel in rn_inspector * Update RN debugger brand name to "React Native JS Inspector" --------- Co-authored-by: Moti Zilberman <motiz88@gmail.com>
- Loading branch information
Showing
11 changed files
with
262 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Copyright 2020 The Chromium Authors. All rights reserved. | ||
# Use of this source code is governed by a BSD-style license that can be | ||
# found in the LICENSE file. | ||
|
||
import("../../../scripts/build/ninja/devtools_entrypoint.gni") | ||
import("../../../scripts/build/ninja/devtools_module.gni") | ||
import("../../../scripts/build/ninja/generate_css.gni") | ||
import("../visibility.gni") | ||
|
||
generate_css("css_files") { | ||
sources = [ "rnWelcome.css" ] | ||
} | ||
|
||
devtools_module("rn_welcome") { | ||
sources = [ "RNWelcome.ts" ] | ||
|
||
deps = [ | ||
"../../core/host:bundle", | ||
"../../core/i18n:bundle", | ||
"../../core/protocol_client:bundle", | ||
"../../core/sdk:bundle", | ||
"../../models/text_utils:bundle", | ||
"../../ui/components/data_grid:bundle", | ||
"../../ui/components/icon_button:bundle", | ||
"../../ui/legacy:bundle", | ||
"../../ui/lit-html:bundle", | ||
] | ||
} | ||
|
||
devtools_entrypoint("bundle") { | ||
entrypoint = "rn_welcome.ts" | ||
|
||
deps = [ | ||
":css_files", | ||
":rn_welcome", | ||
] | ||
|
||
visibility = [ | ||
":*", | ||
"../../../test/unittests/front_end/entrypoints/missing_entrypoints/*", | ||
# "../../../test/unittests/front_end/panels/rn_welcome/*", | ||
"../../entrypoints/*", | ||
] | ||
|
||
visibility += devtools_panels_visibility | ||
} | ||
|
||
devtools_entrypoint("meta") { | ||
entrypoint = "rn_welcome-meta.ts" | ||
|
||
deps = [ ":bundle" ] | ||
|
||
visibility = [ "../../entrypoints/*" ] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// Copyright 2018 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
import * as UI from '../../ui/legacy/legacy.js'; | ||
import * as i18n from '../../core/i18n/i18n.js'; | ||
|
||
import rnWelcomeStyles from './rnWelcome.css.js'; | ||
import * as LitHtml from '../../ui/lit-html/lit-html.js'; | ||
|
||
const UIStrings = { | ||
/** @description The name of the debugging product */ | ||
debuggerBrandName: 'React Native JS Inspector', | ||
/** @description Welcome text */ | ||
welcomeMessage: 'Welcome to debugging in React Native', | ||
/** @description "Debugging docs" link */ | ||
docsLabel: 'Debugging docs', | ||
/** @description "What's new" link */ | ||
whatsNewLabel: "What's new", | ||
}; | ||
const {render, html} = LitHtml; | ||
|
||
const str_ = i18n.i18n.registerUIStrings('panels/rn_welcome/RNWelcome.ts', UIStrings); | ||
const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_); | ||
|
||
let rnWelcomeImplInstance: RNWelcomeImpl; | ||
|
||
export class RNWelcomeImpl extends UI.Widget.VBox { | ||
static instance(opts: {forceNew: null|boolean} = {forceNew: null}): RNWelcomeImpl { | ||
const {forceNew} = opts; | ||
if (!rnWelcomeImplInstance || forceNew) { | ||
rnWelcomeImplInstance = new RNWelcomeImpl(); | ||
} | ||
return rnWelcomeImplInstance; | ||
} | ||
|
||
private constructor() { | ||
super(true, true); | ||
} | ||
|
||
override wasShown(): void { | ||
super.wasShown(); | ||
this.registerCSSFiles([rnWelcomeStyles]); | ||
this.render(); | ||
UI.InspectorView.InspectorView.instance().showDrawer(true); | ||
} | ||
|
||
render(): void { | ||
render(html` | ||
<div class="rn-welcome-panel"> | ||
<div class="rn-welcome-header"> | ||
<img class="rn-welcome-icon" src="/Images/react_native/welcomeIcon.png" role="presentation" /> | ||
<div class="rn-welcome-title"> | ||
${i18nString(UIStrings.debuggerBrandName)} | ||
</div> | ||
</div> | ||
<div class="rn-welcome-tagline"> | ||
${i18nString(UIStrings.welcomeMessage)} | ||
</div> | ||
<div class="rn-welcome-links"> | ||
<x-link class="devtools-link" href="https://reactnative.dev/docs/next/debugging"> | ||
${i18nString(UIStrings.docsLabel)} | ||
</x-link> | ||
<x-link class="devtools-link" href="https://reactnative.dev/blog/tags/debugging"> | ||
${i18nString(UIStrings.whatsNewLabel)} | ||
</x-link> | ||
</div> | ||
</div> | ||
`, this.contentElement, {host: this}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* Copyright 2021 The Chromium Authors. All rights reserved. | ||
* Use of this source code is governed by a BSD-style license that can be | ||
* found in the LICENSE file. | ||
*/ | ||
|
||
.rn-welcome-panel { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: center; | ||
height: 100%; | ||
padding: 16px; | ||
text-align: center; | ||
font-size: 1rem; | ||
background-color: var(--color-background-elevation-0); | ||
} | ||
|
||
.rn-welcome-header { | ||
display: flex; | ||
align-items: center; | ||
margin-bottom: 16px; | ||
} | ||
|
||
.rn-welcome-icon { | ||
width: 30px; | ||
height: 30px; | ||
border-radius: 4px; | ||
margin-right: 12px; | ||
} | ||
|
||
.rn-welcome-title { | ||
font-size: 20px; | ||
color: var(--color-text-primary); | ||
} | ||
|
||
.rn-welcome-tagline { | ||
margin-bottom: 24px; | ||
font-size: 1rem; | ||
line-height: 1.3; | ||
color: var(--color-text-secondary); | ||
} | ||
|
||
.rn-welcome-links { | ||
display: flex; | ||
align-items: center; | ||
} | ||
|
||
.rn-welcome-links > .devtools-link { | ||
position: relative; | ||
margin: 0 16px; | ||
font-size: 14px; | ||
} | ||
|
||
.rn-welcome-links > .devtools-link:not(:last-child)::after { | ||
content: ""; | ||
position: absolute; | ||
right: -16px; | ||
height: 16px; | ||
border-right: 1px solid var(--color-details-hairline); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright 2020 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
import * as i18n from '../../core/i18n/i18n.js'; | ||
import * as Root from '../../core/root/root.js'; | ||
import * as UI from '../../ui/legacy/legacy.js'; | ||
|
||
import type * as RNWelcome from './rn_welcome.js'; | ||
|
||
const UIStrings = { | ||
/** | ||
* @description Title of the Welcome panel, plus an emoji symbolizing React Native | ||
*/ | ||
rnWelcome: '⚛️ Welcome', | ||
|
||
/** | ||
* @description Command for showing the Welcome panel | ||
*/ | ||
showRnWelcome: 'Show React Native Welcome panel', | ||
}; | ||
const str_ = i18n.i18n.registerUIStrings('panels/rn_welcome/rn_welcome-meta.ts', UIStrings); | ||
const i18nLazyString = i18n.i18n.getLazilyComputedLocalizedString.bind(undefined, str_); | ||
|
||
let loadedRNWelcomeModule: (typeof RNWelcome|undefined); | ||
|
||
async function loadRNWelcomeModule(): Promise<typeof RNWelcome> { | ||
if (!loadedRNWelcomeModule) { | ||
loadedRNWelcomeModule = await import('./rn_welcome.js'); | ||
} | ||
return loadedRNWelcomeModule; | ||
} | ||
|
||
UI.ViewManager.registerViewExtension({ | ||
location: UI.ViewManager.ViewLocationValues.PANEL, | ||
id: 'rn-welcome', | ||
title: i18nLazyString(UIStrings.rnWelcome), | ||
commandPrompt: i18nLazyString(UIStrings.showRnWelcome), | ||
order: -10, | ||
persistence: UI.ViewManager.ViewPersistence.PERMANENT, | ||
async loadView() { | ||
const RNWelcome = await loadRNWelcomeModule(); | ||
return RNWelcome.RNWelcome.RNWelcomeImpl.instance(); | ||
}, | ||
experiment: Root.Runtime.ExperimentName.REACT_NATIVE_SPECIFIC_UI, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Copyright 2019 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
import './RNWelcome.js'; | ||
|
||
import * as RNWelcome from './RNWelcome.js'; | ||
|
||
export { | ||
RNWelcome, | ||
}; |