Skip to content
This repository was archived by the owner on Aug 16, 2024. It is now read-only.

Commit 9632247

Browse files
committed
feat: reset app position
1 parent b9ff17e commit 9632247

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

src/pages/Content/components/App/index.tsx

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import clsx from 'clsx'
2-
import React, { useCallback, useEffect, useState } from 'react'
2+
import React, { useCallback, useEffect, useMemo, useState } from 'react'
33
import Draggable, { DraggableEventHandler } from 'react-draggable'
44
import cc from 'chrome-call'
55
// @ts-ignore
@@ -20,6 +20,22 @@ const App: React.FC = () => {
2020
const [close, setClose] = useState(false)
2121
const dispatch = useTranslateJobsDispatch()
2222

23+
const appPosition = useMemo(() => {
24+
const vw = Math.max(
25+
document.documentElement.clientWidth || 0,
26+
window.innerWidth || 0,
27+
)
28+
const vh = Math.max(
29+
document.documentElement.clientHeight || 0,
30+
window.innerHeight || 0,
31+
)
32+
33+
return {
34+
x: vw - 450 - 20,
35+
y: vh - 600 - 20,
36+
}
37+
}, [])
38+
2339
const onNewJob = useCallback(
2440
(job: TranslateJob) => {
2541
logger.debug({
@@ -72,7 +88,7 @@ const App: React.FC = () => {
7288
<Draggable
7389
handle=".ate_App__header"
7490
onStart={onDragStart}
75-
defaultPosition={{ x: 20, y: 20 }}>
91+
defaultPosition={appPosition}>
7692
<div className={clsx(['ate_App', close && 'ate_App--inactive'])}>
7793
<div className="ate_App__header">
7894
<span>A Translator</span>

src/pages/Content/styles/index.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
height: 25px;
4040
background-repeat: no-repeat;
4141
background-size: 25px 25px;
42+
43+
@apply rounded;
4244
}
4345

4446
#ate-icon.active {

0 commit comments

Comments
 (0)