How to use the @react-md/theme.bem function in @react-md/theme

To help you get started, we’ve selected a few @react-md/theme 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 mlaursen / react-md / packages / documentation / components / Customization / ColorPalette / Color.tsx View on Github external
import React, { FC } from "react";
import { bem } from "@react-md/theme";
import { Text } from "@react-md/typography";

export interface ColorValue {
  name: string;
  value: string;
}

interface ColorProps extends ColorValue {
  primary?: string;
  secondary?: boolean;
}

const block = bem("color-palette");

const Color: FC = ({ name, value, primary, secondary }) => {
  const withoutRMD = name.replace("rmd-", "");
  let hexValue = value;
  if (hexValue.length === 4) {
    // ensure that hex colors are always 6 characters instead of their shortened
    // 3 character versions
    hexValue = `${hexValue}${hexValue.substring(1)}`;
  }

  return (
github mlaursen / react-md / packages / documentation / components / Demos / Card / Container.tsx View on Github external
import React, { FC } from "react";
import { bem } from "@react-md/theme";

import "./Container.scss";

interface Props {
  centered?: boolean;
}

const block = bem("card-container");

const Container: FC = ({ children, centered }) => (
  <div>{children}</div>
);

export default Container;
github mlaursen / react-md / packages / documentation / components / Code / CodeBlock.tsx View on Github external
export interface CodeBlockProps {
  className?: string;
  language?: string;
  children: ReactNode;
  highlight?: boolean;
  lineNumbers?: boolean;
}

type WithRef = WithForwardedRef;
type DefaultProps = Required&lt;
  Pick
&gt;;
type WithDefaultProps = CodeBlockProps &amp; DefaultProps &amp; WithRef;

const block = bem("code");

const CodeBlock: FC = props =&gt; {
  const {
    className,
    language,
    children: propChildren,
    highlight,
    forwardedRef,
    lineNumbers,
  } = props as WithDefaultProps;

  const children = useMemo(() =&gt; {
    if (!highlight || typeof propChildren !== "string") {
      return <code>{propChildren}</code>;
    }
github mlaursen / react-md / packages / documentation / components / DemoSandbox / SandboxNavigation.tsx View on Github external
import { AppBar, AppBarTitle, AppBarAction } from "@react-md/app-bar";
import { MenuSVGIcon } from "@react-md/material-icons";
import { bem } from "@react-md/theme";
import { MobileOnly } from "@react-md/utils";

import AppBarNav from "components/AppBarNav";

interface SandboxNavigationProps {
  name: string;
  from: string;
  fileName: string;
  onRequestFiles: () =&gt; void;
  onRequestClose: () =&gt; void;
}

const block = bem("sandbox-modal");

const SandboxNavigation: FC = ({
  name,
  from,
  fileName,
  onRequestFiles,
  onRequestClose,
}) =&gt; {
  return (
github mlaursen / react-md / packages / form / src / TextArea.tsx View on Github external
type WithRef = WithForwardedRef;
type DefaultProps = Required&lt;
  Pick&lt;
    TextAreaProps,
    | "theme"
    | "resize"
    | "defaultValue"
    | "underlineDirection"
    | "error"
    | "rows"
    | "maxRows"
  &gt;
&gt;;
type WithDefaultProps = TextAreaProps &amp; DefaultProps &amp; WithRef;

const block = bem("rmd-text-field");

const TextArea: FC = providedProps =&gt; {
  const {
    style: propStyle,
    className,
    areaStyle,
    areaClassName,
    forwardedRef,
    resize,
    label,
    theme,
    error,
    inline: propInline,
    onBlur: propOnBlur,
    onFocus: propOnFocus,
    onChange: propOnChange,
github mlaursen / react-md / packages / documentation / components / CodePreviewer / Header.tsx View on Github external
import { MenuSVGIcon, CloseSVGIcon } from "@react-md/material-icons";
import { bem } from "@react-md/theme";

import AppBarNav from "components/AppBarNav";
import AppBarAction from "components/AppBarAction";

export interface HeaderProps {
  inline: boolean;
  isDesktop: boolean;
  toggleSheet: () =&gt; void;
  isSheetVisible: boolean;
  projectName: string;
  onRequestClose: () =&gt; void;
}

const block = bem("code-previewer");

const Header: FC = ({
  inline,
  isDesktop,
  toggleSheet,
  isSheetVisible,
  projectName,
  onRequestClose,
}) =&gt; (
  
    {!isDesktop &amp;&amp; (
github mlaursen / react-md / packages / documentation / components / Demos / Form / ExampleForm.tsx View on Github external
Radio,
} from "@react-md/form";
import {
  PersonSVGIcon,
  PhoneSVGIcon,
  LocationOnSVGIcon,
  EmailSVGIcon,
} from "@react-md/material-icons";
import { bem } from "@react-md/theme";

import Phone from "components/Phone";
import states from "constants/states";

import "./ExampleForm.scss";

const block = bem("example-form");

const themes: TextFieldTheme[] = ["none", "underline", "filled", "outline"];

const ExampleForm: FC = () =&gt; {
  const [currentTheme, handleChange] = useChoice("outline");
  const isUnstyled = currentTheme === "none";

  return (
    
      <fieldset>
        {themes.map(theme =&gt; (
          </fieldset>
github mlaursen / react-md / packages / documentation / components / DemoSandbox / FileNotFound.tsx View on Github external
import React, { FC } from "react";
import { Text, TextContainer } from "@react-md/typography";
import { List, ListItem } from "@react-md/list";
import { IFiles } from "codesandbox-import-utils/lib/api/define";
import { bem } from "@react-md/theme";
import Code from "components/Code/Code";
import { Card, CardHeader, CardTitle, CardContent } from "@react-md/card";

export interface FileNotFoundProps {
  fileName: string;
  sandbox: IFiles | null;
  offset: boolean;
  onFileChange: (fileName: string) =&gt; void;
}

const block = bem("sandbox-modal");
const FileNotFound: FC = ({
  offset,
  fileName,
  onFileChange,
  sandbox,
}) =&gt; {
  return (
    <div offset="">
      
        
        {sandbox &amp;&amp; (
          
            
              Did you mean one of:</div>
github mlaursen / react-md / packages / documentation / components / Demos / Chip / ExpandableChips.tsx View on Github external
import { AddCircleSVGIcon } from "@react-md/material-icons";
import { Menu, MenuItem } from "@react-md/menu";
import { bem } from "@react-md/theme";
import { useToggle } from "@react-md/utils";

import Phone from "components/Phone";

import "./ExpandableChips.scss";

const PERSONAL_EMAIL = "jjeckhart@email.com";
const WORK_EMAIL = "jjeckhart@workemail.com";

const getSrc = (isWork: boolean): string =&gt;
  `https://i.pravatar.cc/40?img=${isWork ? 4 : 3}`;

const block = bem("expandable-chip-example");

const ExpandableChips: FC = () =&gt; {
  const [visible, showMenu, hideMenu] = useToggle(false);
  const [isWork, , , toggleWork] = useToggle(false);
  return (
    
      <div>
        <label>
          To
        </label>
        }
        &gt;</div>
github mlaursen / react-md / packages / documentation / components / Customization / ColorPalette / ColorList.tsx View on Github external
import React, { FC } from "react";
import { bem } from "@react-md/theme";
import Color, { ColorValue } from "./Color";

interface ColorListProps {
  baseColor: string;
  colors: ColorValue[];
}

const block = bem("color-palette");

const ColorList: FC = ({ baseColor, colors }) =&gt; {
  const baseName = `rmd-${baseColor}-500`;
  const baseValue = (colors.find(c =&gt; c.name === baseName) || colors[6]).value;
  return (
    <ol>
      
      {colors.map(({ name, value }) =&gt; (
        </ol>

@react-md/theme

The base package for including a theme for react-md. This is required by most other packages.

MIT
Latest version published 11 months ago

Package Health Score

69 / 100
Full package analysis

Popular @react-md/theme functions