Skip to content

An open source design system that's fully customizable and agent ready

TypeScript
2.7 KB
Raw Blame
// Generated by @astryxdesign/native. Do not edit.
public enum BadgeVariant: String, CaseIterable, Codable, Sendable {
  case neutral = "neutral"
  case info = "info"
  case success = "success"
  case warning = "warning"
  case error = "error"
  case blue = "blue"
  case cyan = "cyan"
  case green = "green"
  case orange = "orange"
  case pink = "pink"
  case purple = "purple"
  case red = "red"
  case teal = "teal"
  case yellow = "yellow"
}
#if os(iOS)
public struct BadgeProps {
  /// Base props attach to this part on every platform.
  public static let baseTarget: AstryxBaseTarget = .root
  public var base: AstryxBaseProps
  public var variant: BadgeVariant?
  public var label: String
  public init(variant: BadgeVariant? = nil, label: String, base: AstryxBaseProps = AstryxBaseProps()) {
    self.variant = variant
    self.label = label
    self.base = base
  }
}
public struct BadgeNode: Decodable, Equatable, Sendable {
  public struct Props: Decodable, Equatable, Sendable {
    public var variant: BadgeVariant?
    public var label: String
  }
  public let key: String
  public let base: AstryxBaseProps?
  public let props: Props
  /// The callbacks the core listens to, by prop name.
  public let events: [String]?

  public func listens(_ event: String) -> Bool { events?.contains(event) ?? false }

  /// The contract a Badge view takes; its callbacks send actions to the core.
  public func viewProps(send: @escaping @Sendable (AstryxAction) -> Void) -> BadgeProps {
    return BadgeProps(
      variant: props.variant,
      label: props.label,
      base: base ?? AstryxBaseProps()
    )
  }
}
#endif
#if os(macOS)
public struct BadgeProps {
  /// Base props attach to this part on every platform.
  public static let baseTarget: AstryxBaseTarget = .root
  public var base: AstryxBaseProps
  public var variant: BadgeVariant?
  public var label: String
  public init(variant: BadgeVariant? = nil, label: String, base: AstryxBaseProps = AstryxBaseProps()) {
    self.variant = variant
    self.label = label
    self.base = base
  }
}
public struct BadgeNode: Decodable, Equatable, Sendable {
  public struct Props: Decodable, Equatable, Sendable {
    public var variant: BadgeVariant?
    public var label: String
  }
  public let key: String
  public let base: AstryxBaseProps?
  public let props: Props
  /// The callbacks the core listens to, by prop name.
  public let events: [String]?

  public func listens(_ event: String) -> Bool { events?.contains(event) ?? false }

  /// The contract a Badge view takes; its callbacks send actions to the core.
  public func viewProps(send: @escaping @Sendable (AstryxAction) -> Void) -> BadgeProps {
    return BadgeProps(
      variant: props.variant,
      label: props.label,
      base: base ?? AstryxBaseProps()
    )
  }
}
#endif