Skip to content

Commit 037662d

Browse files
chore(examples): migrates custom-component example to latest beta [skip-lint] (#9170)
Updates the `Custom Components` example, including packages, readme, lockfile, types and the custom fields. --------- Co-authored-by: Patrik Kozak <[email protected]>
1 parent 389ef16 commit 037662d

File tree

57 files changed

+1189
-1181
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+1189
-1181
lines changed

examples/custom-components/README.md

+36-15
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,67 @@
11
# Payload Custom Components Example
22

3-
This example demonstrates how to use Custom Components in [Payload](https://github.com/payloadcms/payload) Admin Panel. This example includes custom components for every field type available in Payload, including both server and client components. It also includes custom views, custom nav links, and more.
3+
This example demonstrates how to use Custom Components in the [Payload](https://github.com/payloadcms/payload) Admin Panel. Custom components allow you to extend Payload by providing custom UI elements for fields, collections, and views. This example covers custom components for every field type available in Payload, including both server and client components.
44

55
## Quick Start
66

7-
To spin up this example locally, follow these steps:
7+
To spin up this example locally, follow the steps below:
88

99
1. Clone this repo
10-
1. `cd` into this directory and run `pnpm i --ignore-workspace`\*, `yarn`, or `npm install`
10+
1. Navigate into the project directory and install dependencies using your preferred package manager:
1111

12-
> \*If you are running using pnpm within the Payload Monorepo, the `--ignore-workspace` flag is needed so that pnpm generates a lockfile in this example's directory despite the fact that one exists in root.
12+
- `pnpm i --ignore-workspace`\*, `yarn`, or `npm install`
1313

14-
1. `pnpm dev`, `yarn dev` or `npm run dev` to start the server
15-
- Press `y` when prompted to seed the database
16-
1. `open http://localhost:3000` to access the home page
17-
1. `open http://localhost:3000/admin` to access the admin panel
18-
- Login with email `[email protected]` and password `demo`
14+
> \*NOTE: The --ignore-workspace flag is needed if you are running this example within the Payload monorepo to avoid workspace conflicts.
15+
16+
1. Start the server:
17+
- Depending on your package manager, run `pnpm dev`, `yarn dev` or `npm run dev`
18+
- When prompted, type `y` then `enter` to seed the database with sample data
19+
1. Access the application:
20+
- Open your browser and navigate to `http://localhost:3000` to access the homepage.
21+
- Open `http://localhost:3000/admin` to access the admin panel.
22+
1. Login:
23+
24+
- Use the following credentials to log into the admin panel:
25+
> `Email: [email protected]` > `Password: demo`
1926
2027
## How it works
2128

2229
### Collections
2330

24-
See the [Collections](https://payloadcms.com/docs/configuration/collections) docs for details on how to extend any of this functionality.
31+
[Collections](https://payloadcms.com/docs/configuration/collections) in Payload allow you to define structured content types. This example includes multiple collections, with a focus on:
2532

2633
- #### Users
2734

28-
The `users` collection is auth-enabled which provides access to the admin panel.
35+
The `users` collection is **auth-enabled**, providing access to the admin panel and enabling user authentication. This collection shows how to implement a basic user collection with authentication.
2936

30-
For additional help with authentication, see the official [Auth Example](https://github.com/payloadcms/payload/tree/main/examples/auth/cms#readme) or the [Authentication](https://payloadcms.com/docs/authentication/overview#authentication-overview) docs.
37+
- For more details on setting up authentication, checkout the [Auth Example](https://github.com/payloadcms/payload/tree/main/examples/auth/cms#readme) and the [Authentication Overview](https://payloadcms.com/docs/authentication/overview#authentication-overview).
3138

3239
- #### Fields
3340

34-
The `fields` collection contains every field type available in Payload, each with custom components filled in every available "slot", i.e. `admin.components.Field`, `admin.components.Label`, etc. There are two of every field, one for server components, and the other for client components. This pattern shows how to use custom components in both environments, no matter which field type you are using.
41+
The `fields` collection demonstrates all the **field types** available in Payload, each one configured with custom components. This includes every available "slot" for custom components (e.g., `admin.components.Field`, `admin.components.Label`, `admin.components.Input`, etc.). For each field type, two examples are provided: one using **server-side components** and the other using **client-side components**. This pattern illustrates how to customize both types of components across different field types.
42+
43+
- **Custom Field Components**: Custom components allow you to tailor the UI and behavior of the admin panel fields. This can be useful for implementing complex interactions, custom validation, or UI enhancements. For example, you might use a custom component to replace a simple text input with a date picker or a rich text editor.
3544

3645
- #### Views
3746

38-
The `views` collection demonstrates how to add collection-level views, including the default view and custom tabs.
47+
The `views` collection demonstrates how to create **collection-level views**, such as custom tabs or layout configurations. This is where you can modify how data is displayed in the admin panel beyond the default list and edit views. Custom views give you full control over how content is presented to users.
3948

4049
- #### Root Views
4150

42-
The `root-views` collection demonstrates how to add a root document-level view to the admin panel.
51+
The `root-views` collection shows how to implement **root-level views** in the admin panel. These views can be used to modify the global admin interface, adding custom sections or settings that appear outside of collections.
52+
53+
## Troubleshooting
54+
55+
If you encounter any issues during setup or while running the example, here are a few things to try:
56+
57+
- **Missing dependencies**: If you see errors related to missing packages, try deleting the `node_modules` folder and the lockfile (`package-lock.json` or `pnpm-lock.yaml`), then rerun `npm install` or `pnpm i`.
58+
59+
- **Port conflicts**: If the development server isn't starting, ensure that port `3000` isn't being used by another process. You can change the port by modifying the `package.json` file or setting the `PORT` environment variable.
60+
61+
- **Seed data issues**: If the database seeding fails, try clearing the database and then rerun the seeding process.
4362

4463
## Questions
4564

4665
If you have any issues or questions, reach out to us on [Discord](https://discord.com/invite/payload) or start a [GitHub discussion](https://github.com/payloadcms/payload/discussions).
66+
67+
For more detailed documentation on how to extend and customize Payload, check out the full [Payload documentation](https://payloadcms.com/docs).

examples/custom-components/next-env.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
/// <reference types="next/image-types/global" />
33

44
// NOTE: This file should not be edited
5-
// see https://nextjs.org/docs/basic-features/typescript for more information.
5+
// see https://nextjs.org/docs/app/building-your-application/configuring/typescript for more information.

examples/custom-components/package.json

+29-16
Original file line numberDiff line numberDiff line change
@@ -5,39 +5,52 @@
55
"license": "MIT",
66
"type": "module",
77
"scripts": {
8-
"_dev": "cross-env NODE_OPTIONS=--no-deprecation && pnpm generate:importmap && next dev",
8+
"_dev": "cross-env NODE_OPTIONS=--no-deprecation next dev",
99
"build": "cross-env NODE_OPTIONS=--no-deprecation next build",
10-
"dev": "cross-env NODE_OPTIONS=--no-deprecation && pnpm generate:importmap && pnpm seed && next dev --turbo",
11-
"generate:importmap": "payload generate:importmap",
10+
"dev": "cross-env PAYLOAD_SEED=true PAYLOAD_DROP_DATABASE=true NODE_OPTIONS=--no-deprecation next dev",
11+
"generate:importmap": "cross-env NODE_OPTIONS=--no-deprecation payload generate:importmap",
1212
"generate:schema": "payload-graphql generate:schema",
1313
"generate:types": "payload generate:types",
1414
"payload": "cross-env NODE_OPTIONS=--no-deprecation payload",
1515
"seed": "npm run payload migrate:fresh",
1616
"start": "cross-env NODE_OPTIONS=--no-deprecation next start"
1717
},
1818
"dependencies": {
19-
"@payloadcms/db-mongodb": "3.0.0-beta.106",
20-
"@payloadcms/next": "3.0.0-beta.106",
21-
"@payloadcms/richtext-lexical": "3.0.0-beta.106",
22-
"@payloadcms/ui": "3.0.0-beta.106",
19+
"@payloadcms/db-mongodb": "beta",
20+
"@payloadcms/next": "beta",
21+
"@payloadcms/richtext-lexical": "beta",
22+
"@payloadcms/ui": "beta",
2323
"cross-env": "^7.0.3",
2424
"dotenv": "^8.2.0",
2525
"graphql": "^16.9.0",
26-
"next": "15.0.0-canary.160",
27-
"payload": "3.0.0-beta.106",
28-
"react": "19.0.0-rc-5dcb0097-20240918",
29-
"react-dom": "19.0.0-rc-5dcb0097-20240918"
26+
"install": "^0.13.0",
27+
"next": "15.0.0",
28+
"payload": "beta",
29+
"react": "19.0.0-rc-65a56d0e-20241020",
30+
"react-dom": "19.0.0-rc-65a56d0e-20241020"
3031
},
3132
"devDependencies": {
32-
"@payloadcms/graphql": "3.0.0-beta.106",
33-
"@types/react": "npm:[email protected]",
34-
"@types/react-dom": "npm:[email protected]",
33+
"@payloadcms/graphql": "beta",
34+
"@swc/core": "^1.6.13",
35+
"@types/ejs": "^3.1.5",
36+
"@types/react": "npm:[email protected]",
37+
"@types/react-dom": "npm:[email protected]",
3538
"eslint": "^8.57.0",
36-
"eslint-config-next": "15.0.0-canary.146",
37-
"tsx": "^4.7.1",
39+
"eslint-config-next": "15.0.0",
40+
"tsx": "^4.16.2",
3841
"typescript": "5.5.2"
3942
},
4043
"engines": {
4144
"node": "^18.20.2 || >=20.9.0"
45+
},
46+
"pnpm": {
47+
"overrides": {
48+
"@types/react": "npm:[email protected]",
49+
"@types/react-dom": "npm:[email protected]"
50+
}
51+
},
52+
"overrides": {
53+
"@types/react": "npm:[email protected]",
54+
"@types/react-dom": "npm:[email protected]"
4255
}
4356
}

0 commit comments

Comments
 (0)