@machinemetrics/mm-react-components 1.4.2 → 1.5.0

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.
@@ -0,0 +1,33 @@
1
+ # Frontend component structure (universal)
2
+
3
+ Summary of base vs. customization layer and composition patterns. Adapt to your project (e.g. shadcn/ui, Radix, or an internal design system).
4
+
5
+ ## Rules
6
+
7
+ | Layer | Rule |
8
+ |-------|------|
9
+ | **Base** (vendor / CLI-installed / design system) | Do not modify. Updated by CLI or upstream; customizations here are lost. |
10
+ | **App / customization** (e.g. `ui/`, `components/app/`) | Customize here only. Re-export from base; override via composition. |
11
+
12
+ ## Composition
13
+
14
+ Compose base components in the customization layer and preserve their documented public,
15
+ theming, and accessibility contracts. Use the installed package's current guidance for
16
+ implementation mechanics. Re-export unchanged behavior rather than forking it.
17
+
18
+ ## Theming
19
+
20
+ - Use semantic CSS variables for colors and spacing; support light/dark via variables.
21
+ - Add design-system attributes (e.g. `data-slot`, `data-variant`) when the theme stylesheet targets them.
22
+ - Single compiled CSS entry for the library or app so consumers get one import.
23
+
24
+ ## Adding and updating
25
+
26
+ - **New behavior:** Use Carbide components as the base when applicable. Compose or
27
+ customize, and add a primitive only after recording a legitimate gap.
28
+ - **Update base:** Use the project's documented update workflow and verify customizations
29
+ against the installed public contract.
30
+ - **Troubleshooting:** Check public exports and version-matched package docs before changing
31
+ a wrapper.
32
+
33
+ When in doubt: customize in the app layer, not the base.
@@ -0,0 +1,39 @@
1
+ # Carbide component reference
2
+
3
+ ## Stable conventions
4
+
5
+ - **Appearance:** Use semantic tokens and current component appearance props. Never copy
6
+ raw palette colors or assume variants are shared across components.
7
+ - **Layout:** Use `flex` and `grid` for spacing; avoid ad-hoc margins between siblings. Tailwind
8
+ is an optional peer dependency: use its `gap-*` utilities only when Tailwind is installed in
9
+ the consuming app, otherwise use plain CSS `gap` on the flex/grid container.
10
+ - **Setup:** Import library styles (e.g. `import '@machinemetrics/mm-react-components/styles'`) and wrap the app (or Carbide root) in `<div className="carbide">` so the theme and fonts apply. For dark mode, apply the compound class instead: `<div className="carbide dark">`.
11
+
12
+ ## Component discovery
13
+
14
+ **When the package is installed in this project:** Check **agent-docs** at `node_modules/@machinemetrics/mm-react-components/agent-docs/`; use **agent-documentation-reference.md** as the index for existing components and patterns.
15
+
16
+ **When the package is not installed in this workspace:** agent-docs is not present. Use this reference and [widget-rules.md](widget-rules.md); recommend installing the package in the project (`npx -p @machinemetrics/mm-react-components mm-init`) for the full doc set.
17
+
18
+ ## Select by behavior
19
+
20
+ Inventory structure, navigation, forms, data display, feedback, and overlays. Search the
21
+ current docs by the required behavior, verify the export, and preserve its documented
22
+ compound children. Do not rely on a static export catalog in this fallback.
23
+
24
+ ## Layout decisions
25
+
26
+ Distinguish structural layout, navigation, temporary overlays, discrete content, and
27
+ bounded overflow. Search current docs for the primitive whose behavior matches the need.
28
+ Do not assume a content container provides page structure or scrolling.
29
+
30
+ ## Widget rules summary
31
+
32
+ - **When to use**: Charts/graphs for trends, comparisons, distributions (with insight annotations). Icons/indicators for status, categories, severity. Metrics/numbers for single KPIs with context (vs target, trend). Text only for labels, brief context, annotations.
33
+ - **Insight-driven**: Add comparisons (vs average, vs goal), highlight what matters (color, sizing), show direction/trend (arrows, sparklines), explain significance.
34
+ - **Avoid**: Text-only widgets, generic charts without context, equal visual weight for all data, missing comparison or context.
35
+ - **Chart complexity**: Follow current guidance and reduce density when the insight becomes
36
+ difficult to read.
37
+ - **Accessibility**: WCAG contrast (4.5:1 text, 3:1 graphics); never rely on color alone: use patterns, shapes, or labels; direct labels on data when possible.
38
+
39
+ For full widget and visualization rules, see [widget-rules.md](widget-rules.md).
@@ -1,44 +1,3 @@
1
- **Insight-Driven Visualizations (NOT generic data dumps)**:
2
-
3
- - **Add context**: Show comparisons, benchmarks, goals, or historical context
4
- - **Highlight what matters**: Use color, annotations, or visual emphasis to draw attention to key findings
5
- - **Show the "so what"**: Don't just display numbers - show WHY they matter (trends up/down, exceeding goals, anomalies)
6
- - **Tell a story**: The visualization should answer a question or reveal an insight, not just display data
7
- - **Actionable insights**: Help users understand what to do with the information
8
-
9
- **Examples of insight-driven approaches**:
10
-
11
- - ❌ BAD: Simple bar chart showing 5 categories and their values
12
- - ✅ GOOD: Bar chart with the #1 issue prominently highlighted, showing % vs. average, and including trend indicators or impact metrics
13
- - ❌ BAD: Line graph showing sales over time
14
- - ✅ GOOD: Line graph with annotations marking significant events, goal lines, forecasts, or anomalies highlighted
15
- - ❌ BAD: Pie chart of categories
16
- - ✅ GOOD: Focused metric card showing the dominant category with a small visual indicator of its proportion and comparative context
17
-
18
- **When to use different methods**:
19
-
20
- - **Charts/Graphs**: Trends, comparisons, distributions, relationships (ALWAYS with insight annotations, highlighting, or contextual markers)
21
- - **Icons/Indicators**: Status, categories, quick recognition, severity levels
22
- - **Metrics/Numbers**: Single key values, KPIs with context (vs. target, vs. last period, trend indicator)
23
- - **Combination layouts**: Mix large metrics with supporting mini-charts for context
24
- - **Text**: Labels, brief context, annotations only when necessary
25
-
26
- **Required elements for insight**:
27
-
28
- - Comparison points (vs. average, vs. goal, vs. previous period)
29
- - Visual highlighting of what's important (color coding, sizing, positioning)
30
- - Indicators of direction/trend (arrows, sparklines, change percentages)
31
- - Context that explains significance (why this matters, what's normal)
32
-
33
- **Avoid**:
34
-
35
- - Large blocks of text, lengthy descriptions, text-only widgets
36
- - Generic bar/line charts that just show data without insight or context
37
- - Equal visual weight for all data points (everything looks equally important)
38
- - Visualizations that require the user to interpret meaning themselves
39
- - Missing comparison or context that would make the data actionable
40
- - If you find yourself creating a chart that could be from Excel's default templates, you're doing it wrong.
41
-
42
1
  # UI Widget Generator Instructions
43
2
 
44
3
  ## CRITICAL RULES - READ FIRST
@@ -79,12 +38,16 @@
79
38
 
80
39
  **CRITICAL: You MUST use only the pre-defined themed components provided in the application.**
81
40
 
82
- - **DO NOT** create new components
83
- - **DO NOT** use custom components
84
- - **DO NOT** write components from scratch
85
- - **ONLY** use the existing themed components available in the component library
41
+ - **DO NOT** build a lookalike component from scratch when the library already provides one
42
+ - **DO NOT** use raw HTML controls or a competing component library
43
+ - **ONLY** use the existing themed components available in the component library, or — for a
44
+ legitimate gap where no library component fits a wrapper/re-export built through the
45
+ customization layer, composing existing components and preserving their contracts
86
46
 
87
- When building widgets, you must work exclusively with the components that have been provided to you. All UI elements must be constructed using these pre-existing themed components.
47
+ When building widgets, you must work exclusively with the components that have been provided to
48
+ you, extended only through the sanctioned customization layer for legitimate gaps. All UI
49
+ elements must be constructed using these pre-existing themed components (or their sanctioned
50
+ customization-layer wrappers).
88
51
 
89
52
  ### Widget Dimensions
90
53
 
@@ -260,19 +223,22 @@ Widgets are VISUAL tools. If a user needs to read paragraphs to understand the d
260
223
  1. **DO NOT** make up data to complete the widget
261
224
  2. **DO NOT** use assumptions or estimates
262
225
  3. **DO** clearly indicate what data is available and what is missing
263
- 4. **DO** ask for the specific data needed before proceeding
226
+ 4. **DO** ask for the specific data needed before building ONLY when the widget cannot be
227
+ accurate without it (no accurate, valuable subset of the request can be built from the
228
+ data provided); otherwise build from what is available instead of asking (see
229
+ Intelligent Adaptation below)
264
230
 
265
231
  **Remember**: An incomplete but accurate widget is infinitely better than a complete but inaccurate one. Data integrity is non-negotiable.
266
232
 
267
233
  ### Intelligent Adaptation
268
234
 
269
- **MANDATORY: Work with available data to create the best possible widget. DO NOT ask follow-up questions about missing data.**
235
+ **MANDATORY: Work with available data to create the best possible widget. Do not ask follow-up questions about missing data when any accurate widget can be built from what was provided; asking is reserved for the single case above, where the missing data is required for correctness.**
270
236
 
271
237
  While you must never hallucinate or assume data, you MUST intelligently adapt to work with the data that IS available:
272
238
 
273
239
  - **Assess what's available**: Evaluate the data provided and determine what insights can be accurately derived
274
240
  - **Adapt immediately**: If ideal data is unavailable, IMMEDIATELY pivot to showcase the next best data that is relevant and valuable
275
- - **DO NOT ask for more data**: Do not get stuck requesting additional data - work with what you have
241
+ - **DO NOT get stuck requesting more data**: When an accurate widget is possible, work with what you have
276
242
  - **Prioritize value**: Focus on what CAN be displayed that provides genuine insight, rather than what's missing
277
243
  - **Be flexible with visualization types**: If the preferred chart type requires unavailable data, choose an alternative visualization that works with available data
278
244
 
@@ -283,7 +249,7 @@ While you must never hallucinate or assume data, you MUST intelligently adapt to
283
249
  - If comparative data is missing, focus on absolute values or trends that exist
284
250
  - If Category A data is unavailable, pivot to Category B data that IS available and relevant
285
251
 
286
- **The goal**: Generate the most valuable, accurate widget possible given the data constraints, without ever compromising on accuracy or fabricating information. Always deliver a widget - never get stuck in data collection mode.
252
+ **The goal**: Generate the most valuable, accurate widget possible given the data constraints, without ever compromising on accuracy or fabricating information. Deliver a widget whenever an accurate one is possible; never get stuck in data collection mode.
287
253
 
288
254
  ## Widget Creation Process
289
255