|
| 1 | +// Copyright (c) Meta Platforms, Inc. and affiliates. |
| 2 | +// Copyright 2018 The Chromium Authors. All rights reserved. |
| 3 | +// Use of this source code is governed by a BSD-style license that can be |
| 4 | +// found in the LICENSE file. |
| 5 | + |
| 6 | +import * as i18n from '../../core/i18n/i18n.js'; |
| 7 | +import * as UI from '../../ui/legacy/legacy.js'; |
| 8 | +import * as LitHtml from '../../ui/lit-html/lit-html.js'; |
| 9 | + |
| 10 | +import ReactDevToolsPlaceholderStyles from './reactDevToolsPlaceholder.css.js'; |
| 11 | + |
| 12 | +const UIStrings = { |
| 13 | + /** @description Placeholder message */ |
| 14 | + placeholderMessage: '[FB-only] React DevTools is coming soon! ⚡', |
| 15 | +}; |
| 16 | +const {render, html} = LitHtml; |
| 17 | + |
| 18 | +const str_ = i18n.i18n.registerUIStrings('panels/react_devtools_placeholder/ReactDevToolsPlaceholder.ts', UIStrings); |
| 19 | +const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_); |
| 20 | + |
| 21 | +let instance: ReactDevToolsPlaceholderImpl; |
| 22 | + |
| 23 | +export class ReactDevToolsPlaceholderImpl extends UI.Widget.VBox { |
| 24 | + static instance(opts: {forceNew: null|boolean} = {forceNew: null}): ReactDevToolsPlaceholderImpl { |
| 25 | + const {forceNew} = opts; |
| 26 | + if (!instance || forceNew) { |
| 27 | + instance = new ReactDevToolsPlaceholderImpl(); |
| 28 | + } |
| 29 | + return instance; |
| 30 | + } |
| 31 | + |
| 32 | + private constructor() { |
| 33 | + super(true, true); |
| 34 | + } |
| 35 | + |
| 36 | + override wasShown(): void { |
| 37 | + super.wasShown(); |
| 38 | + this.registerCSSFiles([ReactDevToolsPlaceholderStyles]); |
| 39 | + this.render(); |
| 40 | + UI.InspectorView.InspectorView.instance().setDrawerMinimized(true); |
| 41 | + } |
| 42 | + |
| 43 | + override willHide(): void { |
| 44 | + UI.InspectorView.InspectorView.instance().setDrawerMinimized(false); |
| 45 | + } |
| 46 | + |
| 47 | + render(): void { |
| 48 | + render( |
| 49 | + html` |
| 50 | + <div class="rn-devtools-placeholder-panel"> |
| 51 | + <div class="rn-devtoools-placeholder-main"> |
| 52 | + <div class="rn-devtoools-placeholder-title"> |
| 53 | + ${i18nString(UIStrings.placeholderMessage)} |
| 54 | + </div> |
| 55 | + <div class="rn-devtools-placeholder-detail"> |
| 56 | + Soon, you will be able to use React DevTools within this panel and |
| 57 | + inspect multiple apps at once. In the meantime, you can connect to |
| 58 | + your app using the standalone React DevTools. |
| 59 | + </div> |
| 60 | + <div class="rn-devtools-placeholder-detail"> |
| 61 | + <code class="rn-devtools-placeholder-code">js1 devtools</code> |
| 62 | + or |
| 63 | + <code class="rn-devtools-placeholder-code" |
| 64 | + >npx react-devtools</code |
| 65 | + > |
| 66 | + </div> |
| 67 | + <a |
| 68 | + class="devtools-link rn-devtools-placeholder-link" |
| 69 | + href="https://fburl.com/workplace/og7mt427" |
| 70 | + target="_blank" |
| 71 | + >https://fburl.com/workplace/og7mt427</a |
| 72 | + > |
| 73 | + </div> |
| 74 | + </div> |
| 75 | + `, |
| 76 | + this.contentElement, {host: this}); |
| 77 | + } |
| 78 | +} |
0 commit comments