UNPKG

@react-spectrum/s2

Version:
1 lines 2.11 kB
{"mappings":";;AAAA;;;;;;;;;;CAUC;AAKM,SAAS,0CAA2C,GAAkC,EAAE,KAA2D;IACxJ,OAAO,CAAA,GAAA,yBAAiB,EAAE,OAAO,CAAC,OAAO;QACvC,IAAI,YAAY,SAAS,IAAI,IAAI,OAAO,EAAE;YACxC,IAAI,SAAC,QAAQ,WAAG,SAAS,GAAE,GAAG,IAAI,OAAO,CAAC,qBAAqB,MAAM,CAAC;YACtE,OAAO;gBACL,GAAG,KAAK;gBACR,YAAY,GAAG,OAAO,cAAc,GAAG,UAAU,CAAC;gBAClD,WAAW,GAAG,OAAO,aAAa,GAAG,aAAa,EAAE,KAAK,GAAG,CAAC,QAAQ,QAAQ,GAAG,IAAI,2BAA2B,CAAC;YAClH;QACF,OACE,OAAO;YACL,GAAG,KAAK;YACR,YAAY,GAAG,OAAO,cAAc,GAAG,UAAU,CAAC;QACpD;IAEJ;AACF","sources":["packages/@react-spectrum/s2/src/pressScale.ts"],"sourcesContent":["/*\n * Copyright 2024 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {composeRenderProps} from 'react-aria-components';\nimport {CSSProperties, RefObject} from 'react';\n\nexport function pressScale<R extends {isPressed: boolean}>(ref: RefObject<HTMLElement | null>, style?: CSSProperties | ((renderProps: R) => CSSProperties)): (renderProps: R) => CSSProperties {\n return composeRenderProps(style, (style, renderProps: R) => {\n if (renderProps.isPressed && ref.current) {\n let {width = 0, height = 0} = ref.current.getBoundingClientRect() ?? {};\n return {\n ...style,\n willChange: `${style?.willChange ?? ''} transform`,\n transform: `${style?.transform ?? ''} perspective(${Math.max(height, width / 3, 24)}px) translate3d(0, 0, -2px)`\n };\n } else {\n return {\n ...style,\n willChange: `${style?.willChange ?? ''} transform`\n };\n }\n });\n}\n"],"names":[],"version":3,"file":"pressScale.mjs.map"}