├── .firebaserc ├── firestore.indexes.json ├── public ├── favicon.ico ├── logo192.png ├── logo512.png ├── robots.txt ├── manifest.json └── index.html ├── README.md ├── storage.rules ├── firebase.json ├── src ├── App.test.js ├── setupTests.js ├── index.css ├── base.js ├── Home.js ├── index.js ├── App.css ├── NewAlbumForm.js ├── NewPhoto.js ├── App.js ├── Album.js ├── logo.svg ├── serviceWorker.js └── mvp.css ├── .gitignore ├── firestore.rules └── package.json /.firebaserc: -------------------------------------------------------------------------------- 1 | { 2 | "projects": { 3 | "default": "frb-albums" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /firestore.indexes.json: -------------------------------------------------------------------------------- 1 | { 2 | "indexes": [], 3 | "fieldOverrides": [] 4 | } 5 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satansdeer/firebase-albums/HEAD/public/favicon.ico -------------------------------------------------------------------------------- /public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satansdeer/firebase-albums/HEAD/public/logo192.png -------------------------------------------------------------------------------- /public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satansdeer/firebase-albums/HEAD/public/logo512.png -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Firebase Upload Download Files - Albums / Picture Gallery 2 | 3 | Example code for [this video](https://youtu.be/SvTfX7t_qSc) -------------------------------------------------------------------------------- /storage.rules: -------------------------------------------------------------------------------- 1 | service firebase.storage { 2 | match /b/{bucket}/o { 3 | match /{allPaths=**} { 4 | allow read, write; 5 | } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /firebase.json: -------------------------------------------------------------------------------- 1 | { 2 | "firestore": { 3 | "rules": "firestore.rules", 4 | "indexes": "firestore.indexes.json" 5 | }, 6 | "storage": { 7 | "rules": "storage.rules" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/App.test.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { render } from '@testing-library/react'; 3 | import App from './App'; 4 | 5 | test('renders learn react link', () => { 6 | expect(true).toEqual(true); 7 | }); 8 | -------------------------------------------------------------------------------- /src/setupTests.js: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom/extend-expect'; 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 5 | sans-serif; 6 | -webkit-font-smoothing: antialiased; 7 | -moz-osx-font-smoothing: grayscale; 8 | } 9 | 10 | code { 11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 12 | monospace; 13 | } 14 | -------------------------------------------------------------------------------- /src/base.js: -------------------------------------------------------------------------------- 1 | import firebase from 'firebase' 2 | import 'firebase/storage' 3 | 4 | export const app = firebase.initializeApp({ 5 | "projectId": "frb-albums", 6 | "appId": "1:384597741592:web:9dfab25140f21ba56df36d", 7 | "databaseURL": "https://frb-albums.firebaseio.com", 8 | "storageBucket": "frb-albums.appspot.com", 9 | "locationId": "us-central", 10 | "apiKey": "AIzaSyDDARuciWs5mvhNckQLnLiaghxwwSmu-aA", 11 | "authDomain": "frb-albums.firebaseapp.com", 12 | "messagingSenderId": "384597741592" 13 | }); 14 | 15 | -------------------------------------------------------------------------------- /public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /src/Home.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import {Link} from 'react-router-dom' 3 | import {NewAlbumForm} from './NewAlbumForm' 4 | 5 | export const Home = ({albums}) => { 6 | 7 | return <> 8 |
9 | {albums.map((album) => ( 10 | 11 | 15 | 16 | ))} 17 |
18 | 21 | 22 | } -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import ReactDOM from "react-dom"; 3 | import "./index.css"; 4 | import "./mvp.css"; 5 | import App from "./App"; 6 | import * as serviceWorker from "./serviceWorker"; 7 | import { BrowserRouter } from "react-router-dom"; 8 | 9 | ReactDOM.render( 10 | 11 | 12 | 13 | 14 | , 15 | document.getElementById("root") 16 | ); 17 | 18 | // If you want your app to work offline and load faster, you can change 19 | // unregister() to register() below. Note this comes with some pitfalls. 20 | // Learn more about service workers: https://bit.ly/CRA-PWA 21 | serviceWorker.unregister(); 22 | -------------------------------------------------------------------------------- /src/App.css: -------------------------------------------------------------------------------- 1 | .App { 2 | text-align: center; 3 | } 4 | 5 | .App-logo { 6 | height: 40vmin; 7 | pointer-events: none; 8 | } 9 | 10 | @media (prefers-reduced-motion: no-preference) { 11 | .App-logo { 12 | animation: App-logo-spin infinite 20s linear; 13 | } 14 | } 15 | 16 | .App-header { 17 | background-color: #282c34; 18 | min-height: 100vh; 19 | display: flex; 20 | flex-direction: column; 21 | align-items: center; 22 | justify-content: center; 23 | font-size: calc(10px + 2vmin); 24 | color: white; 25 | } 26 | 27 | .App-link { 28 | color: #61dafb; 29 | } 30 | 31 | @keyframes App-logo-spin { 32 | from { 33 | transform: rotate(0deg); 34 | } 35 | to { 36 | transform: rotate(360deg); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /firestore.rules: -------------------------------------------------------------------------------- 1 | rules_version = '2'; 2 | service cloud.firestore { 3 | match /databases/{database}/documents { 4 | 5 | // This rule allows anyone on the internet to view, edit, and delete 6 | // all data in your Firestore database. It is useful for getting 7 | // started, but it is configured to expire after 30 days because it 8 | // leaves your app open to attackers. At that time, all client 9 | // requests to your Firestore database will be denied. 10 | // 11 | // Make sure to write security rules for your app before that time, or else 12 | // your app will lose access to your Firestore database 13 | match /{document=**} { 14 | allow read, write: if request.time < timestamp.date(2020, 7, 8); 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /src/NewAlbumForm.js: -------------------------------------------------------------------------------- 1 | import React, { useState } from "react"; 2 | import { app } from "./base"; 3 | 4 | const db = app.firestore(); 5 | 6 | export const NewAlbumForm = () => { 7 | const [albumName, setAlbumName] = useState(""); 8 | 9 | const onAlbumNameChange = (e) => { 10 | setAlbumName(e.target.value); 11 | }; 12 | 13 | const onAlbumCreate = () => { 14 | if (!albumName) { 15 | return; 16 | } 17 | db.collection("albums").doc(albumName).set({ 18 | name: albumName, 19 | }); 20 | setAlbumName(""); 21 | }; 22 | 23 | return ( 24 | <> 25 | 26 | 27 | 28 | ); 29 | }; 30 | -------------------------------------------------------------------------------- /src/NewPhoto.js: -------------------------------------------------------------------------------- 1 | import React, {useState} from 'react' 2 | import firebase from 'firebase' 3 | import {app} from './base' 4 | 5 | const db = app.firestore() 6 | const storage = app.storage(); 7 | 8 | export const NewPhoto = ({currentAlbum}) => { 9 | const [file, setFile] = useState(null) 10 | 11 | const onFileChange = (e) => { 12 | setFile(e.target.files[0]) 13 | } 14 | 15 | const onUpload = async () => { 16 | const storageRef = storage.ref() 17 | const fileRef = storageRef.child(file.name) 18 | await fileRef.put(file) 19 | db.collection("albums").doc(currentAlbum).update({ 20 | images: firebase.firestore.FieldValue.arrayUnion({ 21 | name: file.name, 22 | url: await fileRef.getDownloadURL() 23 | }) 24 | }) 25 | } 26 | 27 | return <> 28 | 29 | 30 | 31 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "firebase-albums", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@testing-library/jest-dom": "^4.2.4", 7 | "@testing-library/react": "^9.3.2", 8 | "@testing-library/user-event": "^7.1.2", 9 | "firebase": "^7.15.0", 10 | "react": "^16.14.0", 11 | "react-dom": "^16.14.0", 12 | "react-router-dom": "^5.2.0", 13 | "react-scripts": "3.4.4" 14 | }, 15 | "scripts": { 16 | "start": "react-scripts start", 17 | "build": "react-scripts build", 18 | "test": "react-scripts test", 19 | "eject": "react-scripts eject" 20 | }, 21 | "eslintConfig": { 22 | "extends": "react-app" 23 | }, 24 | "browserslist": { 25 | "production": [ 26 | ">0.2%", 27 | "not dead", 28 | "not op_mini all" 29 | ], 30 | "development": [ 31 | "last 1 chrome version", 32 | "last 1 firefox version", 33 | "last 1 safari version" 34 | ] 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/App.js: -------------------------------------------------------------------------------- 1 | import React, { useState, useEffect } from "react"; 2 | import { app } from "./base"; 3 | import { NewAlbumForm } from "./NewAlbumForm"; 4 | import { Switch, Route, Link } from "react-router-dom"; 5 | import { Album } from "./Album"; 6 | import { Home } from "./Home"; 7 | 8 | const db = app.firestore(); 9 | 10 | function App() { 11 | const [albums, setAlbums] = useState([]); 12 | 13 | useEffect(() => { 14 | const unmount = db.collection("albums").onSnapshot((snapshot) => { 15 | const tempAlbums = []; 16 | snapshot.forEach((doc) => { 17 | tempAlbums.push({ ...doc.data(), id: doc.id }); 18 | }); 19 | setAlbums(tempAlbums); 20 | }); 21 | return unmount; 22 | }, []); 23 | 24 | return ( 25 |
26 | 27 | }/> 28 | 29 | 30 |
31 | ); 32 | } 33 | 34 | export default App; 35 | -------------------------------------------------------------------------------- /src/Album.js: -------------------------------------------------------------------------------- 1 | import React, { useState, useEffect } from "react"; 2 | import { useRouteMatch, Link } from "react-router-dom"; 3 | import { NewPhoto } from "./NewPhoto"; 4 | import { app } from "./base"; 5 | 6 | const db = app.firestore(); 7 | 8 | export const Album = () => { 9 | const [images, setImages] = useState([]); 10 | const [albumName, setAlbumName] = useState(""); 11 | 12 | const match = useRouteMatch("/:album"); 13 | const { album } = match.params; 14 | 15 | useEffect(() => { 16 | const unmount = db.collection("albums") 17 | .doc(album) 18 | .onSnapshot((doc) => { 19 | setImages(doc.data().images || []); 20 | setAlbumName(doc.data().name); 21 | }); 22 | return unmount 23 | }, []); 24 | 25 | return ( 26 | <> 27 |
28 |
29 |

{albumName}

30 |

Go to the Home page

31 |
32 | {images.map((image) => ( 33 | 36 | ))} 37 |
38 | 41 | 42 | ); 43 | }; 44 | -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 17 | 18 | 27 | React App 28 | 29 | 30 | 31 |
32 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /src/logo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/serviceWorker.js: -------------------------------------------------------------------------------- 1 | // This optional code is used to register a service worker. 2 | // register() is not called by default. 3 | 4 | // This lets the app load faster on subsequent visits in production, and gives 5 | // it offline capabilities. However, it also means that developers (and users) 6 | // will only see deployed updates on subsequent visits to a page, after all the 7 | // existing tabs open on the page have been closed, since previously cached 8 | // resources are updated in the background. 9 | 10 | // To learn more about the benefits of this model and instructions on how to 11 | // opt-in, read https://bit.ly/CRA-PWA 12 | 13 | const isLocalhost = Boolean( 14 | window.location.hostname === 'localhost' || 15 | // [::1] is the IPv6 localhost address. 16 | window.location.hostname === '[::1]' || 17 | // 127.0.0.0/8 are considered localhost for IPv4. 18 | window.location.hostname.match( 19 | /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/ 20 | ) 21 | ); 22 | 23 | export function register(config) { 24 | if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) { 25 | // The URL constructor is available in all browsers that support SW. 26 | const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href); 27 | if (publicUrl.origin !== window.location.origin) { 28 | // Our service worker won't work if PUBLIC_URL is on a different origin 29 | // from what our page is served on. This might happen if a CDN is used to 30 | // serve assets; see https://github.com/facebook/create-react-app/issues/2374 31 | return; 32 | } 33 | 34 | window.addEventListener('load', () => { 35 | const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`; 36 | 37 | if (isLocalhost) { 38 | // This is running on localhost. Let's check if a service worker still exists or not. 39 | checkValidServiceWorker(swUrl, config); 40 | 41 | // Add some additional logging to localhost, pointing developers to the 42 | // service worker/PWA documentation. 43 | navigator.serviceWorker.ready.then(() => { 44 | console.log( 45 | 'This web app is being served cache-first by a service ' + 46 | 'worker. To learn more, visit https://bit.ly/CRA-PWA' 47 | ); 48 | }); 49 | } else { 50 | // Is not localhost. Just register service worker 51 | registerValidSW(swUrl, config); 52 | } 53 | }); 54 | } 55 | } 56 | 57 | function registerValidSW(swUrl, config) { 58 | navigator.serviceWorker 59 | .register(swUrl) 60 | .then(registration => { 61 | registration.onupdatefound = () => { 62 | const installingWorker = registration.installing; 63 | if (installingWorker == null) { 64 | return; 65 | } 66 | installingWorker.onstatechange = () => { 67 | if (installingWorker.state === 'installed') { 68 | if (navigator.serviceWorker.controller) { 69 | // At this point, the updated precached content has been fetched, 70 | // but the previous service worker will still serve the older 71 | // content until all client tabs are closed. 72 | console.log( 73 | 'New content is available and will be used when all ' + 74 | 'tabs for this page are closed. See https://bit.ly/CRA-PWA.' 75 | ); 76 | 77 | // Execute callback 78 | if (config && config.onUpdate) { 79 | config.onUpdate(registration); 80 | } 81 | } else { 82 | // At this point, everything has been precached. 83 | // It's the perfect time to display a 84 | // "Content is cached for offline use." message. 85 | console.log('Content is cached for offline use.'); 86 | 87 | // Execute callback 88 | if (config && config.onSuccess) { 89 | config.onSuccess(registration); 90 | } 91 | } 92 | } 93 | }; 94 | }; 95 | }) 96 | .catch(error => { 97 | console.error('Error during service worker registration:', error); 98 | }); 99 | } 100 | 101 | function checkValidServiceWorker(swUrl, config) { 102 | // Check if the service worker can be found. If it can't reload the page. 103 | fetch(swUrl, { 104 | headers: { 'Service-Worker': 'script' }, 105 | }) 106 | .then(response => { 107 | // Ensure service worker exists, and that we really are getting a JS file. 108 | const contentType = response.headers.get('content-type'); 109 | if ( 110 | response.status === 404 || 111 | (contentType != null && contentType.indexOf('javascript') === -1) 112 | ) { 113 | // No service worker found. Probably a different app. Reload the page. 114 | navigator.serviceWorker.ready.then(registration => { 115 | registration.unregister().then(() => { 116 | window.location.reload(); 117 | }); 118 | }); 119 | } else { 120 | // Service worker found. Proceed as normal. 121 | registerValidSW(swUrl, config); 122 | } 123 | }) 124 | .catch(() => { 125 | console.log( 126 | 'No internet connection found. App is running in offline mode.' 127 | ); 128 | }); 129 | } 130 | 131 | export function unregister() { 132 | if ('serviceWorker' in navigator) { 133 | navigator.serviceWorker.ready 134 | .then(registration => { 135 | registration.unregister(); 136 | }) 137 | .catch(error => { 138 | console.error(error.message); 139 | }); 140 | } 141 | } 142 | -------------------------------------------------------------------------------- /src/mvp.css: -------------------------------------------------------------------------------- 1 | /* MVP.css v1.6 - https://github.com/andybrewer/mvp */ 2 | 3 | :root { 4 | --border-radius: 5px; 5 | --box-shadow: 2px 2px 10px; 6 | --color: #118bee; 7 | --color-accent: #118bee15; 8 | --color-bg: #fff; 9 | --color-bg-secondary: #e9e9e9; 10 | --color-secondary: #920de9; 11 | --color-secondary-accent: #920de90b; 12 | --color-shadow: #f4f4f4; 13 | --color-text: #000; 14 | --color-text-secondary: #999; 15 | --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif; 16 | --hover-brightness: 1.2; 17 | --justify-important: center; 18 | --justify-normal: left; 19 | --line-height: 1.5; 20 | --width-card: 285px; 21 | --width-card-medium: 460px; 22 | --width-card-wide: 800px; 23 | --width-content: 1080px; 24 | } 25 | 26 | /* 27 | @media (prefers-color-scheme: dark) { 28 | :root { 29 | --color: #0097fc; 30 | --color-accent: #0097fc4f; 31 | --color-bg: #333; 32 | --color-bg-secondary: #555; 33 | --color-secondary: #e20de9; 34 | --color-secondary-accent: #e20de94f; 35 | --color-shadow: #bbbbbb20; 36 | --color-text: #f7f7f7; 37 | --color-text-secondary: #aaa; 38 | } 39 | } 40 | */ 41 | 42 | /* Layout */ 43 | article aside { 44 | background: var(--color-secondary-accent); 45 | border-left: 4px solid var(--color-secondary); 46 | padding: 0.01rem 0.8rem; 47 | } 48 | 49 | body { 50 | background: var(--color-bg); 51 | color: var(--color-text); 52 | font-family: var(--font-family); 53 | line-height: var(--line-height); 54 | margin: 0; 55 | overflow-x: hidden; 56 | padding: 1rem 0; 57 | } 58 | 59 | footer, 60 | header, 61 | main { 62 | margin: 0 auto; 63 | max-width: var(--width-content); 64 | padding: 2rem 1rem; 65 | } 66 | 67 | hr { 68 | background-color: var(--color-bg-secondary); 69 | border: none; 70 | height: 1px; 71 | margin: 4rem 0; 72 | } 73 | 74 | section { 75 | display: flex; 76 | flex-wrap: wrap; 77 | justify-content: var(--justify-important); 78 | } 79 | 80 | section aside { 81 | border: 1px solid var(--color-bg-secondary); 82 | border-radius: var(--border-radius); 83 | box-shadow: var(--box-shadow) var(--color-shadow); 84 | margin: 1rem; 85 | padding: 1.25rem; 86 | width: var(--width-card); 87 | } 88 | 89 | section aside:hover { 90 | box-shadow: var(--box-shadow) var(--color-bg-secondary); 91 | } 92 | 93 | section aside img { 94 | max-width: 100%; 95 | } 96 | 97 | [hidden] { 98 | display: none; 99 | } 100 | 101 | /* Headers */ 102 | article header, 103 | div header, 104 | main header { 105 | padding-top: 0; 106 | } 107 | 108 | header { 109 | text-align: var(--justify-important); 110 | } 111 | 112 | header a b, 113 | header a em, 114 | header a i, 115 | header a strong { 116 | margin-left: 0.5rem; 117 | margin-right: 0.5rem; 118 | } 119 | 120 | header nav img { 121 | margin: 1rem 0; 122 | } 123 | 124 | section header { 125 | padding-top: 0; 126 | width: 100%; 127 | } 128 | 129 | /* Nav */ 130 | nav { 131 | align-items: center; 132 | display: flex; 133 | font-weight: bold; 134 | justify-content: space-between; 135 | margin-bottom: 7rem; 136 | } 137 | 138 | nav ul { 139 | list-style: none; 140 | padding: 0; 141 | } 142 | 143 | nav ul li { 144 | display: inline-block; 145 | margin: 0 0.5rem; 146 | position: relative; 147 | text-align: left; 148 | } 149 | 150 | /* Nav Dropdown */ 151 | nav ul li:hover ul { 152 | display: block; 153 | } 154 | 155 | nav ul li ul { 156 | background: var(--color-bg); 157 | border: 1px solid var(--color-bg-secondary); 158 | border-radius: var(--border-radius); 159 | box-shadow: var(--box-shadow) var(--color-shadow); 160 | display: none; 161 | height: auto; 162 | padding: .5rem 1rem; 163 | position: absolute; 164 | left: -2px; 165 | top: 1.7rem; 166 | width: auto; 167 | } 168 | 169 | nav ul li ul li, 170 | nav ul li ul li a { 171 | display: block; 172 | } 173 | 174 | /* Typography */ 175 | code, 176 | samp { 177 | background-color: var(--color-accent); 178 | border-radius: var(--border-radius); 179 | color: var(--color-text); 180 | display: inline-block; 181 | margin: 0 0.1rem; 182 | padding: 0 0.5rem; 183 | } 184 | 185 | details { 186 | margin: 1.3rem 0; 187 | } 188 | 189 | details summary { 190 | font-weight: bold; 191 | cursor: pointer; 192 | } 193 | 194 | h1, 195 | h2, 196 | h3, 197 | h4, 198 | h5, 199 | h6 { 200 | line-height: var(--line-height); 201 | } 202 | 203 | mark { 204 | padding: 0.1rem; 205 | } 206 | 207 | ol li, 208 | ul li { 209 | padding: 0.2rem 0; 210 | } 211 | 212 | p { 213 | margin: 0.75rem 0; 214 | padding: 0; 215 | } 216 | 217 | pre { 218 | margin: 1rem 0; 219 | max-width: var(--width-card-wide); 220 | padding: 1rem 0; 221 | } 222 | 223 | pre code, 224 | pre samp { 225 | display: block; 226 | max-width: var(--width-card-wide); 227 | padding: 0.5rem 2rem; 228 | white-space: pre-wrap; 229 | } 230 | 231 | small { 232 | color: var(--color-text-secondary); 233 | } 234 | 235 | sup { 236 | background-color: var(--color-secondary); 237 | border-radius: var(--border-radius); 238 | color: var(--color-bg); 239 | font-size: xx-small; 240 | font-weight: bold; 241 | margin: 0.2rem; 242 | padding: 0.2rem 0.3rem; 243 | position: relative; 244 | top: -2px; 245 | } 246 | 247 | /* Links */ 248 | a { 249 | color: var(--color-secondary); 250 | display: inline-block; 251 | font-weight: bold; 252 | text-decoration: none; 253 | } 254 | 255 | a:hover { 256 | filter: brightness(var(--hover-brightness)); 257 | text-decoration: underline; 258 | } 259 | 260 | a b, 261 | a em, 262 | a i, 263 | a strong, 264 | button { 265 | border-radius: var(--border-radius); 266 | display: inline-block; 267 | font-size: medium; 268 | font-weight: bold; 269 | line-height: var(--line-height); 270 | margin: 0.5rem 0; 271 | padding: 1rem 2rem; 272 | } 273 | 274 | button { 275 | font-family: var(--font-family); 276 | } 277 | 278 | button:hover { 279 | cursor: pointer; 280 | filter: brightness(var(--hover-brightness)); 281 | } 282 | 283 | a b, 284 | a strong, 285 | button { 286 | background-color: var(--color); 287 | border: 2px solid var(--color); 288 | color: var(--color-bg); 289 | } 290 | 291 | a em, 292 | a i { 293 | border: 2px solid var(--color); 294 | border-radius: var(--border-radius); 295 | color: var(--color); 296 | display: inline-block; 297 | padding: 1rem 2rem; 298 | } 299 | 300 | /* Images */ 301 | figure { 302 | margin: 0; 303 | padding: 0; 304 | } 305 | 306 | figure img { 307 | max-width: 100%; 308 | } 309 | 310 | figure figcaption { 311 | color: var(--color-text-secondary); 312 | } 313 | 314 | /* Forms */ 315 | 316 | button:disabled, 317 | input:disabled { 318 | background: var(--color-bg-secondary); 319 | border-color: var(--color-bg-secondary); 320 | color: var(--color-text-secondary); 321 | cursor: not-allowed; 322 | } 323 | 324 | button[disabled]:hover { 325 | filter: none; 326 | } 327 | 328 | form { 329 | border: 1px solid var(--color-bg-secondary); 330 | border-radius: var(--border-radius); 331 | box-shadow: var(--box-shadow) var(--color-shadow); 332 | display: block; 333 | max-width: var(--width-card-wide); 334 | min-width: var(--width-card); 335 | padding: 1.5rem; 336 | text-align: var(--justify-normal); 337 | } 338 | 339 | form header { 340 | margin: 1.5rem 0; 341 | padding: 1.5rem 0; 342 | } 343 | 344 | input, 345 | label, 346 | select, 347 | textarea { 348 | display: block; 349 | font-size: inherit; 350 | max-width: var(--width-card-wide); 351 | } 352 | 353 | input[type="checkbox"], 354 | input[type="radio"] { 355 | display: inline-block; 356 | } 357 | 358 | input[type="checkbox"]+label, 359 | input[type="radio"]+label { 360 | display: inline-block; 361 | font-weight: normal; 362 | position: relative; 363 | top: 1px; 364 | } 365 | 366 | input, 367 | select, 368 | textarea { 369 | border: 1px solid var(--color-bg-secondary); 370 | border-radius: var(--border-radius); 371 | margin-bottom: 1rem; 372 | padding: 0.4rem 0.8rem; 373 | } 374 | 375 | input[readonly], 376 | textarea[readonly] { 377 | background-color: var(--color-bg-secondary); 378 | } 379 | 380 | label { 381 | font-weight: bold; 382 | margin-bottom: 0.2rem; 383 | } 384 | 385 | /* Tables */ 386 | table { 387 | border: 1px solid var(--color-bg-secondary); 388 | border-radius: var(--border-radius); 389 | border-spacing: 0; 390 | display: inline-block; 391 | max-width: 100%; 392 | overflow-x: auto; 393 | padding: 0; 394 | white-space: nowrap; 395 | } 396 | 397 | table td, 398 | table th, 399 | table tr { 400 | padding: 0.4rem 0.8rem; 401 | text-align: var(--justify-important); 402 | } 403 | 404 | table thead { 405 | background-color: var(--color); 406 | border-collapse: collapse; 407 | border-radius: var(--border-radius); 408 | color: var(--color-bg); 409 | margin: 0; 410 | padding: 0; 411 | } 412 | 413 | table thead th:first-child { 414 | border-top-left-radius: var(--border-radius); 415 | } 416 | 417 | table thead th:last-child { 418 | border-top-right-radius: var(--border-radius); 419 | } 420 | 421 | table thead th:first-child, 422 | table tr td:first-child { 423 | text-align: var(--justify-normal); 424 | } 425 | 426 | table tr:nth-child(even) { 427 | background-color: var(--color-accent); 428 | } 429 | 430 | /* Quotes */ 431 | blockquote { 432 | display: block; 433 | font-size: x-large; 434 | line-height: var(--line-height); 435 | margin: 1rem auto; 436 | max-width: var(--width-card-medium); 437 | padding: 1.5rem 1rem; 438 | text-align: var(--justify-important); 439 | } 440 | 441 | blockquote footer { 442 | color: var(--color-text-secondary); 443 | display: block; 444 | font-size: small; 445 | line-height: var(--line-height); 446 | padding: 1.5rem 0; 447 | } 448 | 449 | /* Custom styles */ --------------------------------------------------------------------------------