badgeColor method

Color badgeColor(
  1. OptimusTokens tokens, {
  2. required bool isEnabled,
  3. required bool isPressed,
  4. required bool isHovered,
})

Implementation

Color badgeColor(
  OptimusTokens tokens, {
  required bool isEnabled,
  required bool isPressed,
  required bool isHovered,
}) {
  switch (this) {
    case OptimusButtonVariant.primary:
    case OptimusButtonVariant.danger:
      if (!isEnabled) return tokens.textDisabled;

      return tokens.textStaticInverse;
    case OptimusButtonVariant.secondary:
      if (!isEnabled) return tokens.backgroundDisabled;
      if (isPressed) return tokens.backgroundStaticFlat;
      if (isHovered) return tokens.backgroundStaticFlat;

      return tokens.textInteractiveDefault;
    case OptimusButtonVariant.tertiary:
      if (!isEnabled) return tokens.backgroundDisabled;

      return tokens.textStaticSecondary;
    case OptimusButtonVariant.ghost:
      if (!isEnabled) return tokens.backgroundDisabled;

      return tokens.textStaticPrimary;
  }
}