Skip to content

Commit

Permalink
Merge pull request #814 from firebase/fdc-web
Browse files Browse the repository at this point in the history
add: dataconnect quickstart
  • Loading branch information
HYACCCINT authored Jul 29, 2024
2 parents 3bd7f95 + 8ddc524 commit c719327
Show file tree
Hide file tree
Showing 42 changed files with 3,060 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
.firebaserc
dist/
**/ui-debug.log
.next
69 changes: 69 additions & 0 deletions dataconnect/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
firebase-debug.log*
firebase-debug.*.log*

# Firebase cache
.firebase/

# Firebase config

# Uncomment this if you'd like others to create their own Firebase project.
# For a team working on the same Firebase project(s), it is recommended to leave
# it commented so all members can deploy to the same project(s) in .firebaserc.
# .firebaserc

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
app/src/lib/dataconnect-sdk/
app/package-lock.json

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.next
.dataconnect
6 changes: 6 additions & 0 deletions dataconnect/app/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
VITE_FIREBASE_API_KEY=your-api-key
VITE_FIREBASE_AUTH_DOMAIN=your-auth-domain
VITE_FIREBASE_PROJECT_ID=your-project-id
VITE_FIREBASE_STORAGE_BUCKET=your-storage-bucket
VITE_FIREBASE_MESSAGING_SENDER_ID=your-messaging-sender-id
VITE_FIREBASE_APP_ID=your-app-id
19 changes: 19 additions & 0 deletions dataconnect/app/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react-hooks/recommended',
],
ignorePatterns: ['dist', '.eslintrc.cjs'],
parser: '@typescript-eslint/parser',
plugins: ['react-refresh'],
rules: {
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
"react-hooks/exhaustive-deps": "warn"
},
}
24 changes: 24 additions & 0 deletions dataconnect/app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
13 changes: 13 additions & 0 deletions dataconnect/app/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/app/src/assets/firebase_logo.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>FriendlyMovies</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
36 changes: 36 additions & 0 deletions dataconnect/app/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"name": "app",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview"
},
"dependencies": {
"@movie/dataconnect": "file:src/lib/dataconnect-sdk",
"dotenv": "^16.4.5",
"firebase": "^10.12.0-dataconnect-preview.388b61c7e",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-icons": "^5.2.1",
"react-router-dom": "^6.25.1"
},
"devDependencies": {
"@types/react": "^18.2.43",
"@types/react-dom": "^18.2.17",
"@typescript-eslint/eslint-plugin": "^6.14.0",
"@typescript-eslint/parser": "^6.14.0",
"@vitejs/plugin-react": "^4.2.1",
"autoprefixer": "^10.4.19",
"eslint": "^8.55.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.5",
"postcss": "^8.4.40",
"tailwindcss": "^3.4.7",
"typescript": "^5.2.2",
"vite": "^5.0.8"
}
}
6 changes: 6 additions & 0 deletions dataconnect/app/postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}
42 changes: 42 additions & 0 deletions dataconnect/app/src/App.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#root {
max-width: 1280px;
margin: 0 auto;
padding: 2rem;
text-align: center;
}

.logo {
height: 6em;
padding: 1.5em;
will-change: filter;
transition: filter 300ms;
}
.logo:hover {
filter: drop-shadow(0 0 2em #646cffaa);
}
.logo.react:hover {
filter: drop-shadow(0 0 2em #61dafbaa);
}

@keyframes logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}

@media (prefers-reduced-motion: no-preference) {
a:nth-of-type(2) .logo {
animation: logo-spin infinite 20s linear;
}
}

.card {
padding: 2em;
}

.read-the-docs {
color: #888;
}
30 changes: 30 additions & 0 deletions dataconnect/app/src/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React from "react";
import { BrowserRouter as Router, Route, Routes } from "react-router-dom";
import Home from "./pages/Home";
import ActorPage from "./pages/Actor";
import MoviePage from "./pages/Movie";
import GenrePage from "./pages/Genre";
import MyProfilePage from "./pages/MyProfile";
import VectorSearchPage from "./pages/VectorSearch";
import AdvancedSearchPage from "./pages/AdvancedSearch";
import NotFound from "./pages/NotFound";
import RootLayout from "./layout/RootLayout";

export default function App() {
return (
<Router>
<RootLayout>
<Routes>
<Route path="/" element={<Home />} />
<Route path="/actor/:id" element={<ActorPage />} />
<Route path="/movie/:id" element={<MoviePage />} />
<Route path="/genre/:genre" element={<GenrePage />} />
<Route path="/myprofile" element={<MyProfilePage />} />
<Route path="/vectorsearch" element={<VectorSearchPage />} />
<Route path="/advancedsearch" element={<AdvancedSearchPage />} />
<Route path="*" element={<NotFound />} />
</Routes>
</RootLayout>
</Router>
);
}
6 changes: 6 additions & 0 deletions dataconnect/app/src/assets/firebase_logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 36 additions & 0 deletions dataconnect/app/src/components/carousel.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import React from 'react';
import MovieCard from '@/components/moviecard';

interface CarouselProps {
title: string;
movies: {
id: string;
title?: string;
imageUrl?: string;
rating?: number | null;
genre?: string | null;
tags?: string[] | null;
}[];
}

export default function Carousel({ title, movies }: CarouselProps) {
return (
<section className="carousel py-8">
<h2 className="text-gray-200 text-2xl font-bold mb-4">{title}</h2>
<div className="carousel__container flex overflow-x-auto space-x-4">
{movies.map((movie) => (
<div className="flex-shrink-0" key={movie.id}>
<MovieCard
id={movie.id}
title={movie.title || 'TBA'}
imageUrl={movie.imageUrl}
rating={movie.rating}
genre={movie.genre}
tags={movie.tags}
/>
</div>
))}
</div>
</section>
);
}
Loading

0 comments on commit c719327

Please sign in to comment.