How to use the @fluentui/react.createComponent function in @fluentui/react

To help you get started, we’ve selected a few @fluentui/react 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 microsoft / fluent-ui-react / docs / src / components / ColorSchemes.tsx View on Github external
type ColorVariantsProps = {
  name?: string
  themes?: ThemePrepared[]
  headers?: ShorthandCollection
}

export const colorVariantsStyles: ComponentSlotStylesInput = {
  root: {
    border: '1px solid transparent',
    borderRadius: '.25rem',
    overflow: 'hidden',
  },
}

const ColorSchemes = createComponent({
  displayName: 'ColorVariants',
  render: ({ name, themes, headers, stardust: { classes } }) => {
    if (themes.length === 0) return <>

    const colorSchemes = _.map(themes, theme => theme.siteVariables.colorScheme[name])

    const elements = _.flatMap(_.head(colorSchemes), (i, token) => [
      ,
github microsoft / fluent-ui-react / docs / src / components / CategoryColorSchemes.tsx View on Github external
type ColorVariantsProps = {
  name?: string
  themes?: ThemePrepared[]
  headers?: ShorthandCollection
}

export const colorVariantsStyles: ComponentSlotStylesInput = {
  root: {
    border: '1px solid transparent',
    borderRadius: '.25rem',
    overflow: 'hidden',
  },
}

const CategoryColorSchemes = createComponent({
  displayName: 'ColorVariants',
  render: ({ name, themes, headers, stardust: { classes } }) => {
    if (themes.length === 0) return <>

    const colorSchemes = _.map(themes, theme => theme.siteVariables.categoryColorScheme[name])

    const elements = _.flatMap(_.head(colorSchemes), (i, token) => [
      ,
github microsoft / fluent-ui-react / packages / code-sandbox / src / KnobsSnippet.tsx View on Github external
import { CodeSnippet, useKnobValues } from '@fluentui/docs-components'
import { createComponent, Flex } from '@fluentui/react'
import * as _ from 'lodash'
import * as React from 'react'

const knobsSnippetStyles = {
  background: 'whitesmoke',
  color: '#777',
  lineHeight: '1.5',
  padding: `5px 10px`,
}

const KnobsSnippet = createComponent({
  displayName: 'KnobsSnippet',
  render: ({ children, stardust }) => {
    const knobs = useKnobValues()
    const values = _.fromPairs(knobs.map(knob => [knob.name, knob.value]))

    return (
      
        <div>{children}</div>
        
          {({ classes }) =&gt; (
github microsoft / fluent-ui-react / docs / src / components / Fader.tsx View on Github external
overflow: 'hidden',
    ':after': {
      content: '""',
      position: 'absolute',
      zIndex: 1,
      bottom: 0,
      left: 0,
      pointerEvents: 'none',
      backgroundImage: 'linear-gradient(to bottom, rgba(255,255,255, 0), rgba(255,255,255, 1) 90%)',
      width: '100%',
      height: '4em',
    },
  },
}

const Fader = createComponent({
  displayName: 'Fader',
  render: ({ children, url, stardust: { classes } }) =&gt; {
    return (
      
        <div>{children}</div>
        <button href="{''}">
      
    )
  },
})

export default Fader
</button>
github microsoft / fluent-ui-react / docs / src / components / ComponentDoc / ComponentControls / ComponentButton.tsx View on Github external
import { createComponent, Icon, Text, Flex } from '@fluentui/react'
import * as React from 'react'

interface LabelledButtonProps {
  iconName: string
  label: string
  onClick?: (event: React.SyntheticEvent) =&gt; void
}

const ComponentButton = createComponent({
  displayName: 'ComponentButton',
  render: ({ stardust, ...props }) =&gt; {
    const { iconName, label, onClick } = props
    return (
      
        
        
    )
  },
})
export default ComponentButton
github microsoft / fluent-ui-react / docs / src / prototypes / CopyToClipboard / NotificationProvider.tsx View on Github external
}, timeout)
  }, [])

  React.useEffect(() =&gt; {
    return () =&gt; clearTimeout(timeoutId.current)
  }, [])

  return (
    &lt;&gt;
      {!!notification &amp;&amp; }
      {children}
    
  )
}

export const Notification = createComponent({
  displayName: 'Notification',
  render: ({ target, trigger, content, stardust: { classes } }) =&gt; {
    const tooltipProps: TooltipProps = {
      content,
      open: true,
      pointing: false,
      target,
      trigger,
    }

    if (target || trigger) {
      return Tooltip.create({ ...tooltipProps, offset: '0 10' })
    }

    return (