@powerhousedao/academy 2.5.0-dev.21 → 2.5.0-dev.23

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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,18 @@
1
+ ## 2.5.0-dev.23 (2025-06-13)
2
+
3
+ This was a version bump only for @powerhousedao/academy to align it with other projects, there were no code changes.
4
+
5
+ ## 2.5.0-dev.22 (2025-06-13)
6
+
7
+ ### 🩹 Fixes
8
+
9
+ - **ci:** set proper tags for docker images ([3cab91969](https://github.com/powerhouse-inc/powerhouse/commit/3cab91969))
10
+ - **ci:** connect deployment ([8ac8e423b](https://github.com/powerhouse-inc/powerhouse/commit/8ac8e423b))
11
+
12
+ ### ❤️ Thank You
13
+
14
+ - Frank
15
+
1
16
  ## 2.5.0-dev.21 (2025-06-12)
2
17
 
3
18
  This was a version bump only for @powerhousedao/academy to align it with other projects, there were no code changes.
@@ -1 +1,124 @@
1
- # Integrate your Scalar into a React Component
1
+ # Step 2: Integrate Your Scalar into a React Component
2
+
3
+ This guide explains how to use a custom scalar (created as described in the previous step) within a React component. You'll learn how to leverage the scalar's validation schema for form input, display errors, and ensure a seamless user experience.
4
+
5
+ ## Table of Contents
6
+
7
+ - [Overview](#overview)
8
+ - [Step 1: Import the Scalar and Dependencies](#step-1-import-the-scalar-and-dependencies)
9
+ - [Step 2: Define Component Props](#step-2-define-component-props)
10
+ - [Step 3: Implement the Component](#step-3-implement-the-component)
11
+ - [Step 4: Render the Input and Error](#step-4-render-the-input-and-error)
12
+ - [Step 5: Example Usage](#step-5-example-usage)
13
+ - [Best Practices](#best-practices)
14
+ - [Tips](#tips)
15
+
16
+ ## Overview
17
+
18
+ Custom scalars provide type-safe validation and parsing for your data. Integrating them into React components ensures that user input is validated consistently with your backend and schema definitions. This is especially useful for form fields like email, phone number, Ethereum address, etc.
19
+
20
+ ## Step 1: Import the Scalar and Dependencies
21
+
22
+ Import your scalar and React hooks. You may use any input component to capture user input. In the following example, `FormInput` is used for demonstration purposes, but you can use a standard `<input>`, a custom component, or any UI library input.
23
+
24
+ ```typescript
25
+ import { useState } from "react";
26
+ import { EthereumAddress as EthereumAddressScalar } from "@powerhousedao/document-engineering/graphql";
27
+ // FormInput is just an example. You can use any input component you prefer.
28
+ import { FormInput } from "@powerhousedao/design-system";
29
+ ```
30
+
31
+ Replace `EthereumAddress` with your scalar's name as needed.
32
+
33
+ ## Step 2: Define Component Props
34
+
35
+ Define the props for your component. Typically, you'll want an `onChange` callback to notify the parent of the value and its validity:
36
+
37
+ ```typescript
38
+ export interface EthereumAddressProps {
39
+ onChange?: (address: string, isValidAddress: boolean) => void;
40
+ }
41
+ ```
42
+
43
+ Adapt the prop names and types to your scalar (e.g., `PhoneNumberProps`, `onChange(phone: string, isValid: boolean)`).
44
+
45
+ ## Step 3: Implement the Component
46
+
47
+ Use React state to track the input value. Use the scalar's Zod schema for validation. Call `onChange` with the value and validity whenever the input changes.
48
+
49
+ > **Note:** The input component in this example is `FormInput`, but you can use any input or UI component to capture user input. The key is to validate the value using the scalar's schema.
50
+
51
+ ```typescript
52
+ export const EthereumAddress: React.FC<EthereumAddressProps> = ({ onChange }) => {
53
+ const [address, setAddress] = useState("");
54
+
55
+ // Validate using the scalar's Zod schema
56
+ const result = EthereumAddressScalar.schema.safeParse(address);
57
+ const errors = result.error?.errors.map((error) => error.message).join(", ");
58
+
59
+ // Notify parent of value and validity
60
+ if (onChange) {
61
+ onChange(address, result.success);
62
+ }
63
+
64
+ return (
65
+ <div>
66
+ {/* Replace FormInput with any input component you prefer */}
67
+ <FormInput
68
+ id="eth-address-input"
69
+ value={address}
70
+ onChange={(e) => setAddress(e.target.value)}
71
+ placeholder="0x...."
72
+ aria-label="Ethereum address input"
73
+ />
74
+ <label htmlFor="eth-address-input">
75
+ {address !== "" && errors}
76
+ </label>
77
+ </div>
78
+ );
79
+ };
80
+ ```
81
+
82
+ **Key Points:**
83
+ - Use the scalar's `.schema.safeParse(value)` for validation.
84
+ - Display error messages if validation fails.
85
+ - Call `onChange` with both the value and its validity.
86
+ - Use accessible labels and attributes.
87
+ - The input component is flexible—use what fits your UI best.
88
+
89
+ ## Step 4: Render the Input and Error
90
+
91
+ - Use any form input component (e.g., `FormInput`, `<input>`, or a custom UI input) for the field.
92
+ - Show error messages below the input when validation fails.
93
+ - Add accessibility attributes (`aria-label`, `htmlFor`).
94
+
95
+ ## Step 5: Example Usage
96
+
97
+ Here's how you might use your component in a parent form:
98
+
99
+ ```typescript
100
+ <EthereumAddress
101
+ onChange={(address, isValid) => {
102
+ // Handle the address and its validity
103
+ console.log("Address:", address, "Valid:", isValid);
104
+ }}
105
+ />
106
+ ```
107
+
108
+ Replace `EthereumAddress` with your scalar component as needed.
109
+
110
+ ## Best Practices
111
+
112
+ - **Validation:** Always use the scalar's schema for validation to ensure consistency with your backend.
113
+ - **Accessibility:** Use proper labels, `aria-*` attributes, and keyboard navigation.
114
+ - **Error Handling:** Display clear, user-friendly error messages.
115
+ - **DRY Principle:** Reuse the scalar's schema and avoid duplicating validation logic.
116
+ - **Type Safety:** Use TypeScript types for props and state.
117
+
118
+ ## Tips
119
+
120
+ - Keep your UI clean and intuitive.
121
+ - Sync your component with any updates to the scalar's schema.
122
+ - Test edge cases (empty input, invalid formats, etc.).
123
+ - Use meaningful placeholder text and labels.
124
+ - Consider supporting additional props (e.g., `disabled`, `required`) for flexibility.
@@ -0,0 +1,9 @@
1
+ # AI Resources
2
+
3
+ We have a couple of AI resources to help you with your daily work or exploring our ecosystem.
4
+
5
+ | Tool | Description |
6
+ |---|---|
7
+ | [**Deepwiki**](https://deepwiki.com/powerhouse-inc/powerhouse) | A searchable/queriable wiki to understand our growing mono repo better. <br /> DeepWiki provides up-to-date documentation you can talk to, for every repo in the world. Think Deep Research for GitHub. |
8
+ | [**Context7**](https://context7.com/powerhouse-inc/powerhouse) | The Powerhouse Academy is also available as context through the context7 MCP Server. <br /> LLMs rely on outdated or generic information about the libraries you use. <br /> Context7 pulls up-to-date, version-specific documentation and code examples directly from the source. <br /> Paste accurate, relevant documentation directly into tools like Cursor, Claude, or any LLM. |
9
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerhousedao/academy",
3
- "version": "2.5.0-dev.21",
3
+ "version": "2.5.0-dev.23",
4
4
  "homepage": "https://powerhouse.academy",
5
5
  "repository": {
6
6
  "type": "git",
package/sidebars.ts CHANGED
@@ -121,10 +121,8 @@ const sidebars = {
121
121
  `,
122
122
  },
123
123
  'academy/ComponentLibrary/CreateCustomScalars',
124
- 'academy/ComponentLibrary/ScalarComponent',
125
- 'academy/ComponentLibrary/ComplexComponent',
126
- 'academy/ComponentLibrary/LayoutComponent',
127
- 'academy/ComponentLibrary/FragmentsComponent',
124
+ 'academy/ComponentLibrary/IntegrateIntoAReactComponent',
125
+ 'academy/ComponentLibrary/ScalarVsUIComponents',
128
126
  ],
129
127
  },
130
128
 
@@ -136,6 +134,7 @@ const sidebars = {
136
134
  },
137
135
  { type: 'doc', id: 'academy/Cookbook', label: 'Cookbook' },
138
136
  { type: 'doc', id: 'academy/Glossary', label: 'Glossary' },
137
+ { type: 'doc', id: 'academy/AIResources', label: 'AI Resources' },
139
138
  // ...add more as needed
140
139
  ],
141
140
  };
@@ -1,38 +0,0 @@
1
- import { Tabs, TabItem } from '@theme/Tabs';
2
-
3
- # Complex Component Example
4
-
5
- ## Sidebar
6
-
7
- ### **Scalar Definition**
8
-
9
- - **Name:** `Sidebar`
10
- - **Purpose:** The Sidebar component can be used within a page layout to provide a sidebar navigation. It provided a tree structure of nodes that can be used to navigate the application offering customization, search and more.
11
-
12
-
13
- <details>
14
- <summary>**Formatting of the component:**</summary>
15
-
16
- </details>
17
-
18
- <details>
19
- <summary>**Validation of the Component:**</summary>
20
-
21
- </details>
22
-
23
- <div style={{
24
- border: '1px solid #E5E7EB',
25
- borderRadius: '8px',
26
- padding: '16px',
27
- marginBottom: '20px',
28
- }}>
29
- <iframe
30
- src="https://dspot-scalars-storybook.vercel.app/iframe.html?args=&id=document-engineering-complex-components-sidebar--readme&viewMode=story"
31
- style={{
32
- width: '100%',
33
- height: '2000px',
34
- border: 'none',
35
- }}
36
- title="Sidebar Component Demo"
37
- />
38
- </div>
@@ -1,5 +0,0 @@
1
- import { Tabs, TabItem } from '@theme/Tabs';
2
-
3
- # Layout Component Example
4
-
5
- ## PHID Field Example
@@ -1,5 +0,0 @@
1
- import { Tabs, TabItem } from '@theme/Tabs';
2
-
3
- # Fragment Component Example
4
-
5
- ## PHID Field Example
@@ -1,23 +0,0 @@
1
- # AI Resources
2
-
3
- We have a couple of AI resources to help you with your daily work.
4
-
5
- ## Deepwiki
6
- A searchable/queriable wiki to understand our growing mono repo better.
7
- https://deepwiki.com/powerhouse-inc/powerhouse
8
-
9
- :::info
10
- What is DeepWiki?
11
- DeepWiki provides up-to-date documentation you can talk to, for every repo in the world. Think Deep Research for GitHub.
12
- :::
13
-
14
- ## Context7
15
- The Powerhouse Academy is also available as context through the context7 MCP Server.
16
- https://context7.com/powerhouse-inc/powerhouse
17
-
18
- :::info
19
- What is Context7?
20
- LLMs rely on outdated or generic information about the libraries you use.
21
-
22
- Context7 pulls up-to-date, version-specific documentation and code examples directly from the source. Paste accurate, relevant documentation directly into tools like Cursor, Claude, or any LLM. Get better answers, no hallucinations and an AI that actually understands your stack.
23
- :::