How to use vtex - 10 common examples

To help you get started, we’ve selected a few vtex 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 vtex-apps / store-components / react / components / SKUSelector / components / ErrorMessage.tsx View on Github external
function ErrorMessage() {
  const handles = useCssHandles(CSS_HANDLES)
  const className = `${handles.errorMessage} c-danger`

  return (
    
      {message => (
        <>{' '}{/* this space is necessary */}
          <span>
            {message}
          </span>
        
      )}
    
  )
}
github vtex-apps / store-components / react / components / SearchBar / components / AutocompleteInput.js View on Github external
const AutocompleteInput = ({
  onClearInput,
  compactMode,
  value,
  hasIconLeft,
  iconBlockClass,
  iconClasses,
  autoFocus,
  ...restProps
}) =&gt; {
  const inputRef = useRef(null)
  const handles = useCssHandles(CSS_HANDLES)

  useEffect(() =&gt; {
    const changeClassInput = () =&gt; {
      if (compactMode) {
        inputRef.current.placeholder = ''
        inputRef.current.classList.add(handles.paddingInput)
      }
    }

    changeClassInput()
    autoFocus &amp;&amp; inputRef.current.focus()
    // eslint-disable-next-line react-hooks/exhaustive-deps
  }, [])

  const suffix = (
github vtex-apps / store-components / react / components / InfoCard / index.js View on Github external
subhead,
  callToActionMode,
  callToActionText,
  callToActionUrl,
  textPosition,
  textAlignment,
  imageUrl,
  mobileImageUrl,
  imageActionUrl,
  intl,
  htmlId,
}) => {
  const {
    hints: { mobile },
  } = useRuntime()
  const handles = useCssHandles(CSS_HANDLES)
  const paddingClass =
    textPosition === textPostionValues.LEFT ? 'pr4-ns' : 'pl4-ns'

  // We ignore textAlignment tokens when full image mode
  const alignToken = isFullModeStyle
    ? safelyGetToken(alignTokens, textPosition, 'textPosition')
    : safelyGetToken(alignTokens, textAlignment, 'textAlignment')
  const itemsToken = isFullModeStyle
    ? safelyGetToken(itemsTokens, textPosition, 'textPosition')
    : safelyGetToken(itemsTokens, textAlignment, 'textAlignment')
  const justifyToken = safelyGetToken(
    justifyTokens,
    textPosition,
    'textPosition'
  )
  const flexOrderToken = safelyGetToken(
github vtex-apps / store / react / components / NetworkStatusToast.js View on Github external
function NetworkStatusToast({ intl }) {
  const runtime = useRuntime()
  const [offline, setOffline] = useState(false)
  // Useful to dismissable toast flow.
  const [showingOffline, setShowingOffline] = useState(false)
  const { showToast, hideToast, toastState } = useContext(ToastContext)

  const toastConfig = useMemo(
    () => ({
      message: intl.formatMessage({
        id: 'store/store.network-status.offline',
      }),
      dismissable: pathOr(false, ['hints', 'mobile'], runtime),
      duration: Infinity,
    }),
    [intl, runtime]
  )
github vtex-apps / store-components / react / components / ProductSpecifications / Wrapper.js View on Github external
const ProductSpecificationsWrapper = ({
  hiddenSpecifications,
  visibleSpecifications,
  specifications: propsSpecifications,
  tabsMode, // This is a legacy prop passed by product-details
  showSpecificationsTab = false,
  collapsible = 'always',
}) =&gt; {
  const productContext = useProduct()

  const specifications =
    propsSpecifications || getSpecifications(productContext)

  return (
    
  )
}
github vtex-apps / store / react / components / withDataLayer.js View on Github external
const {
        push,
        subscribe, // eslint-disable-line no-unused-vars
        ...props
      } = this.props

      // Use the push function from the pixel for backward-compatibility
      return (
        
          {context =&gt; }
        
      )
    }
  }

  return hoistNonReactStatics(Pixel(DataLayer), WrappedComponent)
}
github vtex-apps / store-components / react / components / ProductSpecifications / index.js View on Github external
const ProductSpecifications = ({
  tabsMode,
  specifications,
  collapsible = 'always',
  hiddenSpecifications,
  visibleSpecifications,
  shouldCollapseInTabChange,
}) => {
  const [currentTab, setCurrentTab] = useState(0)
  const [collapsed, setCollapsed] = useState(true)
  const handles = useCssHandles(CSS_HANDLES)
  const { isMobile } = useDevice()

  const shouldBeCollapsible = Boolean(
    collapsible === 'always' ||
      (collapsible === 'mobileOnly' && isMobile) ||
      (collapsible === 'desktopOnly' && !isMobile)
  )

  const handleTabChange = tabIndex => {
    setCurrentTab(tabIndex)
    if (shouldCollapseInTabChange) {
      setCollapsed(true)
    }
  }

  const getSpecificationItems = () => {
github vtex-apps / store-components / react / components / ProductDescription / index.js View on Github external
const ProductDescription = ({ description, collapseContent, title, intl }) =&gt; {
  if (!description) {
    return null
  }

  const descriptionParsed = useMemo(() =&gt; HtmlParser(description), [
    description,
  ])

  const handles = useCssHandles(CSS_HANDLES)

  return (
    <div>
      
        {txt =&gt; (
          <h2>
            {title ? formatIOMessage({ id: title, intl }) : txt}
          </h2>
        )}
      

      <div>
        {collapseContent ? (
          </div></div>
github vtex-apps / store-components / react / components / ProductImages / components / Carousel / ThumbnailSwiper.js View on Github external
const ThumbnailSwiper = ({
  isThumbsVertical,
  slides,
  swiperParams,
  thumbUrls,
  position,
  onThumbClick,
  activeIndex,
  thumbnailAspectRatio,
  thumbnailMaxHeight,
}) =&gt; {
  const hasThumbs = slides.length &gt; 1
  const handles = useCssHandles(CSS_HANDLES)

  const thumbClasses = classNames(`${handles.carouselGaleryThumbs} dn h-auto`, {
    'db-ns': hasThumbs,
    mt3: !isThumbsVertical,
    'w-20 bottom-0 top-0 absolute': isThumbsVertical,
    'left-0':
      isThumbsVertical &amp;&amp; position === THUMBS_POSITION_HORIZONTAL.LEFT,
    'right-0':
      isThumbsVertical &amp;&amp; position === THUMBS_POSITION_HORIZONTAL.RIGHT,
  })

  return (
    <div data-testid="thumbnail-swiper">
      
        {slides.map((slide, i) =&gt; {
          const itemContainerClasses = classNames('swiper-slide mb5 pointer',</div>
github vtex-apps / store-components / react / components / ProductBrand / index.js View on Github external
const ProductBrand = ({
  displayMode = DISPLAY_MODE.LOGO,
  fallbackToText = true,
  loadingPlaceholder = DISPLAY_MODE.LOGO,
  /** TODO: decide whether the prop width should be supported
   * It makes sense at surface, but setting both width and height
   * messes with the alignment of the logo, due to how our image
   * server handles resizing. */
  height = 100,
  excludeBrands,
  logoWithLink,
  brandName: brandNameProp,
  brandId: brandIdProp,
}) =&gt; {
  const { brandName, brandId } = useBrandInfoProps(brandNameProp, brandIdProp)
  const handles = useCssHandles(CSS_HANDLES)

  if (!brandName || !brandId) {
    return null
  }

  /** Certain brands (e.g. placeholder brands) can be filtered out via theme config */
  if (shouldExcludeBrand(brandName, brandId, excludeBrands)) {
    return null
  }

  const brandNameElement = (
    <span>{brandName}</span>
  )

  const BrandContainer = ({ children }) =&gt; (
    <div>{children}</div>