@sanity/ui 2.0.0-beta.4 → 2.0.0-beta.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,104 @@
1
+ import {ThemeColorSchemeKey} from '@sanity/ui/theme'
2
+ import {MotionProps, motion} from 'framer-motion'
3
+ import React, {CSSProperties, forwardRef, memo, useMemo} from 'react'
4
+ import styled from 'styled-components'
5
+ import {POPOVER_MOTION_PROPS} from '../../constants'
6
+ import {Placement, Radius} from '../../types'
7
+ import {Arrow} from '../../utils'
8
+ import {Card, CardProps} from '../card'
9
+ import {
10
+ DEFAULT_TOOLTIP_ARROW_HEIGHT,
11
+ DEFAULT_TOOLTIP_ARROW_RADIUS,
12
+ DEFAULT_TOOLTIP_ARROW_WIDTH,
13
+ } from './constants'
14
+
15
+ const MotionCard = styled(motion(Card))``
16
+
17
+ /**
18
+ * @internal
19
+ */
20
+ export const TooltipCard = memo(
21
+ forwardRef(function TooltipCard(
22
+ props: {
23
+ animate?: boolean
24
+ arrow: boolean
25
+ arrowRef: React.Ref<HTMLDivElement>
26
+ arrowX?: number
27
+ arrowY?: number
28
+ originX?: number
29
+ originY?: number
30
+ padding?: number | number[]
31
+ placement?: Placement
32
+ radius?: Radius | Radius[]
33
+ scheme?: ThemeColorSchemeKey
34
+ shadow?: number | number[]
35
+ } & Omit<React.HTMLProps<HTMLDivElement>, 'as' | 'height' | 'width'>,
36
+ ref: React.ForwardedRef<HTMLDivElement>,
37
+ ) {
38
+ const {
39
+ animate,
40
+ arrow,
41
+ arrowRef,
42
+ arrowX,
43
+ arrowY,
44
+ children,
45
+ originX,
46
+ originY,
47
+ padding,
48
+ placement,
49
+ radius,
50
+ scheme,
51
+ shadow,
52
+ style,
53
+ ...restProps
54
+ } = props
55
+
56
+ const rootStyle: CSSProperties = useMemo(
57
+ () => ({
58
+ originX,
59
+ originY,
60
+ ...style,
61
+ }),
62
+ [originX, originY, style],
63
+ )
64
+
65
+ const arrowStyle: CSSProperties = useMemo(
66
+ () => ({
67
+ left: arrowX !== null ? arrowX : undefined,
68
+ top: arrowY !== null ? arrowY : undefined,
69
+ right: undefined,
70
+ bottom: undefined,
71
+ }),
72
+ [arrowX, arrowY],
73
+ )
74
+
75
+ return (
76
+ <MotionCard
77
+ data-ui="Tooltip__card"
78
+ {...(restProps as CardProps & MotionProps)}
79
+ data-placement={placement}
80
+ padding={padding}
81
+ radius={radius}
82
+ ref={ref}
83
+ scheme={scheme}
84
+ shadow={shadow}
85
+ style={rootStyle}
86
+ {...(animate ? POPOVER_MOTION_PROPS : {})}
87
+ >
88
+ {children}
89
+
90
+ {arrow && (
91
+ <Arrow
92
+ ref={arrowRef}
93
+ style={arrowStyle}
94
+ width={DEFAULT_TOOLTIP_ARROW_WIDTH}
95
+ height={DEFAULT_TOOLTIP_ARROW_HEIGHT}
96
+ radius={DEFAULT_TOOLTIP_ARROW_RADIUS}
97
+ />
98
+ )}
99
+ </MotionCard>
100
+ )
101
+ }),
102
+ )
103
+
104
+ TooltipCard.displayName = 'TooltipCard'
@@ -12,6 +12,8 @@ export function _cardColorStyle(
12
12
  return {
13
13
  // from base
14
14
 
15
+ '--card-backdrop-color': base.backdrop,
16
+
15
17
  '--card-focus-ring-color': base.focusRing,
16
18
 
17
19
  '--card-shadow-outline-color': base.shadow.outline,
@@ -1,3 +1,6 @@
1
+ /**
2
+ * @internal
3
+ */
1
4
  export function ConditionalWrapper({
2
5
  children,
3
6
  condition,
@@ -0,0 +1 @@
1
+ export * from './conditionalWrapper'
@@ -1,5 +1,6 @@
1
1
  export * from './arrow'
2
2
  export * from './boundaryElement'
3
+ export * from './conditionalWrapper'
3
4
  export * from './elementQuery'
4
5
  export * from './errorBoundary'
5
6
  export * from './layer'
@@ -575,39 +575,39 @@ export const defaultColorTokens: ThemeColorTokens = {
575
575
  },
576
576
  },
577
577
  syntax: {
578
- atrule: ['purple/700', 'purple/400'],
578
+ atrule: ['purple/600', 'purple/400'],
579
579
  attrName: ['green/700', 'green/400'],
580
580
  attrValue: ['yellow/700', 'yellow/400'],
581
581
  attribute: ['yellow/700', 'yellow/400'],
582
- boolean: ['purple/700', 'purple/400'],
583
- builtin: ['purple/700', 'purple/400'],
582
+ boolean: ['purple/600', 'purple/400'],
583
+ builtin: ['purple/600', 'purple/400'],
584
584
  cdata: ['yellow/700', 'yellow/400'],
585
585
  char: ['yellow/700', 'yellow/400'],
586
586
  class: ['orange/700', 'orange/400'],
587
587
  className: ['cyan/700', 'cyan/400'],
588
- comment: ['gray/700/0.5', 'gray/400/0.5'],
589
- constant: ['purple/700', 'purple/400'],
590
- deleted: ['red/700', 'red/400'],
591
- entity: ['red/700', 'red/400'],
588
+ comment: ['gray/400', 'gray/600'],
589
+ constant: ['purple/600', 'purple/400'],
590
+ deleted: ['red/600', 'red/400'],
591
+ entity: ['red/600', 'red/400'],
592
592
  function: ['green/700', 'green/400'],
593
- hexcode: ['blue/700', 'blue/400'],
594
- id: ['purple/700', 'purple/400'],
595
- important: ['purple/700', 'purple/400'],
593
+ hexcode: ['blue/600', 'blue/400'],
594
+ id: ['purple/600', 'purple/400'],
595
+ important: ['purple/600', 'purple/400'],
596
596
  inserted: ['yellow/700', 'yellow/400'],
597
- keyword: ['magenta/700', 'magenta/400'],
598
- number: ['purple/700', 'purple/400'],
599
- operator: ['magenta/700', 'magenta/400'],
600
- property: ['blue/700', 'blue/400'],
597
+ keyword: ['magenta/600', 'magenta/400'],
598
+ number: ['purple/600', 'purple/400'],
599
+ operator: ['magenta/600', 'magenta/400'],
600
+ property: ['blue/600', 'blue/400'],
601
601
  pseudoClass: ['yellow/700', 'yellow/400'],
602
602
  pseudoElement: ['yellow/700', 'yellow/400'],
603
- punctuation: ['gray/700', 'gray/400'],
604
- regex: ['blue/700', 'blue/400'],
605
- selector: ['red/700', 'red/400'],
603
+ punctuation: ['gray/600', 'gray/400'],
604
+ regex: ['blue/600', 'blue/400'],
605
+ selector: ['red/600', 'red/400'],
606
606
  string: ['yellow/700', 'yellow/400'],
607
- symbol: ['purple/700', 'purple/400'],
608
- tag: ['red/700', 'red/400'],
607
+ symbol: ['purple/600', 'purple/400'],
608
+ tag: ['red/600', 'red/400'],
609
609
  unit: ['orange/700', 'orange/400'],
610
- url: ['red/700', 'red/400'],
611
- variable: ['red/700', 'red/400'],
610
+ url: ['red/600', 'red/400'],
611
+ variable: ['red/600', 'red/400'],
612
612
  },
613
613
  }