How to use the @instructure/ui-utils.isEmpty function in @instructure/ui-utils

To help you get started, we’ve selected a few @instructure/ui-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github instructure / instructure-ui / packages / ui-themeable / src / ThemeRegistry.js View on Github external
function mergeWithDefaultThemeVariables (themeKey, overrides) {
  let variables

  if (themeKey) {
    variables = getVariablesWithOverrides(themeKey, overrides)
  } else { // fall back to defaults, but still apply overrides
    const defaultOverrides = getRegistry().overrides
    const defaultOverridesIsEmpty = isEmpty(defaultOverrides)
    if (!defaultOverridesIsEmpty && !isEmpty(overrides)) {
      variables = mergeDeep(defaultOverrides, overrides)
    } else if (defaultOverridesIsEmpty) {
      variables = overrides
    } else {
      variables = defaultOverrides
    }
  }

  return getVariablesWithOverrides(getDefaultThemeKey(), variables)
}
github instructure / instructure-ui / packages / ui-themeable / src / ThemeRegistry.js View on Github external
return function (variables) {
    let theme = {}

    if (typeof componentThemeFunction === 'function') {
      theme = componentThemeFunction(variables)
    }

    // so that the components for the themeKey can
    // just specify overrides we merge them with defaults here
    let defaultComponentTheme = {}

    if (typeof componentThemeFunction[themeKey] === 'function') {
      defaultComponentTheme = componentThemeFunction[themeKey](variables)
    }

    if (!isEmpty(defaultComponentTheme) && !isEmpty(theme)) {
      theme = {...theme, ...defaultComponentTheme}
    } else if (isEmpty(theme)) {
      theme = defaultComponentTheme
    }

    return theme
  }
}
github instructure / instructure-ui / packages / ui-themeable / src / ThemeRegistry.js View on Github external
function mergeWithDefaultThemeVariables (themeKey, overrides) {
  let variables

  if (themeKey) {
    variables = getVariablesWithOverrides(themeKey, overrides)
  } else { // fall back to defaults, but still apply overrides
    const defaultOverrides = getRegistry().overrides
    const defaultOverridesIsEmpty = isEmpty(defaultOverrides)
    if (!defaultOverridesIsEmpty && !isEmpty(overrides)) {
      variables = mergeDeep(defaultOverrides, overrides)
    } else if (defaultOverridesIsEmpty) {
      variables = overrides
    } else {
      variables = defaultOverrides
    }
  }

  return getVariablesWithOverrides(getDefaultThemeKey(), variables)
}
github instructure / instructure-ui / packages / ui-themeable / src / ThemeRegistry.js View on Github external
if (typeof componentThemeFunction === 'function') {
      theme = componentThemeFunction(variables)
    }

    // so that the components for the themeKey can
    // just specify overrides we merge them with defaults here
    let defaultComponentTheme = {}

    if (typeof componentThemeFunction[themeKey] === 'function') {
      defaultComponentTheme = componentThemeFunction[themeKey](variables)
    }

    if (!isEmpty(defaultComponentTheme) && !isEmpty(theme)) {
      theme = {...theme, ...defaultComponentTheme}
    } else if (isEmpty(theme)) {
      theme = defaultComponentTheme
    }

    return theme
  }
}
github instructure / instructure-ui / packages / ui-themeable / src / getShorthandPropValue.js View on Github external
function getShorthandPropValue (componentName, componentTheme, propValue, propName) {
  if (typeof propValue !== 'string' || isEmpty(componentTheme)) {
    return
  }

  return propValue
    .split(' ')
    .map((shortHandValue) => {
      if (shortHandValue === 'auto' || shortHandValue === '0') {
        return shortHandValue
      }

      if (shortHandValue === 'none') {
        return '0'
      }

      if (shortHandValue === 'circle') {
        return '100%'
github instructure / instructure-ui / packages / ui-themeable / src / applyVariablesToNode.js View on Github external
function applyVariablesToNodeStyle (domNode, variables, defaults, prefix) {
  if (!domNode || isEmpty(variables)) {
    return
  }

  clearCustomProperties(domNode, prefix)

  const overrides = pickOverrides(defaults, variables)

  if (overrides && !isEmpty(overrides)) {
    setCustomProperties(domNode, formatVariableNames(overrides, prefix))
  }
}
github instructure / instructure-ui / packages / ui-themeable / src / ThemeRegistry.js View on Github external
function getVariablesWithOverrides (themeKey, overrides) {
  const theme = getRegisteredTheme(themeKey)
  const variables = theme.variables || {}
  const overridesIsEmpty = isEmpty(overrides)

  if (!overridesIsEmpty && theme.immutable) {
    warn(
      false,
      `[themeable] Theme, '${theme.key}', is immutable. Cannot apply overrides: ${JSON.stringify(overrides)}`
    )
    return variables
  }

  const variablesIsEmpty = isEmpty(variables)
  if (!variablesIsEmpty && !overridesIsEmpty) return mergeDeep(variables, overrides)
  if (variablesIsEmpty) return overrides || {}
  return variables
}
github instructure / instructure-ui / packages / ui-themeable / src / ThemeRegistry.js View on Github external
function getVariablesWithOverrides (themeKey, overrides) {
  const theme = getRegisteredTheme(themeKey)
  const variables = theme.variables || {}
  const overridesIsEmpty = isEmpty(overrides)

  if (!overridesIsEmpty && theme.immutable) {
    warn(
      false,
      `[themeable] Theme, '${theme.key}', is immutable. Cannot apply overrides: ${JSON.stringify(overrides)}`
    )
    return variables
  }

  const variablesIsEmpty = isEmpty(variables)
  if (!variablesIsEmpty && !overridesIsEmpty) return mergeDeep(variables, overrides)
  if (variablesIsEmpty) return overrides || {}
  return variables
}
github instructure / instructure-ui / packages / ui-themeable / src / applyVariablesToNode.js View on Github external
function applyVariablesToNodeStyle (domNode, variables, defaults, prefix) {
  if (!domNode || isEmpty(variables)) {
    return
  }

  clearCustomProperties(domNode, prefix)

  const overrides = pickOverrides(defaults, variables)

  if (overrides && !isEmpty(overrides)) {
    setCustomProperties(domNode, formatVariableNames(overrides, prefix))
  }
}