feat: atoms as npm package (#14160)
* fix: getEnv not returning fallback API_URL breaking examples app * refactor: use vite as the only way to build atoms * refactor: web use atoms from web.ts and rest from dist * refactor: update atoms version, description and set privacy to public * fix: lib and ui import from web atoms * refactor: rename @calcom/platform-atoms to @calcom/atoms * feat: atoms as npm works with example app outside monorepo * start atoms from v1.0.0 * refactor: monorepo atoms for internal use * document atoms publishing * refactor: remove unused import in v2 * fix: mistakes made during main merge * refactor: move back examples app while still having it in atoms-examples repo * refactor: monorepo examples readme * feat: atoms yarn publish command * refactor: atoms css file simplify * fix: mocking atoms in ui unit test * fix: mocking atoms in app-store unit test
This commit is contained in:
1 parent
61a8543e08
commit
74e5f4bf37
34 files changed
+234
-183
No files matched your search
@@ -0,0 +1,3 @@
|
||||
NEXT_PUBLIC_X_CAL_ID=""
|
||||
X_CAL_SECRET_KEY=""
|
||||
NEXT_PUBLIC_CALCOM_API_URL="http://localhost:5555/api/v2"
|
||||
@@ -1,40 +1,35 @@
|
||||
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).
|
||||
# Atoms examples
|
||||
Example apps using atoms - customizable UI components to integrate scheduling into your product.
|
||||
|
||||
## Getting Started
|
||||
## Running examples apps locally
|
||||
|
||||
First, run the development server:
|
||||
1. Cal's backend is required to run example apps, so clone `https://github.com/calcom/cal.com` and follow setup instructions in the readme. Importantly, you need to have Google credentials setup by following [this section](https://github.com/calcom/cal.com?tab=readme-ov-file#obtaining-the-google-api-credentials) in the docs.
|
||||
|
||||
```bash
|
||||
npm run dev
|
||||
# or
|
||||
yarn dev
|
||||
# or
|
||||
pnpm dev
|
||||
# or
|
||||
bun dev
|
||||
2. Open "apps/api/v2/.env" and copy environment variables below, and then copy `NEXTAUTH_SECRET` from the root ".env" of repository cloned in step 1.
|
||||
```jsx
|
||||
NODE_ENV="development"
|
||||
API_PORT=5555
|
||||
DATABASE_READ_URL="postgresql://postgres:@localhost:5450/calendso"
|
||||
DATABASE_WRITE_URL="postgresql://postgres:@localhost:5450/calendso"
|
||||
API_URL="http://localhost"
|
||||
NEXTAUTH_SECRET="copy from .env of root of repository cloned in step 1"
|
||||
DATABASE_URL="postgresql://postgres:@localhost:5450/calendso"
|
||||
JWT_SECRET="asjdijI1JIO12I3O89198jojioSAJDU"
|
||||
REDIS_URL="redis://localhost:6379"
|
||||
```
|
||||
|
||||
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
|
||||
3. Start "apps/api/v2" api using `yarn dev`.
|
||||
4. Start "packages/platform/atoms" atoms package with `yarn dev`.
|
||||
5. Start "apps/web" cal web app using `yarn dx`.
|
||||
6. Open your browser at "http://localhost:3000/" and login with admin username `[email protected]` and password `ADMINadmin2022!`.
|
||||
7. In the web app navigate to `http://localhost:3000/settings/organizations/new` and create a sample organization. When asked for phone verification code enter `111111`.
|
||||
8. In the web app navigate to `http://localhost:3000/settings/organizations/platform/oauth-clients` and create a new oAuth client - give all permissions and set redirect uri to `http://localhost:4321` which points to example app.
|
||||
9. Setup environment for the example app you want to run:
|
||||
1. First, copy ".env.example" into ".env".
|
||||
2. Open ".env" file and paste client id from step 8 in `NEXT_PUBLIC_X_CAL_ID` and client secret in `X_CAL_SECRET_KEY`. If in step 2 you used the same environment variables, then `NEXT_PUBLIC_CALCOM_API_URL` can stay as is. Otherwise adjust the port to point to the same `API_PORT` as you used in step 2.
|
||||
10. Navigate to example app and setup database by running `rm -f prisma/dev.db && yarn prisma db push`.
|
||||
11. Start the example app by running `yarn dev` and go to `http://localhost:4321`.
|
||||
12. In the Google Cloud Console "API & Services" "Credentials" `https://console.cloud.google.com/apis/credentials` open web project setup in step 1 and add `http://localhost:5555/api/v2/platform/gcal/oauth/save` to the authorized redirect URIs.
|
||||
|
||||
You can start editing the page by modifying `pages/index.tsx`. The page auto-updates as you edit the file.
|
||||
<img width="1000" alt="Screenshot 2024-03-21 at 09 42 36" src="https://github.com/calcom/atoms-examples/assets/42170848/82ce4d7a-fc08-489a-ab06-a8eb41a68a2a">
|
||||
|
||||
[API routes](https://nextjs.org/docs/api-routes/introduction) can be accessed on [http://localhost:3000/api/hello](http://localhost:3000/api/hello). This endpoint can be edited in `pages/api/hello.ts`.
|
||||
|
||||
The `pages/api` directory is mapped to `/api/*`. Files in this directory are treated as [API routes](https://nextjs.org/docs/api-routes/introduction) instead of React pages.
|
||||
|
||||
This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font.
|
||||
|
||||
## Learn More
|
||||
|
||||
To learn more about Next.js, take a look at the following resources:
|
||||
|
||||
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
|
||||
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
|
||||
|
||||
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!
|
||||
|
||||
## Deploy on Vercel
|
||||
|
||||
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
|
||||
|
||||
Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.
|
||||
@@ -9,7 +9,7 @@
|
||||
"lint": "next lint"
|
||||
},
|
||||
"dependencies": {
|
||||
"@calcom/platform-atoms": "*",
|
||||
"@calcom/atoms": "*",
|
||||
"@prisma/client": "5.4.2",
|
||||
"next": "14.0.4",
|
||||
"prisma": "^5.7.1",
|
||||
|
||||
@@ -3,8 +3,8 @@ import type { AppProps } from "next/app";
|
||||
import { Poppins } from "next/font/google";
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
import { CalProvider } from "@calcom/platform-atoms/components";
|
||||
import "@calcom/platform-atoms/dist/globals.min.css";
|
||||
import { CalProvider } from "@calcom/atoms";
|
||||
import "@calcom/atoms/globals.min.css";
|
||||
|
||||
const poppins = Poppins({ subsets: ["latin"], weight: ["400", "800"] });
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Navbar } from "@/components/Navbar";
|
||||
import { Inter } from "next/font/google";
|
||||
|
||||
import { AvailabilitySettings } from "@calcom/platform-atoms/components";
|
||||
import { AvailabilitySettings } from "@calcom/atoms";
|
||||
|
||||
const inter = Inter({ subsets: ["latin"] });
|
||||
|
||||
@@ -28,7 +28,6 @@ export default function Availability(props: { calUsername: string; calEmail: str
|
||||
onDeleteSuccess={() => {
|
||||
console.log("Deleted successfully");
|
||||
}}
|
||||
translations={{ timezone: "Select your timezone" }}
|
||||
/>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
@@ -2,7 +2,7 @@ import { Navbar } from "@/components/Navbar";
|
||||
import { Inter } from "next/font/google";
|
||||
import { useState } from "react";
|
||||
|
||||
import { Booker } from "@calcom/platform-atoms/components";
|
||||
import { Booker } from "@calcom/atoms";
|
||||
|
||||
const inter = Inter({ subsets: ["latin"] });
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Navbar } from "@/components/Navbar";
|
||||
import { Inter, Poppins } from "next/font/google";
|
||||
|
||||
import { GcalConnect } from "@calcom/platform-atoms/components";
|
||||
import { GcalConnect } from "@calcom/atoms";
|
||||
|
||||
const inter = Inter({ subsets: ["latin"] });
|
||||
const poppins = Poppins({ subsets: ["latin"], weight: ["400", "800"] });
|
||||
|
||||
@@ -15,7 +15,8 @@
|
||||
"incremental": true,
|
||||
"paths": {
|
||||
"@/*": ["./src/*"]
|
||||
}
|
||||
},
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
|
||||
"exclude": ["node_modules"]
|
||||
|
||||
Reference in new issue
Block a user