about summary refs log tree commit diff
path: root/src/components/MediaInsetBorder.tsx
blob: ed89880f40824c7603751572f11426142457995b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import React from 'react'

import {atoms as a, useTheme, ViewStyleProp} from '#/alf'
import {Fill} from '#/components/Fill'

/**
 * Applies and thin border within a bounding box. Used to contrast media from
 * bg of the container.
 */
export function MediaInsetBorder({
  children,
  style,
  opaque,
}: {
  children?: React.ReactNode
  /**
   * Used where this border needs to match adjacent borders, such as in
   * external link previews
   */
  opaque?: boolean
} & ViewStyleProp) {
  const t = useTheme()
  const isLight = t.name === 'light'
  return (
    <Fill
      style={[
        a.rounded_md,
        a.border,
        opaque
          ? [t.atoms.border_contrast_low]
          : [
              isLight
                ? t.atoms.border_contrast_low
                : t.atoms.border_contrast_high,
              {opacity: 0.6},
            ],
        {
          pointerEvents: 'none',
        },
        style,
      ]}>
      {children}
    </Fill>
  )
}