PHP 8.2.30
Preview: theme-get.ts Size: 1.53 KB
/home/byroehnu/.trash/node_modules11/@adminjs/design-system/src/utils/theme-get.ts

import { getValueAndUnit } from 'polished'

export function themeGet(
  kind: string,
  value?: string | number,
  offset?: number | string,
): any {
  return ({ theme }) => {
    const themeVal = value ? theme[kind][value] : theme[kind]

    if (themeVal && offset) {
      let offsetValue: number
      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
226 B lrw-r--r-- 2026-02-28 00:31:40
Edit Download
151 B lrw-r--r-- 2026-02-28 00:31:40
Edit Download
826 B lrw-r--r-- 2026-02-28 00:31:40
Edit Download
6.13 KB lrw-r--r-- 2026-02-28 00:31:40
Edit Download
930 B lrw-r--r-- 2026-02-28 00:31:40
Edit Download
1.51 KB lrw-r--r-- 2026-02-28 00:31:40
Edit Download
23.52 KB lrw-r--r-- 2026-02-28 00:31:40
Edit Download
638 B lrw-r--r-- 2026-02-28 00:31:40
Edit Download
65 B lrw-r--r-- 2026-02-28 00:31:40
Edit Download
287 B lrw-r--r-- 2026-02-28 00:31:42
Edit Download
394 B lrw-r--r-- 2026-02-28 00:31:42
Edit Download
1008 B lrw-r--r-- 2026-02-28 00:31:42
Edit Download
491 B lrw-r--r-- 2026-02-28 00:31:48
Edit Download
438 B lrw-r--r-- 2026-02-28 00:31:48
Edit Download
42.07 KB lrw-r--r-- 2026-02-28 00:31:48
Edit Download
1.18 KB lrw-r--r-- 2026-02-28 00:31:58
Edit Download
2.02 KB lrw-r--r-- 2026-02-28 00:31:48
Edit Download
1.24 KB lrw-r--r-- 2026-02-28 00:31:48
Edit Download
518 B lrw-r--r-- 2026-02-28 00:32:00
Edit Download
236 B lrw-r--r-- 2026-02-28 00:31:50
Edit Download
1.53 KB lrw-r--r-- 2026-02-28 00:31:50
Edit Download

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