Components
React OKR UI provides a collection of highly compositional components for a wide range of possible OKR UI requirements.
Here's a live example. Adjust values in the Playground area to test how the components work and it's props work.
Okr
The <Okr> component acts as a general countainer wrapper:
<Okr metrics={metrics} grades={grades}>{children}</Okr>
Properties
Okr has the properties:
metrics: i.e., the things you are measuring as resultsgrades: i.e., how scores are interpreted e.g.,passorfail
Example metrics and grades
Here is some example configuration:
// Metricsconst metrics = [{id: "1",name: "product revenue",prefix: "",suffix: "%",space: false, // FixallowNegative: false,decimalScale: 2,},];// Gradesconst grades = [{id: "1",name: "Fail",range: [0.0, 0.75],color: "#ef4444",},{id: "2",name: "Pass",range: [0.75, 2.0],color: "#10b981",},];
Objective
The <Objective> component provides a wrapper for each objective:
<Objective className="card">{children}</Objective>
Properties
The component takes a className and passes it on to the component:
Result
The <Result> component provides a wrapper for each result:
<Result className="card">{children}</Result>
Properties
The component takes a className and passes it on to the component.
Goal
The <Goal> component displays the goal text, either by processing the result object properties or simply taking objective text.
Carve out a niche
Increase churn from 20% to 50%
Properties
The component takes objective properties to calculate the goal or simply text. It also includes an optional label:
Due
Input any parsable date string (or timestamp) to display the date. Customize using options:
Progress
Progress indicator for objectives, calculated from result scores or input as a percentage value.
Properties
Takes either a percentage value, or an array of results.
Results example
Here is how to structure your results in an array:
const results = [id: "1",metricId: "1",direction: "increase",start: 50,end: 10,current: 20,},]
Current
Display the current result value.
Properties
Takes the current value from the result and the metricId to format the number.
Score
Score the result based on start, end (goal), and current value.
Properties
Takes result properties, as well as a label, and className. Can display as a circle which uses the score grade to determine its background color.
Row
A flex row utility component (very optional).
<Row type="flex">{children}</Row>
Properties
Use to layout your row using flex or wrap.