PHP 8.2.30
Preview: theme-get.js Size: 1.47 KB
//proc/thread-self/root/home/byroehnu/.trash/node_modules11/@adminjs/design-system/build/utils/theme-get.js

import { getValueAndUnit } from 'polished';
export function themeGet(kind, value, offset) {
  return ({
    theme
  }) => {
    const themeVal = value ? theme[kind][value] : theme[kind];
    if (themeVal && offset) {
      let offsetValue;
      if (typeof offset === 'string') {
        [offsetValue] = getValueAndUnit(offset);
      } else {
        offsetValue = offset;
      }
      const [pxValue, unit] = getValueAndUnit(themeVal);
      return `${pxValue + offsetValue}${unit}`;
    }
    return themeVal;
  };
}
export default themeGet;

/**
 *
 * Handy utility function which simplifies taking values from the {@link Theme}.
 *
 * ### Example
 *
 * ```javascript
 * import { Box, themeGet } from '@adminjs/design-system'
 *
 * const myComponent = styled(Box)`
 *   padding: ${themeGet('space', 'xl')};
 *   font: ${themeGet('font')};
 *   margin-top: ${themeGet('space', 'xl', -2)};
 *
 *   margin-bottom: ${(props) => themeGet('space', props.disabled ? 'xl' : 'xxl')(props)};
 * `
 *
 * ```
 *
 * @param {string} kind           One of the keys in the {@link Theme} interface. For example:
 *                                `fontWeights`
 * @param {string} [value]        Value for the key
 * @param {string | number} [offset]    optional offset. When you want to take xxl + 2pixels
 *                                you can do this by passing +2 as the offset.
 * @return {ThemeFunction}  function taking props as an argument
 *
 * @new in version 3.3
 * @function themeGet
 * @memberof Theme
 */

Directory Contents

Dirs: 0 × Files: 21

Name Size Perms Modified Actions
193 B lrw-r--r-- 2026-02-28 00:28:24
Edit Download
10 B lrw-r--r-- 2026-02-28 00:31:02
Edit Download
666 B lrw-r--r-- 2026-02-28 00:31:04
Edit Download
6.12 KB lrw-r--r-- 2026-02-28 00:31:04
Edit Download
841 B lrw-r--r-- 2026-02-28 00:31:04
Edit Download
1.34 KB lrw-r--r-- 2026-02-28 00:31:10
Edit Download
23.50 KB lrw-r--r-- 2026-02-28 00:31:10
Edit Download
10 B lrw-r--r-- 2026-02-28 00:31:10
Edit Download
10 B lrw-r--r-- 2026-02-28 00:31:10
Edit Download
218 B lrw-r--r-- 2026-02-28 00:31:14
Edit Download
325 B lrw-r--r-- 2026-02-28 00:31:14
Edit Download
875 B lrw-r--r-- 2026-02-28 00:31:18
Edit Download
501 B lrw-r--r-- 2026-02-28 00:31:28
Edit Download
10 B lrw-r--r-- 2026-02-28 00:31:32
Edit Download
42.05 KB lrw-r--r-- 2026-02-28 00:31:36
Edit Download
1.02 KB lrw-r--r-- 2026-02-28 00:31:36
Edit Download
2.01 KB lrw-r--r-- 2026-02-28 00:31:36
Edit Download
1.06 KB lrw-r--r-- 2026-02-28 00:31:36
Edit Download
823 B lrw-r--r-- 2026-02-28 00:31:36
Edit Download
238 B lrw-r--r-- 2026-02-28 00:31:36
Edit Download
1.47 KB lrw-r--r-- 2026-02-28 00:31:38
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).