starling-devex 0.1.2

Starling: a local dev orchestrator with a central daemon, shared named-URL proxy, and a k9s-style TUI (a Rust port of Tilt + portless)
import { Typography, TypographyTypeMap } from "@material-ui/core"
import {
  DefaultComponentProps,
  OverrideProps,
} from "@material-ui/core/OverridableComponent"
import React, { ElementType, PropsWithChildren } from "react"

/**
 * A lightweight wrapper for content that should only be available
 * to assistive technology, using Material UI's Typography component
 * with `srOnly` class. Screen-reader-only classes are a common pattern
 * that allows useful content to be present in the DOM (and therefore
 * available to screen-readers), but not visible to sighted users.
 * https://material-ui.com/api/typography/
 *
 * Using this may cause layout problems, see discussion here:
 * https://github.com/tilt-dev/tilt/pull/5504
 * Prefer aria-label when possible.
 */

// Note: types are copy-pasta'd and adapted from Typography.d.ts
type SrOnlyProps<C extends ElementType> =
  | ({ component: C } & OverrideProps<TypographyTypeMap, C> &
      DefaultComponentProps<TypographyTypeMap>)
  | DefaultComponentProps<TypographyTypeMap>

export default function SrOnly<C extends ElementType = "span">(
  props: PropsWithChildren<SrOnlyProps<C>>
) {
  return (
    <Typography {...props} variant="srOnly">
      {props.children}
    </Typography>
  )
}