@material-ui/core#darken TypeScript Examples

The following examples show how to use @material-ui/core#darken. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CartSummary.tsx    From storefront with MIT License 6 votes vote down vote up
useStyles = makeStyles(
  ({ palette }) => ({
    table: {
      borderTop: `1px solid ${darken(alpha(palette.divider, 1), 0.68)}`,
    },

    tableRow: {
      '& td:first-of-type': {
        paddingLeft: 0,
      },

      '& td:last-of-type': {
        paddingRight: 0,
      },
    },

    image: {
      height: 'auto',
      width: 64,
    },

    total: {
      fontSize: 16,
    },
  }),
  { name: 'CartSummary' },
)
Example #2
Source File: VotingControl.tsx    From clearflask with Apache License 2.0 6 votes vote down vote up
renderVotingButtons() {
    const upvoted: boolean = this.props.vote === Client.VoteOption.Upvote;
    const downvoted: boolean = this.props.vote === Client.VoteOption.Downvote;

    const upvote = (
      <MyButton
        buttonVariant='post'
        Icon={UpvoteIcon}
        color={this.props.theme.palette.primary.main}
        colorHide={!upvoted}
        onClick={this.props.onUpvote}
      >
        {this.props.onDownvote === undefined ? this.props.voteValue || 0 : undefined}
      </MyButton>
    );

    if (this.props.onDownvote === undefined) {
      return upvote;
    }

    return (
      <>
        {upvote}
        <span className={this.props.classes.voteValueStandalone}>
          {this.props.voteValue || 0}
        </span>
        <MyButton
          buttonVariant='post'
          Icon={DownvoteIcon}
          color={this.props.theme.palette.type === 'dark'
            ? lighten(this.props.theme.palette.error.dark, 0.3)
            : darken(this.props.theme.palette.error.dark, 0.3)}
          colorHide={!downvoted}
          onClick={this.props.onDownvote}
        />
      </>
    );
  }
Example #3
Source File: VotingControl.tsx    From clearflask with Apache License 2.0 6 votes vote down vote up
renderIWantThis() {
    const upvoted: boolean = this.props.vote === Client.VoteOption.Upvote;
    const downvoted: boolean = this.props.vote === Client.VoteOption.Downvote;

    const upvote = (
      <MyButton
        buttonVariant='post'
        color={this.props.theme.palette.primary.main}
        colorHide={!upvoted}
        Icon={upvoted ? PositiveSelectedIcon : PositiveIcon}
        onClick={this.props.onUpvote}
      >
        {this.props.t(this.props.iWantThis?.positiveLabel as any || 'want')}
      </MyButton>
    );

    if (this.props.onDownvote === undefined) {
      return upvote;
    }

    return (
      <>
        {upvote}
        <MyButton
          buttonVariant='post'
          color={this.props.theme.palette.type === 'dark'
            ? lighten(this.props.theme.palette.error.dark, 0.3)
            : darken(this.props.theme.palette.error.dark, 0.3)}
          colorHide={!downvoted}
          Icon={downvoted ? NegativeSelectedIcon : NegativeIcon}
          onClick={this.props.onDownvote}
        >
          {this.props.t(this.props.iWantThis?.negativeLabel as any || 'hate')}
        </MyButton>
      </>
    );
  }
Example #4
Source File: OrderList.tsx    From ra-enterprise-demo with MIT License 6 votes vote down vote up
orderRowStyle =
    (batchLevel, theme) =>
    (record): any => {
        let backgroundColor;
        switch (record.batch) {
            case batchLevel:
                backgroundColor =
                    theme.palette.type === 'light'
                        ? lighten(fade(theme.palette.info.light, 1), 0.68)
                        : darken(fade(theme.palette.info.dark, 1), 0.88);
                break;
            case 1:
                if (batchLevel > 0) {
                    backgroundColor =
                        theme.palette.type === 'light'
                            ? lighten(fade(theme.palette.info.light, 1), 0.78)
                            : darken(fade(theme.palette.info.dark, 1), 0.78);
                }
                break;
            default:
                backgroundColor = theme.palette.background.paper;
        }

        return {
            backgroundColor,
        };
    }
Example #5
Source File: CartTable.tsx    From storefront with MIT License 5 votes vote down vote up
useStyles = makeStyles(
  ({ breakpoints, palette }) => ({
    root: {
      borderTop: `1px solid ${darken(alpha(palette.divider, 1), 0.68)}`,
      display: 'block',

      [breakpoints.up('sm')]: {
        borderTop: 0,
        display: 'table',
      },
    },

    footer: {
      display: 'block',

      [breakpoints.up('sm')]: {
        display: 'table-footer-group',
      },

      '& tr': {
        display: 'flex',

        [breakpoints.up('sm')]: {
          display: 'table-row',
        },
      },

      '& td': {
        '&:nth-of-type(n+2)': {
          flexGrow: 1,
        },

        '&:nth-of-type(3)': {
          textAlign: 'right',

          [breakpoints.up('sm')]: {
            textAlign: 'left',
          },
        },
      },
    },
  }),
  { name: 'CartTable' },
)
Example #6
Source File: RichText.tsx    From storefront with MIT License 5 votes vote down vote up
useStyles = makeStyles(
  ({ palette, spacing, typography }) => ({
    root: {
      '& h2, & h3, & h4, & h5, & p': {
        marginBottom: spacing(2),
        marginTop: 0,
      },

      '& h2': {
        ...typography.h2,
      },

      '& h3': {
        ...typography.h3,
      },

      '& h4': {
        ...typography.h4,
      },

      '& h5': {
        ...typography.h5,
      },

      '& p': {
        ...typography.body1,
      },

      '& a': {
        color: palette.common.white,
        textDecoration: 'none',

        '&:hover': {
          textDecoration: 'underline',
        },
      },

      '& table': {
        borderCollapse: 'collapse',
        marginBottom: spacing(2),

        '& th, & td': {
          ...typography.body2,
          borderBottom: `1px solid ${darken(alpha(palette.divider, 1), 0.68)}`,
          padding: spacing(1),
          textAlign: 'left',
        },
      },

      '& .alignright': {
        float: 'right',
      },
    },
  }),
  { name: 'RichText' },
)
Example #7
Source File: styles.ts    From backstage with Apache License 2.0 5 votes vote down vote up
// The opposite of MUI's emphasize function - darken darks, lighten lights
export function brighten(color: string, coefficient = 0.2) {
  return getLuminance(color) > 0.5
    ? lighten(color, coefficient)
    : darken(color, coefficient);
}
Example #8
Source File: styles.ts    From firetable with Apache License 2.0 4 votes vote down vote up
useStyles = makeStyles((theme) =>
  createStyles({
    tableWrapper: {
      display: "flex",
      flexDirection: "column",
      width: `calc(100% - ${DRAWER_COLLAPSED_WIDTH}px)`,
      height: `calc(100vh - ${APP_BAR_HEIGHT}px)`,

      "& > .rdg": { flex: 1 },

      [theme.breakpoints.down("sm")]: { width: "100%" },
    },

    loadingContainer: {
      position: "sticky",
      left: 0,
      height: 100,
    },

    "@global": {
      ".rdg.rdg": {
        "--color": theme.palette.text.secondary,
        "--border-color": theme.palette.divider,
        // "--summary-border-color": "#aaa",
        "--background-color": theme.palette.background.paper,
        "--header-background-color": theme.palette.background.default,
        "--row-hover-background-color": emphasize(
          theme.palette.background.paper,
          0.04
        ),
        "--row-selected-background-color":
          theme.palette.type === "light"
            ? lighten(theme.palette.primary.main, 0.9)
            : darken(theme.palette.primary.main, 0.8),
        "--row-selected-hover-background-color":
          theme.palette.type === "light"
            ? lighten(theme.palette.primary.main, 0.8)
            : darken(theme.palette.primary.main, 0.7),
        "--checkbox-color": theme.palette.primary.main,
        "--checkbox-focus-color": theme.palette.primary.main,
        "--checkbox-disabled-border-color": "#ccc",
        "--checkbox-disabled-background-color": "#ddd",
        "--selection-color": theme.palette.primary.main,
        "--font-size": "0.75rem",
        "--cell-padding": theme.spacing(0, 1.5),

        border: "none",
        backgroundColor: "transparent",

        ...theme.typography.body2,
        fontSize: "0.75rem",
        lineHeight: "inherit !important",

        "& .rdg-cell": {
          display: "flex",
          alignItems: "center",
          padding: "var(--cell-padding)",

          overflow: "visible",
          contain: "none",
        },

        "& .rdg-cell-frozen-last": {
          boxShadow:
            theme.palette.type === "light"
              ? "2px 0 4px 0px rgba(0, 0, 0, .08)"
              : "2px 0 4px 0px rgba(0, 0, 0, .67)",
        },

        "& .rdg-cell-copied": {
          backgroundColor:
            theme.palette.type === "light"
              ? lighten(theme.palette.primary.main, 0.7)
              : darken(theme.palette.primary.main, 0.6),
        },
      },

      ".rdg-header-row .rdg-cell": {
        borderTop: "1px solid var(--border-color)",
      },

      ".rdg-row:hover": { color: theme.palette.text.primary },

      ".row-hover-iconButton": {
        color: theme.palette.text.disabled,
        transitionDuration: "0s",

        ".rdg-row:hover &": {
          color: theme.palette.text.primary,
          backgroundColor: fade(
            theme.palette.text.primary,
            theme.palette.action.hoverOpacity * 2
          ),
        },
      },

      ".cell-collapse-padding": {
        margin: theme.spacing(0, -1.5),
        width: `calc(100% + ${theme.spacing(3)}px)`,
      },
    },
  })
)