UNPKG

@atlaskit/motion

Version:

A set of utilities to apply motion in your application.

19 lines (18 loc) 664 B
import { getDocument } from '@atlaskit/browser-apis'; /** * Resolves a motion token to a string value. * @param token - The motion token to resolve. * @returns The string value for the motion token. */ export const resolveMotionToken = token => { const cssVarMatch = token.match(/var\(\s*(--[^,\s)]+)/); const cssVar = cssVarMatch ? cssVarMatch[1] : null; if (cssVar) { var _getDocument; const documentElement = (_getDocument = getDocument()) === null || _getDocument === void 0 ? void 0 : _getDocument.documentElement; if (documentElement) { return getComputedStyle(documentElement).getPropertyValue(cssVar); } } return ''; };