Skip to content

Commit 7de1fb2

Browse files
committed
Initial commit to showcase all our tutorials now.
1 parent b299b58 commit 7de1fb2

File tree

15 files changed

+3132
-9
lines changed

15 files changed

+3132
-9
lines changed

src/content/docs/tutorials/Developing Your First Widget/building-testing.mdx

Lines changed: 492 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 296 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,296 @@
1+
---
2+
title: "Step 1: Getting Started with Widget Development"
3+
description: Set up your development environment and understand the widget development workflow
4+
sidebar:
5+
order: 1
6+
---
7+
8+
import {
9+
SlTarget,
10+
SlCheck,
11+
SlArrowRight,
12+
SlWrench,
13+
SlSettings,
14+
SlFolder,
15+
} from "react-icons/sl";
16+
17+
Welcome to widget development! In this step, you'll set up your development environment and get familiar with the widget development workflow.
18+
19+
## 🎯 What You'll Accomplish
20+
21+
By the end of this step, you'll have:
22+
23+
<div class="prose">
24+
25+
- **Development environment ready** - All prerequisites installed and configured
26+
- **Widget starter kit cloned** - Your own copy of the widget template
27+
- **Development server running** - Local widget development environment active
28+
- **Project structure understanding** - Know how widget projects are organized
29+
30+
</div>
31+
32+
## 🏢 Check With Your Organization First
33+
34+
Before diving into the standard tools, **check with your platform team** to see if your organization provides:
35+
36+
<div class="prose">
37+
38+
- **Custom widget starter kit** - Organization-specific template with company standards
39+
- **Internal development guidelines** - Company-specific setup instructions
40+
- **Custom development tools** - Organization-specific CLI tools or workflows
41+
- **Internal widget registry** - Private package registry for dependencies
42+
43+
</div>
44+
45+
If your organization has custom tools, use those instead! The concepts in this tutorial will still apply.
46+
47+
## 🔧 Prerequisites Check
48+
49+
Ensure you have the following installed:
50+
51+
### Node.js and Package Manager
52+
53+
```bash
54+
# Check Node.js version (18+ required)
55+
node --version
56+
57+
# Check npm version
58+
npm --version
59+
60+
# Or if using yarn
61+
yarn --version
62+
```
63+
64+
### Code Editor Setup
65+
66+
We recommend **VS Code** with these extensions for the best development experience:
67+
68+
<div class="prose">
69+
70+
- **ES7+ React/Redux/React-Native snippets** - React development helpers
71+
- **TypeScript and JavaScript Language Features** - Enhanced TS support
72+
- **Prettier** - Code formatting
73+
- **ESLint** - Code linting and quality
74+
75+
</div>
76+
77+
## 📦 Cloning the Widget Starter Kit
78+
79+
Let's get the standard 1fe widget starter kit:
80+
81+
### 1. Clone the Repository
82+
83+
```bash
84+
# Clone the widget starter kit
85+
git clone https://github.com/docusign/1fe-widget-starter-kit.git my-first-widget
86+
87+
# Navigate to the project
88+
cd my-first-widget
89+
```
90+
91+
### 2. Install Dependencies
92+
93+
```bash
94+
# Install all dependencies
95+
yarn install
96+
97+
# Or if using npm
98+
npm install
99+
```
100+
101+
This will install all the necessary dependencies for widget development, including:
102+
- **@1fe/cli** - Build and development tools
103+
- **React and TypeScript** - Core development libraries
104+
- **Testing frameworks** - Jest and testing utilities
105+
106+
### 3. Explore the Project Structure
107+
108+
Let's understand what you just cloned:
109+
110+
```
111+
my-first-widget/
112+
├── src/ # Your widget source code
113+
│ ├── components/ # Reusable React components
114+
│ ├── contract.ts # Widget contract definition
115+
│ ├── app1.tsx # Main widget entry point
116+
│ └── widget.ts # Widget configuration
117+
├── tests/ # Test files
118+
├── .1fe.config.ts # Widget build configuration
119+
├── package.json # Dependencies and scripts
120+
└── README.md # Project documentation
121+
```
122+
123+
## 🏗️ Understanding Key Files
124+
125+
### Widget Entry Point (`src/app1.tsx`)
126+
127+
This is your main widget component:
128+
129+
```typescript title="src/app1.tsx"
130+
import React, { useEffect } from 'react';
131+
import { platformProps } from '@1fe/shell';
132+
import { WidgetProps } from './contract';
133+
134+
const MyWidget: React.FC<WidgetProps> = (props) => {
135+
useEffect(() => {
136+
// Widget initialization
137+
platformProps.utils.appLoadTime.end();
138+
console.log('Hello from my first widget!');
139+
}, []);
140+
141+
return (
142+
<div>
143+
<h1>My First Widget</h1>
144+
<p>Welcome to 1fe widget development!</p>
145+
</div>
146+
);
147+
};
148+
149+
export default MyWidget;
150+
```
151+
152+
### Widget Contract (`src/contract.ts`)
153+
154+
Defines the interface between your widget and the platform:
155+
156+
```typescript title="src/contract.ts"
157+
export interface WidgetProps {
158+
// Define the props your widget expects
159+
title?: string;
160+
theme?: 'light' | 'dark';
161+
// Add more props as needed
162+
}
163+
```
164+
165+
### Configuration (`.1fe.config.ts`)
166+
167+
Controls how your widget is built and deployed:
168+
169+
```typescript title=".1fe.config.ts"
170+
import { defineConfig } from '@1fe/cli';
171+
172+
export default defineConfig({
173+
widget: {
174+
name: 'my-first-widget',
175+
entry: 'src/app1.tsx',
176+
},
177+
// Additional configuration options
178+
});
179+
```
180+
181+
## 🚀 Starting the Development Server
182+
183+
Now let's get your widget running locally:
184+
185+
```bash
186+
# Start the development server
187+
yarn dev
188+
189+
# Or with npm
190+
npm run dev
191+
```
192+
193+
You should see output similar to:
194+
195+
```
196+
✓ Widget development server started
197+
✓ Widget bundle available at: http://localhost:8080/js/1fe-bundle.js
198+
✓ Ready for development!
199+
```
200+
201+
**What just happened?**
202+
- The 1fe CLI compiled your widget
203+
- Started a local development server
204+
- Made your widget available at a local URL
205+
- Enabled hot reloading for development
206+
207+
## 🔍 Verifying Your Setup
208+
209+
Let's make sure everything is working:
210+
211+
### 1. Check the Bundle URL
212+
213+
Open your browser and visit:
214+
```
215+
http://localhost:8080/js/1fe-bundle.js
216+
```
217+
218+
You should see JavaScript code (the compiled widget bundle).
219+
220+
### 2. Check Development Logs
221+
222+
In your terminal, you should see:
223+
- No TypeScript errors
224+
- Successful compilation messages
225+
- Hot reload ready status
226+
227+
### 3. Make a Test Change
228+
229+
Edit `src/app1.tsx` and change the heading:
230+
231+
```typescript title="src/app1.tsx" {8}
232+
return (
233+
<div>
234+
<h1>My Awesome First Widget!</h1>
235+
<p>Welcome to 1fe widget development!</p>
236+
</div>
237+
);
238+
```
239+
240+
Save the file and watch your terminal - you should see the widget recompile automatically.
241+
242+
## 📁 Understanding Widget Architecture
243+
244+
### Platform Integration
245+
246+
Your widget runs within the 1fe platform and has access to:
247+
248+
<div class="prose">
249+
250+
- **Platform utilities** - Shared functions for logging, navigation, etc.
251+
- **Shared dependencies** - React, design systems, and common libraries
252+
- **Shell context** - Platform-wide state and configuration
253+
- **Event system** - Communication with other widgets and the shell
254+
255+
</div>
256+
257+
### Development Workflow
258+
259+
The typical development cycle is:
260+
261+
1. **Code** - Write widget functionality in `src/`
262+
2. **Test** - Use the playground for immediate feedback
263+
3. **Build** - Compile with `yarn build:widget`
264+
4. **Deploy** - Push to your organization's deployment pipeline
265+
266+
## ✅ Validation Checklist
267+
268+
Before moving to the next step, ensure:
269+
270+
<div class="prose">
271+
272+
- [ ] **Node.js 18+** installed and working
273+
- [ ] **Widget starter kit** cloned and dependencies installed
274+
- [ ] **Development server** running without errors
275+
- [ ] **Bundle URL** accessible at http://localhost:8080/js/1fe-bundle.js
276+
- [ ] **Hot reloading** working when you make code changes
277+
278+
</div>
279+
280+
## 🎉 Success!
281+
282+
Congratulations! You now have a fully functional widget development environment. Your widget is compiled, served locally, and ready for development.
283+
284+
## 👉 Next Step
285+
286+
Now that your development environment is ready, let's learn how to use the 1fe Playground to develop and test your widget interactively.
287+
288+
**[Step 2: Using the Playground for Development](/tutorials/developing-your-first-widget/using-playground/)**
289+
290+
In the next step, you'll load your widget in the playground and start the interactive development workflow.
291+
292+
---
293+
294+
:::tip[Organization Integration]
295+
Once you're comfortable with this standard workflow, ask your platform team about organization-specific development tools. The concepts you're learning here apply to any custom tooling your organization provides!
296+
:::

0 commit comments

Comments
 (0)