+
+
attachStickyDataAttribute(gitakoDescriptionTarget, spacingAttributeName, ({ oldValue }) =>
- setBodyIndent(oldValue === 'true'),
+ setBodyIndent(
+ (oldValue &&
+ (
+ {
+ left: 'left',
+ right: 'right',
+ } as const
+ )[oldValue]) ||
+ 'left',
+ ),
)
-export function setBodyIndent(shouldShowGitako: boolean) {
- gitakoDescriptionTarget.setAttribute(spacingAttributeName, `${shouldShowGitako}`)
+export function setBodyIndent(placement: Config['sidebarPlacement'] | false) {
+ gitakoDescriptionTarget.setAttribute(spacingAttributeName, `${placement}`)
}
/**
diff --git a/src/utils/config/helper.ts b/src/utils/config/helper.ts
index 6b11989..ac46372 100644
--- a/src/utils/config/helper.ts
+++ b/src/utils/config/helper.ts
@@ -22,6 +22,7 @@ export type Config = {
restoreExpandedFolders: boolean
pjaxMode: 'native' | 'pjax-api'
showDiffInText: boolean
+ sidebarPlacement: 'left' | 'right'
__showInspector?: boolean
}
@@ -46,6 +47,7 @@ enum configKeys {
restoreExpandedFolders = 'restoreExpandedFolders',
pjaxMode = 'pjaxMode',
showDiffInText = 'showDiffInText',
+ sidebarPlacement = 'sidebarPlacement',
__showInspector = '__showInspector',
}
@@ -72,6 +74,7 @@ export const getDefaultConfigs: () => Config = () => ({
restoreExpandedFolders: true,
pjaxMode: platformName === 'GitHub' ? 'native' : 'pjax-api', // use native on GitHub
showDiffInText: false,
+ sidebarPlacement: 'left',
})
const configKeyArray = Object.values(configKeys)
diff --git a/src/utils/hooks/useResizeHandler.ts b/src/utils/hooks/useResizeHandler.ts
index 678a19e..cec3142 100644
--- a/src/utils/hooks/useResizeHandler.ts
+++ b/src/utils/hooks/useResizeHandler.ts
@@ -3,6 +3,13 @@ import { Size2D } from '../../components/Size'
export type ResizeState = 'idle' | 'resizing'
+export type ResizeHandlerOptions = Partial<{
+ onResizeStateChange: (state: ResizeState) => void
+ onClick: (e: PointerEvent) => void
+ distanceTolerance: number
+ direction: 'right' | 'left'
+}>
+
export function useResizeHandler(
size: Size2D,
onResize: (size: Size2D) => void,
@@ -10,17 +17,18 @@ export function useResizeHandler(
onResizeStateChange,
onClick,
distanceTolerance = 2,
- }: Partial<{
- onResizeStateChange: (state: ResizeState) => void
- onClick: (e: PointerEvent) => void
- distanceTolerance: number
- }> = {},
+ direction = 'right',
+ }: ResizeHandlerOptions = {},
) {
const pointerDown = React.useRef(false)
const pointerMoved = React.useRef(false)
const initialSizeRef = React.useRef([0, 0])
const baseSize = React.useRef(size)
const latestPropSize = React.useRef(size)
+ const fix = {
+ left: -1,
+ right: 1,
+ }[direction]
React.useEffect(() => {
latestPropSize.current = size
@@ -34,11 +42,11 @@ export function useResizeHandler(
pointerMoved.current =
pointerMoved.current || (clientX - x0) ** 2 + (clientY - y0) ** 2 > distanceTolerance ** 2
const [x1, y1] = baseSize.current
- onResize([x1 + clientX - x0, y1 + clientY - y0])
+ onResize([x1 + (clientX - x0) * fix, y1 + (clientY - y0) * fix])
}
window.addEventListener('pointermove', onPointerMove)
return () => window.removeEventListener('pointermove', onPointerMove)
- }, [onResize, distanceTolerance])
+ }, [onResize, distanceTolerance, fix])
React.useEffect(() => {
const onPointerUp = (e: PointerEvent) => {