MCPcopy Index your code
hub / github.com/adobe/react-spectrum / pressScale

Function pressScale

packages/@react-spectrum/s2/src/pressScale.ts:36–55  ·  view source on GitHub ↗
(
  ref: RefObject<HTMLElement | null>,
  style?: CSSProperties | ((renderProps: R) => CSSProperties)
)

Source from the content-addressed store, hash-verified

34 * `style` prop.
35 */
36export function pressScale<R extends {isPressed: boolean}>(
37 ref: RefObject<HTMLElement | null>,
38 style?: CSSProperties | ((renderProps: R) => CSSProperties)
39): (renderProps: R) => CSSProperties {
40 return composeRenderProps(style, (style, renderProps: R) => {
41 if (renderProps.isPressed && ref.current) {
42 let {width = 0, height = 0} = ref.current.getBoundingClientRect() ?? {};
43 return {
44 ...style,
45 willChange: `${style?.willChange ?? ''} transform`,
46 transform: `${style?.transform ?? ''} perspective(${Math.max(height, width / 3, 24)}px) translate3d(0, 0, -2px)`
47 };
48 } else {
49 return {
50 ...style,
51 willChange: `${style?.willChange ?? ''} transform`
52 };
53 }
54 });
55}

Callers 15

ButtonFunction · 0.90
ReleaseLinkFunction · 0.90
ColorSchemeToggleFunction · 0.90
SideNavItemFunction · 0.90
SideNavLinkFunction · 0.90
IconItemFunction · 0.90
ColorItemFunction · 0.90
HeaderLinkFunction · 0.90
ColorSchemeToggleFunction · 0.90
HeaderFunction · 0.90
IconItemFunction · 0.90
ColorSchemeToggleFunction · 0.90

Calls 1

composeRenderPropsFunction · 0.85

Tested by

no test coverage detected