Skip to content

Commit b04c696

Browse files
authored
Merge pull request #45 from ashikka/feat/firebase-integration-sample
feat: Firebase Integration Sample
2 parents 47bc74a + 9bd80dd commit b04c696

24 files changed

+11608
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Dependency directory
2+
node_modules/
3+
4+
#Build directory
5+
dist/
6+
7+
.env
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Firebase Integration Plugin
2+
3+
This plugin is an example to integrate the `Firebase` library. This plugin just retrieves the data from the database specified and displays it in the plugin window.
4+
5+
## Install dependencies
6+
7+
First ensure that your terminal is in the root of this project. Then:
8+
9+
For `yarn` users, install all dependencies using:
10+
11+
```
12+
yarn install
13+
```
14+
15+
For `npm` users, install all dependencies using:
16+
17+
```
18+
npm install
19+
```
20+
21+
## Firestore Setup
22+
23+
Next, you need to create a `.env` file containing all the variables. Enter all variables from your Firebase project:
24+
25+
```sh
26+
{
27+
echo 'API_KEY='
28+
echo 'AUTH_DOMAIN='
29+
echo 'PROJECT_ID='
30+
echo 'STORAGE_BUCKET='
31+
echo 'MESSAGING_SENDER_ID='
32+
echo 'APP_ID='
33+
echo 'COLLECTION_NAME='
34+
35+
} >> .env
36+
```
37+
38+
## Build Process
39+
40+
There are two ways to build the plugin for use in Photoshop:
41+
42+
* `yarn watch` or `npm run watch` will build a development version of the plugin, and recompile everytime you make a change to the source files. The result is placed in `dist`.
43+
* `yarn build` or `npm run build` will build a production version of the plugin and place it in `dist`. It will not update every time you make a change to the source files.
44+
45+
> You **must** run either `watch` or `build` prior to trying to use within Photoshop!
46+
47+
## Launching in Photoshop
48+
49+
You can use the UXP Developer Tools to load the plugin into Photoshop.
50+
51+
If the plugin hasn't already been added to your workspace in the UXP Developer Tools, you can add it by clicking "Add Plugin..." and selecting `dist/manifest.json`. **DO NOT** select the `manifest.json` file inside the `plugin` folder.
52+
53+
Once added, you can load it into Photoshop by clicking the ••• button on the corresponding row, and clicking "Load". Switch to Photoshop and you should see the starter panels.
54+
55+
56+
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { initializeApp } from "firebase/app";
2+
import { getFirestore, collection, getDocs } from "firebase/firestore/lite";
3+
4+
// Configure your Firebase environment
5+
const config = {
6+
apiKey: process.env.API_KEY,
7+
authDomain: process.env.AUTH_DOMAIN,
8+
projectId: process.env.PROJECT_ID,
9+
storageBucket: process.env.STORAGE_BUCKET,
10+
messagingSenderId: process.env.MESSAGING_SENDER_ID,
11+
appId: process.env.APP_ID
12+
}
13+
14+
// Initialize the app
15+
const app = initializeApp(config);
16+
17+
// Get the database for the initialized app
18+
const db = getFirestore(app);
19+
20+
// Make client side requests to get the data and map it accordingly
21+
async function getData() {
22+
try {
23+
const names = collection(db, process.env.COLLECTION_NAME);
24+
const documents = await getDocs(names);
25+
const list = documents.docs.map((doc) => doc.data());
26+
return list;
27+
} catch (e) {
28+
return e;
29+
}
30+
}
31+
32+
export default getData;

0 commit comments

Comments
 (0)