Skip to content

Commit

Permalink
refactor: default exports
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrieljablonski committed Feb 18, 2024
1 parent 21385dc commit 74b4243
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/components/Tooltip/Tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import classNames from 'classnames'
import debounce from 'utils/debounce'
import { useTooltip } from 'components/TooltipProvider'
import useIsomorphicLayoutEffect from 'utils/use-isomorphic-layout-effect'
import { getScrollParent } from 'utils/get-scroll-parent'
import { computeTooltipPosition } from 'utils/compute-positions'
import computeTooltipPosition from 'utils/compute-positions'
import type { IComputedPosition } from 'utils/compute-positions-types'
import { cssTimeToMs } from 'utils/css-time-to-ms'
import cssTimeToMs from 'utils/css-time-to-ms'
import { deepEqual } from 'utils/deep-equal'
import getScrollParent from 'utils/get-scroll-parent'
import coreStyles from './core-styles.module.css'
import styles from './styles.module.css'
import type {
Expand Down
4 changes: 2 additions & 2 deletions src/test/utils.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import debounce from 'utils/debounce'
import { computeTooltipPosition } from 'utils/compute-positions'
import { cssTimeToMs } from 'utils/css-time-to-ms'
import computeTooltipPosition from 'utils/compute-positions'
import cssTimeToMs from 'utils/css-time-to-ms'

// Tell Jest to mock all timeout functions
jest.useRealTimers()
Expand Down
4 changes: 3 additions & 1 deletion src/utils/compute-positions.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { computePosition, offset, shift, arrow, flip } from '@floating-ui/dom'
import type { IComputePositions } from './compute-positions-types'

export const computeTooltipPosition = async ({
const computeTooltipPosition = async ({
elementReference = null,
tooltipReference = null,
tooltipArrowReference = null,
Expand Down Expand Up @@ -96,3 +96,5 @@ export const computeTooltipPosition = async ({
return { tooltipStyles: styles, tooltipArrowStyles: {}, place: placement }
})
}

export default computeTooltipPosition
4 changes: 3 additions & 1 deletion src/utils/css-time-to-ms.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
export const cssTimeToMs = (time: string): number => {
const cssTimeToMs = (time: string): number => {
const match = time.match(/^([\d.]+)(ms|s)$/)
if (!match) {
return 0
}
const [, amount, unit] = match
return Number(amount) * (unit === 'ms' ? 1 : 1000)
}

export default cssTimeToMs
4 changes: 3 additions & 1 deletion src/utils/get-scroll-parent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const isScrollable = (node: Element) => {
})
}

export const getScrollParent = (node: Element | null) => {
const getScrollParent = (node: Element | null) => {
if (!node) {
return null
}
Expand All @@ -22,3 +22,5 @@ export const getScrollParent = (node: Element | null) => {
}
return document.scrollingElement || document.documentElement
}

export default getScrollParent

0 comments on commit 74b4243

Please sign in to comment.