forked from ChromeDevTools/devtools-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
Create Welcome panel in rn_inspector #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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: 'Chrome DevTools for React Native', | ||
motiz88 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| /** @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 hidden or 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 hidden or 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 hidden or 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, | ||
| }; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually perhaps these could be scoped by panel (
rn_welcome/) 🤔