@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.
- package/dist/index.cjs.mjs +1 -0
- package/dist/index.d.ts +69 -30
- package/dist/index.esm.js +776 -318
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +777 -319
- package/dist/index.js.map +1 -1
- package/dist/theme.esm.js +21 -21
- package/dist/theme.esm.js.map +1 -1
- package/dist/theme.js +21 -21
- package/dist/theme.js.map +1 -1
- package/package.json +6 -4
- package/src/core/constants.ts +18 -0
- package/src/core/middleware/origin.ts +47 -0
- package/src/core/primitives/badge/badge.tsx +1 -3
- package/src/core/primitives/popover/popover.tsx +67 -13
- package/src/core/primitives/popover/popoverCard.tsx +26 -15
- package/src/core/primitives/select/select.tsx +1 -1
- package/src/core/primitives/tooltip/tooltip.tsx +46 -56
- package/src/core/primitives/tooltip/tooltipCard.tsx +104 -0
- package/src/core/styles/card/_cardColorStyle.ts +2 -0
- package/src/core/{primitives/tooltip → utils/conditionalWrapper}/conditionalWrapper.tsx +3 -0
- package/src/core/utils/conditionalWrapper/index.ts +1 -0
- package/src/core/utils/index.ts +1 -0
- package/src/theme/defaults/colorTokens.ts +21 -21
|
@@ -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'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './conditionalWrapper'
|
package/src/core/utils/index.ts
CHANGED
|
@@ -575,39 +575,39 @@ export const defaultColorTokens: ThemeColorTokens = {
|
|
|
575
575
|
},
|
|
576
576
|
},
|
|
577
577
|
syntax: {
|
|
578
|
-
atrule: ['purple/
|
|
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/
|
|
583
|
-
builtin: ['purple/
|
|
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/
|
|
589
|
-
constant: ['purple/
|
|
590
|
-
deleted: ['red/
|
|
591
|
-
entity: ['red/
|
|
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/
|
|
594
|
-
id: ['purple/
|
|
595
|
-
important: ['purple/
|
|
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/
|
|
598
|
-
number: ['purple/
|
|
599
|
-
operator: ['magenta/
|
|
600
|
-
property: ['blue/
|
|
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/
|
|
604
|
-
regex: ['blue/
|
|
605
|
-
selector: ['red/
|
|
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/
|
|
608
|
-
tag: ['red/
|
|
607
|
+
symbol: ['purple/600', 'purple/400'],
|
|
608
|
+
tag: ['red/600', 'red/400'],
|
|
609
609
|
unit: ['orange/700', 'orange/400'],
|
|
610
|
-
url: ['red/
|
|
611
|
-
variable: ['red/
|
|
610
|
+
url: ['red/600', 'red/400'],
|
|
611
|
+
variable: ['red/600', 'red/400'],
|
|
612
612
|
},
|
|
613
613
|
}
|