Skip to content

Commit f320e3e

Browse files
committed
WIP, custom API Modes
1 parent 8706737 commit f320e3e

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

src/popup/Popup.jsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ function Popup() {
6262
const [config, setConfig] = useState(defaultConfig)
6363
const [currentVersion, setCurrentVersion] = useState('')
6464
const [latestVersion, setLatestVersion] = useState('')
65+
const [tabIndex, setTabIndex] = useState(0)
6566
const theme = useWindowTheme()
6667

6768
const updateConfig = async (value) => {
@@ -94,7 +95,13 @@ function Popup() {
9495
return (
9596
<div className={popup === 'true' ? 'container-popup-mode' : 'container-page-mode'}>
9697
<form style="width:100%;">
97-
<Tabs selectedTabClassName="popup-tab--selected">
98+
<Tabs
99+
selectedTabClassName="popup-tab--selected"
100+
selectedIndex={tabIndex}
101+
onSelect={(index) => {
102+
setTabIndex(index)
103+
}}
104+
>
98105
<TabList>
99106
<Tab className="popup-tab">{t('General')}</Tab>
100107
<Tab className="popup-tab">{t('Feature Pages')}</Tab>
@@ -103,7 +110,7 @@ function Popup() {
103110
</TabList>
104111

105112
<TabPanel>
106-
<GeneralPart config={config} updateConfig={updateConfig} />
113+
<GeneralPart config={config} updateConfig={updateConfig} setTabIndex={setTabIndex} />
107114
</TabPanel>
108115
<TabPanel>
109116
<FeaturePages config={config} updateConfig={updateConfig} />

src/popup/sections/GeneralPart.jsx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,12 @@ import Browser from 'webextension-polyfill'
2727
import { languageList } from '../../config/language.mjs'
2828
import PropTypes from 'prop-types'
2929
import { config as menuConfig } from '../../content-script/menu-tools'
30+
import { PencilIcon } from '@primer/octicons-react'
3031

3132
GeneralPart.propTypes = {
3233
config: PropTypes.object.isRequired,
3334
updateConfig: PropTypes.func.isRequired,
35+
setTabIndex: PropTypes.func.isRequired,
3436
}
3537

3638
function formatDate(date) {
@@ -86,7 +88,7 @@ async function checkBilling(apiKey, apiUrl) {
8688
}
8789
}
8890

89-
export function GeneralPart({ config, updateConfig }) {
91+
export function GeneralPart({ config, updateConfig, setTabIndex }) {
9092
const { t, i18n } = useTranslation()
9193
const [balance, setBalance] = useState(null)
9294
const [apiModes, setApiModes] = useState([])
@@ -154,7 +156,18 @@ export function GeneralPart({ config, updateConfig }) {
154156
</select>
155157
</label>
156158
<label>
157-
<legend>{t('API Mode')}</legend>
159+
<legend style={{ display: 'flex', alignItems: 'center', gap: '8px' }}>
160+
{t('API Mode')}
161+
<div
162+
style={{ cursor: 'pointer' }}
163+
onClick={(e) => {
164+
e.preventDefault()
165+
setTabIndex(2)
166+
}}
167+
>
168+
<PencilIcon />
169+
</div>
170+
</legend>
158171
<span style="display: flex; gap: 15px;">
159172
<select
160173
style={

0 commit comments

Comments
 (0)