|
| 1 | +/* This Source Code Form is subject to the terms of the Mozilla Public |
| 2 | + * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
| 3 | + * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
| 4 | + |
| 5 | +import * as React from 'react' |
| 6 | +import { render } from 'react-dom' |
| 7 | +import { Provider } from 'react-redux' |
| 8 | +import { Store } from 'webext-redux' |
| 9 | + |
| 10 | +import Theme from 'brave-ui/theme/brave-default' |
| 11 | +import { ThemeProvider } from 'styled-components' |
| 12 | +import { initLocale } from 'brave-ui/helpers' |
| 13 | +require('emptykit.css') |
| 14 | +require('../../../../../ui/webui/resources/fonts/muli.css') |
| 15 | +require('../../../../../ui/webui/resources/fonts/poppins.css') |
| 16 | + |
| 17 | +import { LocaleContext } from '../../shared/lib/locale_context' |
| 18 | +import { WithThemeVariables } from '../../shared/components/with_theme_variables' |
| 19 | + |
| 20 | +// Components |
| 21 | +import AdsEnablePanel from './components/ads_enable' |
| 22 | + |
| 23 | +// Utils |
| 24 | +import { getMessage, getUIMessages } from './background/api/locale_api' |
| 25 | + |
| 26 | +const store: Store<RewardsExtension.State> = new Store({ |
| 27 | + portName: 'REWARDSPANEL' |
| 28 | +}) |
| 29 | + |
| 30 | +const localeContext = { |
| 31 | + getString: (key: string) => { |
| 32 | + // In order to normalize messages across extensions and WebUI, replace all |
| 33 | + // chrome.i18n message placeholders with $N marker patterns. UI components |
| 34 | + // are responsible for replacing these markers with appropriate text or |
| 35 | + // using the markers to build HTML. |
| 36 | + const subsitutions = ['$1', '$2', '$3', '$4', '$5', '$6', '$7', '$8', '$9'] |
| 37 | + return getMessage(key, subsitutions) |
| 38 | + } |
| 39 | +} |
| 40 | + |
| 41 | +initLocale(getUIMessages()) |
| 42 | + |
| 43 | +store.ready().then( |
| 44 | + () => { |
| 45 | + render( |
| 46 | + <LocaleContext.Provider value={localeContext}> |
| 47 | + <Provider store={store}> |
| 48 | + <ThemeProvider theme={Theme}> |
| 49 | + <WithThemeVariables> |
| 50 | + <AdsEnablePanel /> |
| 51 | + </WithThemeVariables> |
| 52 | + </ThemeProvider> |
| 53 | + </Provider> |
| 54 | + </LocaleContext.Provider>, |
| 55 | + document.getElementById('ads_enable_root')) |
| 56 | + }) |
| 57 | + .catch(() => { |
| 58 | + console.error('Problem mounting ads enable panel') |
| 59 | + }) |
0 commit comments