├── .gitignore ├── README.md ├── package.json ├── public ├── global.css └── index.html ├── rollup.config.js └── src ├── App.svelte ├── Login.svelte ├── Profile.svelte ├── TodoItem.svelte ├── Todos.svelte ├── firebase.js └── main.js /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | public/bundle.* 4 | package-lock.json 5 | yarn.lock 6 | NOTES.md -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Svelte v3 - Firebase Demo 2 | 3 | More [Svelte](https://fireship.io/tags/svelte/) on Fireship.io 4 | 5 | Build a basic authenticated todo app with Svelte & Firebase (RxFire): 6 | 7 | * [x] login/logout with Google OAuth 8 | * [x] create, query, update, delete associated todo items. 9 | 10 | ``` 11 | git clone 12 | npm run dev 13 | ``` 14 | 15 | Replace the credentials in `app/firebase.js`. -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "svelte-app", 3 | "version": "1.0.0", 4 | "devDependencies": { 5 | "npm-run-all": "^4.1.5", 6 | "rollup": "^1.10.1", 7 | "rollup-plugin-commonjs": "^9.3.4", 8 | "rollup-plugin-node-resolve": "^4.2.3", 9 | "rollup-plugin-svelte": "^5.0.3", 10 | "rollup-plugin-terser": "^4.0.4", 11 | "sirv-cli": "^0.3.1", 12 | "svelte": "^3.0.0" 13 | }, 14 | "scripts": { 15 | "build": "rollup -c", 16 | "autobuild": "rollup -c -w", 17 | "dev": "run-p start:dev autobuild", 18 | "start": "sirv public", 19 | "start:dev": "sirv public --dev" 20 | }, 21 | "dependencies": { 22 | "firebase": "^5.10.0", 23 | "rxfire": "^3.4.0", 24 | "rxjs": "^6.5.1" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /public/global.css: -------------------------------------------------------------------------------- 1 | html, body { 2 | position: relative; 3 | width: 100%; 4 | height: 100%; 5 | } 6 | 7 | body { 8 | color: #333; 9 | margin: 0; 10 | padding: 8px; 11 | box-sizing: border-box; 12 | font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif; 13 | } 14 | 15 | a { 16 | color: rgb(0,100,200); 17 | text-decoration: none; 18 | } 19 | 20 | a:hover { 21 | text-decoration: underline; 22 | } 23 | 24 | a:visited { 25 | color: rgb(0,80,160); 26 | } 27 | 28 | label { 29 | display: block; 30 | } 31 | 32 | input, button, select, textarea { 33 | font-family: inherit; 34 | font-size: inherit; 35 | padding: 0.4em; 36 | margin: 0 0 0.5em 0; 37 | box-sizing: border-box; 38 | border: 1px solid #ccc; 39 | border-radius: 2px; 40 | } 41 | 42 | input:disabled { 43 | color: #ccc; 44 | } 45 | 46 | input[type="range"] { 47 | height: 0; 48 | } 49 | 50 | button { 51 | background-color: #f4f4f4; 52 | outline: none; 53 | } 54 | 55 | button:active { 56 | background-color: #ddd; 57 | } 58 | 59 | button:focus { 60 | border-color: #666; 61 | } -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 |Your userID is { uid }
12 | -------------------------------------------------------------------------------- /src/TodoItem.svelte: -------------------------------------------------------------------------------- 1 | 24 | 25 | 41 | 42 | 43 |Your task: { text }
50 | 51 | -------------------------------------------------------------------------------- /src/firebase.js: -------------------------------------------------------------------------------- 1 | import firebase from 'firebase/app';// rollup bundle issue with ESM import 2 | import 'firebase/auth'; 3 | import 'firebase/firestore'; 4 | var firebaseConfig = { 5 | apiKey: "AIzaSyCNGXNpOeRLQcJnuSgUXLv8sWcPhvJfyVA", 6 | authDomain: "fireship-lessons.firebaseapp.com", 7 | databaseURL: "https://fireship-lessons.firebaseio.com", 8 | projectId: "fireship-lessons", 9 | storageBucket: "fireship-lessons.appspot.com", 10 | messagingSenderId: "758773997881" 11 | }; 12 | 13 | console.log(firebase) 14 | 15 | firebase.initializeApp(firebaseConfig); 16 | 17 | export const auth = firebase.auth(); 18 | export const googleProvider = new firebase.auth.GoogleAuthProvider(); 19 | 20 | export const db = firebase.firestore(); 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/main.js: -------------------------------------------------------------------------------- 1 | import App from './App.svelte'; 2 | 3 | const app = new App({ 4 | target: document.body, 5 | props: { 6 | name: 'FireSvelte 🔥', 7 | }, 8 | }); 9 | 10 | export default app; --------------------------------------------------------------------------------