How to use @instructure/console - 10 common examples

To help you get started, we’ve selected a few @instructure/console 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-tabs / src / components / Tabs / index.js View on Github external
setSelected (index) {
    let selectedIndex

    // Check index boundary
    error(this.isValidIndex(index), `[Tabs] Invalid tab index: '${index}'.`)

    const handleChange = () => {
      if (typeof selectedIndex !== 'undefined' && typeof this.props.onChange === 'function') {
        this.props.onChange(index, selectedIndex)
      }
    }

    if (typeof this.props.selectedIndex === 'undefined') {
      this.setState((state, props) => {
        selectedIndex = state.selectedIndex

        if (index !== selectedIndex) {
          handleChange()
          return { selectedIndex: index, focus: true }
        } else {
          return state
github instructure / instructure-ui / packages / ui-link / src / Link / index.js View on Github external
get containsTruncateText () {
    let truncateText = false

    React.Children.forEach(this.props.children, (child) => {
      if (child && matchComponentTypes(child, ['TruncateText'])) {
        truncateText = true
      }
    })

    warn( // if display prop is used, warn about icon or TruncateText
      !truncateText || this.props.display === undefined,
      '[Link] Using the display property with TruncateText may cause layout issues.'
    )

    return truncateText
  }
github instructure / instructure-ui / packages / ui-link / src / Link / index.js View on Github external
renderIcon () {
    warn( // if display prop is used, warn about icon or TruncateText
      this.props.display === undefined,
      '[Link] Using the display property with an icon may cause layout issues.'
    )

    return <span>{callRenderProp(this.props.renderIcon)}</span>
  }
github instructure / instructure-ui / packages / ui-forms / src / Select / index.js View on Github external
constructor (props) {
    super(props)
    const options = parseOptions(props.children)

    error(
      !(props.allowCustom && props.multiple),
      `[Select] The 'allowCustom' and 'multiple' props are mutually exclusive.`
    )

    this.state = { options }
  }
github instructure / instructure-ui / packages / ui-alerts / src / Alert / index.js View on Github external
initLiveRegion (liveRegion) {
    error(
      liveRegion.getAttribute('role') === 'alert',
      `[Alert] live region must have role='alert' set on page load in order to announce content`
    )

    if (liveRegion) {
      liveRegion.setAttribute('aria-live', this.props.liveRegionPoliteness)
      liveRegion.setAttribute('aria-relevant', 'additions text')
      liveRegion.setAttribute('aria-atomic', this.props.isLiveRegionAtomic)
    }
  }
github instructure / instructure-ui / packages / ui-a11y / src / FocusRegion.js View on Github external
blur () {
    error(!this._active, `[FocusRegion] Cannot call '.blur()' on a region that is currently active.`)
    this._keyboardFocusRegion.blur()
  }
}
github instructure / instructure-ui / packages / ui-a11y / src / Dialog / index.js View on Github external
focus () {
    if (!this.props.open || !this.contentElement) {
      error(false, '[Dialog] Can\'t focus a Dialog that isn\'t open.')
      return
    }

    if (this._focusRegion) {
      FocusRegionManager.focusRegion(this.contentElement, this._focusRegion.id)
    }
  }
github instructure / instructure-ui / packages / ui-forms / src / DateInput / DatePicker / index.js View on Github external
_validateDateProp (dateStr, fallbackDateStr, propName, locale, timezone) {
    const parsedDate = this._parseDate(dateStr, locale, timezone)
    const isEmpty = !dateStr
    const isValid = parsedDate.isValid()

    error(isEmpty || isValid, `[DatePicker] Unexpected date format received for '${propName}' prop: '${dateStr}'.`)

    return (isEmpty || !isValid) ? fallbackDateStr : dateStr
  }
github instructure / instructure-ui / packages / ui-themeable / src / ThemeRegistry.js View on Github external
function getRegisteredTheme (themeKey, defaultTheme = {}) {
  if (!themeKey) return defaultTheme

  const theme = getRegistry().themes[themeKey]
  if (theme) {
    return theme
  } else {
    if (themeKey !== DEFAULT_THEME_KEY) {
      error(theme, `[themeable] Could not find theme: '${themeKey}' in the registry.`)
    }
    return defaultTheme
  }
}
github instructure / instructure-ui / packages / ui-themeable / src / ThemeRegistry.js View on Github external
function generateTheme (themeKey, overrides) {
  const registry = getRegistry()

  error((registry.registered.length > 0), '[themeable] No themes have been registered. ' +
    'Import a theme from @instructure/ui-themes or register a custom theme with registerTheme ' +
    '(see @instructure/ui-themeable).'
  )

  const components = getRegisteredComponents(themeKey)
  const theme = {}

  const variables = mergeWithDefaultThemeVariables(themeKey, overrides)

  if (isEmpty(variables)) {
    return
  }

  Object.getOwnPropertySymbols(components)
    .forEach((componentKey) => {
      theme[componentKey] = components[componentKey](variables)

@instructure/console

A babel macro made by Instructure Inc.

MIT
Latest version published 2 days ago

Package Health Score

84 / 100
Full package analysis

Similar packages