You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/ARCHITECTURE.md
+14-4Lines changed: 14 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -39,13 +39,23 @@ Arrows mean "imports / depends on."
39
39
- Services never import Components or Views
40
40
- No circular dependencies
41
41
42
-
## Page / Component / Hook Rules
42
+
## React
43
43
44
-
**Components are simple** — they receive data via props, render it, and call callbacks to return data to the parent (or use context). No logic at the top of a component.
44
+
### Page / Component / Hook Rules
45
45
46
-
**Pages are smart** — they use central hooks (e.g. `useClusterService`, `useSourceControl`) to fetch, prepare, and transform all data needed for downstream components.
46
+
**Components are simple by default** — they receive data via props, render it, and call callbacks. No logic at the top of a component.
47
47
48
-
**Extract logic into hooks** — if a page or component has any logic (state management, data transformation, side effects), extract it into a co-named hook: `FunctionTable.tsx` → `useFunctionTable.ts`, `FunctionsListPage.tsx` → `useFunctionsListPage.ts`. If there is no logic, no hook is needed.
48
+
**A component may own its own data and state when it encapsulates a self-contained capability that is not specific to any one page** (e.g., forge connection, auth flows, notification subscriptions). The component becomes the single owner of that concern. Pages consume it without orchestrating its internals.
49
+
50
+
**Pages are smart for page-specific data** — they use central hooks (e.g. `useClusterService`, `useSourceControl`) to fetch, prepare, and transform all data needed for downstream components.
51
+
52
+
**Extract logic into hooks** — if a page or component has any logic (state management, data transformation, side effects), extract it into a custom hook. If the hook is reused by multiple components, put it in a separate file: `useFunctionTable.ts`. If the hook is only used by one component, keep it in the same file, do not export it. If there is no logic, no hook is needed.
53
+
54
+
**File ordering** — within a file, put the exported component at the top, then its hook below, then helper functions at the bottom. Readers see the main thing first and can drill down.
55
+
56
+
### Performance
57
+
58
+
-**No preemptive `useCallback` or `useMemo`**: Only use them when a memoized child (`React.memo`) depends on a stable reference, or when profiling shows a measurable performance problem. Plain functions and derived values are simpler and sufficient by default.
Copy file name to clipboardExpand all lines: docs/STYLEGUIDE.md
+2-1Lines changed: 2 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,7 +25,8 @@
25
25
26
26
## CSS
27
27
28
-
-**Relative units only**: Use `rem` and `em` for all sizing (widths, heights, margins, padding, font sizes). Never use `px`.
28
+
-**PatternFly first**: Use PatternFly component props for all layout and spacing. Only fall back to custom CSS when PatternFly does not cover the need.
29
+
-**Relative units only**: When custom CSS is necessary, use `rem` and `em` for all sizing. Never use `px`.
0 commit comments