Skip to content

Commit

Permalink
refactor: rename internal types to be more consistent with rest of co…
Browse files Browse the repository at this point in the history
…de base
  • Loading branch information
nerdyman committed Sep 11, 2022
1 parent e7d5d8f commit b501c53
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
10 changes: 5 additions & 5 deletions src/ReactCompareSlider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ import React, { useEffect, useCallback, useRef, useState } from 'react';

import { ContainerClip, ContainerHandle } from './Container';
import { ReactCompareSliderHandle } from './ReactCompareSliderHandle';
import type { ReactCompareSliderAllProps } from './types';
import type { ReactCompareSliderDetailedProps } from './types';
import {
KeyboardEventKeys,
useEventListener,
usePrevious,
UseResizeObserverHandlerParams,
UseResizeObserverHandlerProps,
useResizeObserver,
} from './utils';

/** Properties for internal `updateInternalPosition` callback. */
interface UpdateInternalPositionProps
extends Required<Pick<ReactCompareSliderAllProps, 'boundsPadding' | 'portrait'>> {
extends Required<Pick<ReactCompareSliderDetailedProps, 'boundsPadding' | 'portrait'>> {
/** X coordinate to update to (landscape). */
x: number;
/** Y coordinate to update to (portrait). */
Expand All @@ -26,7 +26,7 @@ const EVENT_PASSIVE_PARAMS = { passive: true };
const EVENT_CAPTURE_PARAMS = { capture: true, passive: false };

/** Root Comparison slider. */
export const ReactCompareSlider: React.FC<ReactCompareSliderAllProps> = ({
export const ReactCompareSlider: React.FC<ReactCompareSliderDetailedProps> = ({
handle,
itemOne,
itemTwo,
Expand Down Expand Up @@ -225,7 +225,7 @@ export const ReactCompareSlider: React.FC<ReactCompareSliderAllProps> = ({
}, []);

/** Resync internal position on resize. */
const handleResize: (resizeProps: UseResizeObserverHandlerParams) => void = useCallback(
const handleResize: (resizeProps: UseResizeObserverHandlerProps) => void = useCallback(
({ width, height }) => {
const { width: scaledWidth, height: scaledHeight } = (
rootContainerRef.current as HTMLDivElement
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ export type { ReactCompareSliderHandleProps } from './ReactCompareSliderHandle';
export { ReactCompareSliderImage } from './ReactCompareSliderImage';
export type { ReactCompareSliderImageProps } from './ReactCompareSliderImage';

export type { ReactCompareSliderAllProps, ReactCompareSliderProps } from './types';
export type { ReactCompareSliderDetailedProps, ReactCompareSliderProps } from './types';

export { styleFitContainer } from './utils';
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ export interface ReactCompareSliderProps extends Partial<ReactCompareSliderCommo
}

/** `ReactCompareSliderProps` *and* all valid `div` element props. */
export type ReactCompareSliderAllProps = ReactCompareSliderProps &
export type ReactCompareSliderDetailedProps = ReactCompareSliderProps &
React.HtmlHTMLAttributes<HTMLDivElement>;
8 changes: 4 additions & 4 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export enum KeyboardEventKeys {
export const styleFitContainer = ({
boxSizing = 'border-box',
objectFit = 'cover',
objectPosition = 'center',
objectPosition = 'center center',
...props
}: React.CSSProperties = {}): React.CSSProperties => ({
display: 'block',
Expand Down Expand Up @@ -76,7 +76,7 @@ export const useEventListener = (

/**
* Conditionally use `useLayoutEffect` for client *or* `useEffect` for SSR.
* @see <https://github.com/reduxjs/react-redux/blob/c581d480dd675f2645851fb006bef91aeb6ac24d/src/utils/useIsomorphicLayoutEffect.js>
* @see https://github.com/reduxjs/react-redux/blob/c581d480dd675f2645851fb006bef91aeb6ac24d/src/utils/useIsomorphicLayoutEffect.js
*/
export const useIsomorphicLayoutEffect =
typeof window !== 'undefined' &&
Expand All @@ -86,7 +86,7 @@ export const useIsomorphicLayoutEffect =
: useEffect;

/** Params passed to `useResizeObserver` `handler` function. */
export type UseResizeObserverHandlerParams = DOMRect;
export type UseResizeObserverHandlerProps = DOMRect;

/**
* Bind resize observer callback to element.
Expand All @@ -95,7 +95,7 @@ export type UseResizeObserverHandlerParams = DOMRect;
*/
export const useResizeObserver = (
ref: RefObject<Element>,
handler: (entry: UseResizeObserverHandlerParams) => void
handler: (entry: UseResizeObserverHandlerProps) => void
): void => {
const observer = useRef<ResizeObserver>();

Expand Down

0 comments on commit b501c53

Please sign in to comment.