Preskoči na vsebino

std-rating

Level: Atom | Entity: Review | Persistence: runtime

2 states, 3 events, 3 transitions

Live Preview

orbital ReviewOrbital {
entity Review [runtime] {
id : string
name : string
description : string
status : string
createdAt : string
rating : number
comment : string
}
trait ReviewRating -> Review [interaction] {
initial: idle
state idle {
INIT -> idle
(fetch Review)
(render-ui main { type: "stack", direction: "vertical", gap: "lg", align: "center", children: [{ type: "stack", direction: "horizontal", gap: "sm", align: "center", children: [{ type: "icon", name: "star", size: "lg" }, { type: "typography", content: "Rating", variant: "h2" }] }, { type: "divider" }, { type: "typography", variant: "body", color: "muted", content: "How would you rate this?" }, { type: "star-rating", value: ["object/get", ["array/first", "@entity"], "rating"], max: 5, event: "RATE", size: "lg" }, { type: "button", label: "Submit Rating", event: "RATE", variant: "primary", icon: "star" }] })
RATE -> rated
(set @entity.rating @payload.rating)
(render-ui main { type: "stack", direction: "vertical", gap: "lg", align: "center", children: [{ type: "stack", direction: "horizontal", gap: "sm", align: "center", children: [{ type: "icon", name: "check-circle", size: "lg" }, { type: "typography", content: "Thank You!", variant: "h2" }] }, { type: "divider" }, { type: "star-rating", value: ["object/get", ["array/first", "@entity"], "rating"], max: 5, readOnly: true, size: "lg" }, { type: "alert", variant: "success", message: "Your rating has been recorded." }, { type: "button", label: "Rate Again", event: "RESET", variant: "ghost", icon: "rotate-ccw" }] })
}
state rated {
RESET -> idle
(set @entity.rating 0)
(render-ui main { type: "stack", direction: "vertical", gap: "lg", align: "center", children: [{ type: "stack", direction: "horizontal", gap: "sm", align: "center", children: [{ type: "icon", name: "star", size: "lg" }, { type: "typography", content: "Rating", variant: "h2" }] }, { type: "divider" }, { type: "typography", variant: "body", color: "muted", content: "How would you rate this?" }, { type: "star-rating", value: ["object/get", ["array/first", "@entity"], "rating"], max: 5, event: "RATE", size: "lg" }, { type: "button", label: "Submit Rating", event: "RATE", variant: "primary", icon: "star" }] })
}
}
page "/reviews/rating" -> ReviewRating
}
Loading preview...

Orbital Visualization

Loading visualization...

Entity Fields

FieldTypeDefault
idstring-
namestring-
descriptionstring-
statusstring"active"
createdAtstring-
ratingnumber0
commentstring""

States

StateType
idleInitial
rated-

Events

EventPayload
INIT-
RATErating: number
RESET-

Transitions

FromEventToEffects
idleINITidle2 effects
idleRATErated2 effects
ratedRESETidle2 effects