about summary refs log tree commit diff
path: root/src/alf/util/useGutterStyles.ts
blob: 64b246fdd2595a12c2d4e12796fdada87efe3167 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import React from 'react'

import {atoms as a, useBreakpoints, ViewStyleProp} from '#/alf'

export function useGutterStyles({
  top,
  bottom,
}: {
  top?: boolean
  bottom?: boolean
} = {}) {
  const {gtMobile} = useBreakpoints()
  return React.useMemo<ViewStyleProp['style']>(() => {
    return [
      a.px_lg,
      top && a.pt_md,
      bottom && a.pb_md,
      gtMobile && [a.px_xl, top && a.pt_lg, bottom && a.pb_lg],
    ]
  }, [gtMobile, top, bottom])
}