Popup UI
Relevant source files
The following files were used as context for generating this wiki page:The Popup UI is the primary user interface for the Read Frog browser extension, displayed when the user clicks the extension's icon in the browser toolbar. It serves as a central control panel, providing quick access to the extension's core functionalities, such as initiating page translation, triggering article analysis, and configuring essential settings like language preferences and AI providers.
This UI is built with React and is the main entrypoint for user interaction defined in the WXT framework as a browser_action. It communicates with content scripts and the background service worker to manage the extension's state and execute commands on the active web page.
Sources: src/entrypoints/popup/index.html:6, src/entrypoints/popup/app.tsx, CLAUDE.md
Architecture and Component Structure
The Popup UI is structured around a main App component that orchestrates a collection of specialized child components. Each component is responsible for a specific piece of functionality, from language selection to triggering major actions.
Sources: src/entrypoints/popup/app.tsx:27-42
The following diagram illustrates the component hierarchy of the Popup UI.
Key Components
The App component renders a vertical layout of various controls and action buttons.
| Component | Description | Source File |
|---|---|---|
UserAccount | Displays user account information. | src/entrypoints/popup/app.tsx:29 |
LanguageOptionsSelector | Allows users to select the source and target languages for translation. | src/entrypoints/popup/components/language-options-selector.tsx |
TranslationModeSelector | Lets the user choose between "Bilingual" and "Translation Only" display modes. | src/entrypoints/popup/app.tsx:34 |
TranslateProviderField | A selector for the AI provider used for translation. | src/entrypoints/popup/app.tsx:35 |
ReadProviderField | A selector for the AI provider used for the "Read Article" feature. | src/entrypoints/popup/app.tsx:37 |
ReadButton | A button to trigger the AI-powered article analysis feature. | src/entrypoints/popup/components/read-button.tsx |
TranslateButton | A button to toggle full-page translation on or off. | src/entrypoints/popup/components/translate-button.tsx |
AlwaysTranslate | A toggle to automatically translate the current website in the future. | src/entrypoints/popup/app.tsx:40 |
Hotkey | A selector for the modifier key used for hover-to-translate functionality. | src/entrypoints/popup/app.tsx:41 |
AISmartContext | A toggle to enable or disable using webpage context to improve translation quality. | src/entrypoints/popup/app.tsx:42 |
MoreMenu | A dropdown menu with links to external resources like Discord, GitHub, and tutorials. | src/entrypoints/popup/components/more-menu.tsx |
Sources: src/entrypoints/popup/app.tsx:27-56, src/locales/en.yml:10-100
Core Actions
The popup provides two primary action buttons: "Read Article" and "Translate".
Translate Page
The TranslateButton component is responsible for toggling the page translation feature. When clicked, it sends a message to the content script of the active tab to either start or stop the translation process.
The button's appearance and text change based on whether translation is currently active on the page, which is determined by listening to storage changes.
The following sequence diagram shows the flow for enabling page translation.
Read Article
The ReadButton component initiates the "Read Article" feature. This feature uses AI to analyze and explain the main content of the current page. When the user clicks the button, a message is sent to the side.content script, which then opens the side panel and begins the article extraction and analysis process.
The button is disabled if the side panel is already open to prevent conflicts.
Footer and External Links
The footer of the Popup UI provides access to more detailed settings, displays the extension version, and contains a MoreMenu for external links.
Sources: src/entrypoints/popup/app.tsx:44-56
Options Page
A "Settings" button navigates the user to the full options page of the extension, which is opened in a new tab. This is achieved by calling browser.runtime.openOptionsPage().
Sources: src/entrypoints/popup/app.tsx:48
More Menu
The MoreMenu component is a dropdown that provides users with quick links to community pages, source code, and other resources.
| Menu Item | URL | Icon |
|---|---|---|
| Join Discord | https://discord.gg/ej45e3PezJ | logos:discord-icon |
| Join WeChat | `https://github.com/mengxi-ream/read-frog/blob/HEAD/assets/wechat-account.jpg%60 | streamline-logos:wechat-logo-solid |
| Star on Github | `https://github.com/mengxi-ream/read-frog%60 | fa7-brands:github |
| Rate Us | Dynamically generated review URL | tabler:star |
| E-book Reader | https://www.neat-reader.com/webapp#/ | tabler:book |
| Tutorial | https://readfrog.app/tutorial/ | tabler:help-circle |
Sources: src/entrypoints/popup/components/more-menu.tsx:8-30