@app-studio/web 0.9.45 → 0.9.46

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,452 +0,0 @@
1
-
2
- # OKR
3
-
4
- The OKR (Objectives and Key Results) component is used for displaying and tracking organizational objectives and their associated key results. It provides a comprehensive view of progress, status, and ownership for strategic goals.
5
-
6
- ## When to use
7
-
8
- Use the OKR component when you need to:
9
- - Display strategic goals and their progress in a clear, hierarchical manner.
10
- - Track the status and ownership of objectives and key results.
11
- - Provide a centralized view of team or company-wide goals.
12
- - Visualize progress towards specific targets.
13
-
14
- ## Import
15
-
16
- ```jsx
17
- import { OKR } from '@app-studio/web';
18
- ```
19
-
20
- ## Props
21
-
22
- | Prop | Type | Default | Description |
23
- | ---- | ---- | ------- | ----------- |
24
- | objectives | OKRObjective[] | **required** | Array of objectives to display |
25
- | themeMode | 'light' \| 'dark' | 'light' | Theme mode for the component |
26
- | views | OKRViews | undefined | Custom styling for different parts of the component. See the `OKRViews` type definition for all available options. |
27
- | onObjectiveClick | (objective: OKRObjective) => void | undefined | Callback when an objective is clicked |
28
- | onKeyResultClick | (keyResult: OKRKeyResult, objective: OKRObjective) => void | undefined | Callback when a key result is clicked |
29
- | renderObjectiveFooter | (objective: OKRObjective) => ReactNode | undefined | Custom footer renderer for objectives |
30
- | renderKeyResultFooter | (keyResult: OKRKeyResult, objective: OKRObjective) => ReactNode | undefined | Custom footer renderer for key results |
31
-
32
- ## Type Definitions
33
-
34
- ### OKRStatus
35
-
36
- ```tsx
37
- type OKRStatus =
38
- | 'notStarted' // No progress made (0%)
39
- | 'onTrack' // Good progress (70-99%)
40
- | 'atRisk' // Moderate progress (40-69%)
41
- | 'offTrack' // Poor progress (1-39%)
42
- | 'achieved'; // Goal completed (100%)
43
- ```
44
-
45
- ### OKRObjective
46
-
47
- ```tsx
48
- interface OKRObjective {
49
- id: string; // Unique identifier
50
- title: string; // Objective title
51
- description?: string; // Objective description
52
- owner?: string; // Person responsible
53
- timeframe?: string; // Time period (e.g., "Q4 2025")
54
- tags?: string[]; // Category tags
55
- progress?: number; // Overall progress (0-100)
56
- status?: OKRStatus; // Current status
57
- keyResults: OKRKeyResult[]; // Associated key results
58
- }
59
- ```
60
-
61
- ### OKRKeyResult
62
-
63
- ```tsx
64
- interface OKRKeyResult {
65
- id: string; // Unique identifier
66
- title: string; // Key result title
67
- description?: string; // Key result description
68
- progress?: number; // Progress percentage (0-100)
69
- metric?: string; // Measurement metric
70
- target?: string; // Target value
71
- current?: string; // Current value
72
- owner?: string; // Person responsible
73
- status?: OKRStatus; // Current status
74
- confidence?: 'low' | 'medium' | 'high'; // Confidence level
75
- lastUpdated?: string; // Last update timestamp
76
- tags?: string[]; // Category tags
77
- }
78
- ```
79
-
80
- ## Examples
81
-
82
- ### Basic Usage
83
-
84
- This example shows a basic OKR with one objective and three key results with different statuses.
85
-
86
- ![Basic OKR](https://placehold.co/800x400)
87
-
88
- ```jsx
89
- import React from 'react';
90
- import { OKR } from '@app-studio/web';
91
-
92
- export const BasicOKR = () => {
93
- const objectives = [
94
- {
95
- id: '1',
96
- title: 'Launch New Feature',
97
- description: 'Successfully launch the new feature to all users.',
98
- owner: 'John Doe',
99
- timeframe: 'Q4 2025',
100
- tags: ['new-feature', 'launch'],
101
- progress: 50,
102
- status: 'onTrack',
103
- keyResults: [
104
- {
105
- id: '1.1',
106
- title: 'Complete development',
107
- progress: 80,
108
- status: 'onTrack',
109
- },
110
- {
111
- id: '1.2',
112
- title: 'Complete QA testing',
113
- progress: 40,
114
- status: 'atRisk',
115
- },
116
- {
117
- id: '1.3',
118
- title: 'Reach 10,000 active users',
119
- progress: 10,
120
- status: 'offTrack',
121
- },
122
- ],
123
- },
124
- ];
125
-
126
- return <OKR objectives={objectives} />;
127
- };
128
- ```
129
-
130
- ### With Detailed Key Results
131
-
132
- This example shows a more detailed view of key results, including metrics, targets, and confidence levels. It also demonstrates the dark theme.
133
-
134
- ![Detailed OKR](https://placehold.co/800x450)
135
-
136
- ```jsx
137
- import React from 'react';
138
- import { OKR } from '@app-studio/web';
139
-
140
- export const DetailedOKR = () => {
141
- const objectives = [
142
- {
143
- id: '2',
144
- title: 'Improve Customer Satisfaction',
145
- description: 'Increase customer satisfaction scores by 20%',
146
- owner: 'Jane Smith',
147
- timeframe: 'Q1 2026',
148
- tags: ['customer-experience', 'support'],
149
- keyResults: [
150
- {
151
- id: '2.1',
152
- title: 'Reduce support ticket response time',
153
- description: 'Decrease average response time from 4h to 2h',
154
- progress: 65,
155
- metric: 'Average Response Time',
156
- current: '2.5h',
157
- target: '2h',
158
- owner: 'Support Team',
159
- status: 'onTrack',
160
- confidence: 'high',
161
- lastUpdated: '2 days ago',
162
- tags: ['support', 'efficiency'],
163
- },
164
- {
165
- id: '2.2',
166
- title: 'Increase NPS score',
167
- description: 'Improve Net Promoter Score from 40 to 50',
168
- progress: 30,
169
- metric: 'NPS Score',
170
- current: '43',
171
- target: '50',
172
- owner: 'Customer Success',
173
- status: 'atRisk',
174
- confidence: 'medium',
175
- lastUpdated: '1 week ago',
176
- tags: ['nps', 'metrics'],
177
- },
178
- ],
179
- },
180
- ];
181
-
182
- return <OKR objectives={objectives} themeMode="dark" />;
183
- };
184
- ```
185
-
186
- ### With Click Handlers
187
-
188
- You can use the `onObjectiveClick` and `onKeyResultClick` props to handle user interactions, for example to navigate to a detailed view.
189
-
190
- ![Interactive OKR](https://placehold.co/800x250)
191
-
192
- ```jsx
193
- import React from 'react';
194
- import { OKR } from '@app-studio/web';
195
-
196
- export const InteractiveOKR = () => {
197
- const objectives = [
198
- {
199
- id: '3',
200
- title: 'Increase Revenue',
201
- owner: 'Sales Team',
202
- timeframe: 'Q2 2026',
203
- keyResults: [
204
- {
205
- id: '3.1',
206
- title: 'Close 50 new enterprise deals',
207
- progress: 40,
208
- current: '20',
209
- target: '50',
210
- },
211
- ],
212
- },
213
- ];
214
-
215
- const handleObjectiveClick = (objective) => {
216
- console.log('Clicked objective:', objective.title);
217
- };
218
-
219
- const handleKeyResultClick = (keyResult, objective) => {
220
- console.log('Clicked key result:', keyResult.title);
221
- console.log('From objective:', objective.title);
222
- // Navigate to detail view, open modal, etc.
223
- };
224
-
225
- return (
226
- <OKR
227
- objectives={objectives}
228
- onObjectiveClick={handleObjectiveClick}
229
- onKeyResultClick={handleKeyResultClick}
230
- />
231
- );
232
- };
233
- ```
234
-
235
- ### With Custom Footers
236
-
237
- The `renderObjectiveFooter` and `renderKeyResultFooter` props allow you to add custom actions or information to each objective and key result.
238
-
239
- ![OKR with footers](https://placehold.co/800x300)
240
-
241
- ```jsx
242
- import React from 'react';
243
- import { OKR, Button, Horizontal } from '@app-studio/web';
244
-
245
- export const OKRWithFooters = () => {
246
- const objectives = [
247
- {
248
- id: '4',
249
- title: 'Expand Market Presence',
250
- owner: 'Marketing',
251
- timeframe: 'Q3 2026',
252
- keyResults: [
253
- {
254
- id: '4.1',
255
- title: 'Launch in 3 new regions',
256
- progress: 33,
257
- },
258
- ],
259
- },
260
- ];
261
-
262
- return (
263
- <OKR
264
- objectives={objectives}
265
- renderObjectiveFooter={(objective) => (
266
- <Horizontal gap={8}>
267
- <Button size="sm" variant="outline">View Details</Button>
268
- <Button size="sm" variant="ghost">Edit</Button>
269
- </Horizontal>
270
- )}
271
- renderKeyResultFooter={(keyResult, objective) => (
272
- <Horizontal gap={8}>
273
- <Button size="sm" variant="link">Update Progress</Button>
274
- <Button size="sm" variant="link">Add Comment</Button>
275
- </Horizontal>
276
- )}
277
- />
278
- );
279
- };
280
- ```
281
-
282
- ### Auto-calculated Progress
283
-
284
- If an objective's `progress` is not provided, it is automatically calculated as the average progress of its key results.
285
-
286
- ![Auto-progress OKR](https://placehold.co/800x350)
287
-
288
- ```jsx
289
- import React from 'react';
290
- import { OKR } from '@app-studio/web';
291
-
292
- export const AutoProgressOKR = () => {
293
- const objectives = [
294
- {
295
- id: '5',
296
- title: 'Improve Engineering Efficiency',
297
- // No progress specified - will be auto-calculated
298
- keyResults: [
299
- { id: '5.1', title: 'Reduce build time by 50%', progress: 70 },
300
- { id: '5.2', title: 'Increase test coverage to 90%', progress: 60 },
301
- { id: '5.3', title: 'Automate deployment process', progress: 80 },
302
- ],
303
- // Objective progress will be: (70 + 60 + 80) / 3 = 70%
304
- },
305
- ];
306
-
307
- return <OKR objectives={objectives} />;
308
- };
309
- ```
310
-
311
- ## Customization
312
-
313
- The OKR component can be extensively customized using the `views` prop. See the `OKRViews` type definition for all available options.
314
-
315
- ![Custom styled OKR](https://placehold.co/800x250)
316
-
317
- ```jsx
318
- import React from 'react';
319
- import { OKR } from '@app-studio/web';
320
-
321
- export const CustomStyledOKR = () => {
322
- const objectives = [
323
- {
324
- id: '6',
325
- title: 'Custom Styled Objective',
326
- keyResults: [
327
- { id: '6.1', title: 'Key Result 1', progress: 75 },
328
- ],
329
- },
330
- ];
331
-
332
- return (
333
- <OKR
334
- objectives={objectives}
335
- views={{
336
- objectiveCard: {
337
- backgroundColor: 'color.blue.50',
338
- borderColor: 'color.blue.300',
339
- borderRadius: 20,
340
- },
341
- objectiveTitle: {
342
- color: 'color.blue.800',
343
- size: 'xl',
344
- },
345
- keyResultItem: {
346
- backgroundColor: 'color.blue.100',
347
- borderRadius: 16,
348
- },
349
- }}
350
- />
351
- );
352
- };
353
- ```
354
-
355
- ## Live Demo
356
- A live demo of the OKR component with all its features is available [here](https://app-studio-web.vercel.app/components/okr).
357
-
358
- ## Status Derivation
359
-
360
- If a status is not explicitly provided, it will be automatically derived from the progress value:
361
-
362
- | Progress | Derived Status |
363
- | -------- | -------------- |
364
- | 0% | `notStarted` |
365
- | 1-39% | `offTrack` |
366
- | 40-69% | `atRisk` |
367
- | 70-99% | `onTrack` |
368
- | 100% | `achieved` |
369
-
370
- ## Status Indicators
371
-
372
- Each status is displayed with a corresponding visual indicator:
373
-
374
- | Status | Indicator | Label |
375
- | ------ | --------- | ----- |
376
- | `notStarted` | Info (blue) | "Not started" |
377
- | `onTrack` | Success (green) | "On track" |
378
- | `atRisk` | Warning (yellow) | "At risk" |
379
- | `offTrack` | Error (red) | "Off track" |
380
- | `achieved` | Success (green) | "Achieved" |
381
-
382
- ## Theme Support
383
-
384
- The OKR component fully supports both light and dark themes.
385
-
386
- ```jsx
387
- // Light theme (default)
388
- <OKR objectives={objectives} themeMode="light" />
389
-
390
- // Dark theme
391
- <OKR objectives={objectives} themeMode="dark" />
392
-
393
- // Auto-detect from theme context
394
- <OKR objectives={objectives} />
395
- ```
396
-
397
- ## Accessibility
398
-
399
- The OKR component implements the following accessibility features:
400
-
401
- - Proper semantic HTML structure
402
- - Keyboard navigation support for interactive elements
403
- - ARIA attributes for status indicators
404
- - High contrast colors for text and backgrounds in both themes
405
- - Proper focus states for clickable key results
406
- - Screen reader friendly progress indicators
407
-
408
- ## Best Practices
409
-
410
- ### Data Structure
411
-
412
- - Always provide unique `id` values for objectives and key results
413
- - Use descriptive titles that clearly communicate the goal
414
- - Include descriptions for complex objectives or key results
415
- - Specify owners to establish accountability
416
- - Add tags for easy categorization and filtering
417
-
418
- ### Progress Tracking
419
-
420
- - Keep progress values between 0-100 (they will be clamped automatically)
421
- - Update progress regularly to maintain accuracy
422
- - Use the `lastUpdated` field to show recency of data
423
- - Consider using confidence levels to indicate certainty
424
- - Provide both `current` and `target` values for transparency
425
-
426
- ### Status Management
427
-
428
- - Let the component auto-derive status from progress when possible
429
- - Only override status when you have specific business logic
430
- - Use appropriate statuses to drive action and attention
431
- - Review `atRisk` and `offTrack` items regularly
432
-
433
- ### User Experience
434
-
435
- - Use `onKeyResultClick` to provide drill-down functionality
436
- - Implement custom footers for actions like updating progress or adding comments
437
- - Group related objectives using tags
438
- - Keep the number of key results per objective manageable (3-5 is ideal)
439
- - Use consistent timeframes across related objectives
440
-
441
- ### Performance
442
-
443
- - For large datasets, consider pagination or filtering
444
- - Memoize event handlers to prevent unnecessary re-renders
445
- - Use virtualization if displaying many objectives simultaneously
446
-
447
- ## Related Components
448
-
449
- - [ProgressBar](../utility/progress-bar.md) - Used internally for progress visualization
450
- - [StatusIndicator](../feedback/status-indicator.md) - Used internally for status display
451
- - [Card](./card.md) - Similar container component for content display
452
- - [Badge](./badge.md) - Can be used in custom footers for additional metadata