Skip to content

Commit 9d2b74a

Browse files
committed
Feat: Make on-page popup resizable and fix layout
1 parent 7b99ec5 commit 9d2b74a

File tree

4 files changed

+41
-30
lines changed

4 files changed

+41
-30
lines changed

package-lock.json

Lines changed: 19 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/FloatingToolbar/index.jsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import PropTypes from 'prop-types'
44
import { config as toolsConfig } from '../../content-script/selection-tools'
55
import { getClientPosition, isMobile, setElementPositionInViewport } from '../../utils'
66
import Draggable from 'react-draggable'
7-
import { useClampWindowSize } from '../../hooks/use-clamp-window-size'
87
import { useTranslation } from 'react-i18next'
98
import { useConfig } from '../../hooks/use-config.mjs'
109

@@ -19,7 +18,6 @@ function FloatingToolbar(props) {
1918
const [closeable, setCloseable] = useState(props.closeable)
2019
const [position, setPosition] = useState(getClientPosition(props.container))
2120
const [virtualPosition, setVirtualPosition] = useState({ x: 0, y: 0 })
22-
const windowSize = useClampWindowSize([750, 1500], [0, Infinity])
2321
const config = useConfig(() => {
2422
setRender(true)
2523
if (!triggered && selection) {
@@ -92,10 +90,7 @@ function FloatingToolbar(props) {
9290
onStop={dragEvent.onStop}
9391
position={virtualPosition}
9492
>
95-
<div
96-
className="chatgptbox-selection-window"
97-
style={{ width: windowSize[0] * 0.4 + 'px' }}
98-
>
93+
<div className="chatgptbox-selection-window">
9994
<div className="chatgptbox-container">
10095
<ConversationCard
10196
session={props.session}

src/content-script/styles.scss

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,11 @@
7474
flex-grow: 1;
7575
margin-bottom: 20px;
7676

77+
display: flex;
78+
min-height: 0;
79+
7780
.gpt-inner {
78-
height: 100%;
81+
flex: 1;
7982
display: flex;
8083
position: relative;
8184
flex-direction: column;
@@ -99,6 +102,8 @@
99102
color: var(--font-color);
100103
overflow-y: auto;
101104
overflow-x: hidden;
105+
flex: 1; /* <-- ADD THIS (tells it to grow/shrink) */
106+
min-height: 0; /* <-- ADD THIS (critical for it to shrink properly) */
102107

103108
::-webkit-scrollbar {
104109
background-color: var(--theme-color);
@@ -1357,7 +1362,10 @@
13571362
border: 0;
13581363
border-top: 1px solid var(--theme-border-color);
13591364
width: 100%;
1360-
height: 100%;
1365+
// height: 100%; <-- COMMENT OUT OR DELETE THIS LINE
1366+
height: 70px; /* <-- SET A FIXED STARTING HEIGHT */
1367+
min-height: 70px; /* <-- SET A MINIMUM HEIGHT */
1368+
resize: none !important; /* <-- DISABLE THE TEXTAREA'S OWN RESIZE */
13611369
background-color: var(--theme-color);
13621370
color: var(--font-color);
13631371

@@ -1445,8 +1453,17 @@
14451453
}
14461454

14471455
.chatgptbox-selection-window {
1448-
height: auto;
14491456
border-radius: 8px;
14501457
background-color: var(--theme-color);
14511458
box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.2);
1459+
1460+
width: 500px;
1461+
height: 450px;
1462+
resize: both;
1463+
overflow: hidden;
1464+
min-width: 350px;
1465+
min-height: 300px;
1466+
1467+
display: flex;
1468+
flex-direction: column;
14521469
}

src/popup/styles.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
display: flex;
4040
flex-direction: column;
4141
align-items: center;
42-
width: 460px;
42+
width: 430px;
4343
height: 560px;
4444
padding: 20px;
4545
overflow-y: auto;

0 commit comments

Comments
 (0)