This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const getComments = () => { | |
return onSnapshot(collection(db, 'comments'), (value) => { | |
const comments = value.docs.reduce((acc, item) => { | |
if (id.id === item.data().coinId) { | |
acc.push({ ...item.data(), id: item.id }) | |
} | |
return acc; | |
}, []) | |
setComments(comments); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const FONT_FACES = `@font-face { | |
font-display: auto; | |
font-family: "Elections-Publico"; | |
font-style: normal; | |
font-weight: 800; | |
src: url("https://some-url.com/fonts/Publico-Bold.woff") format("woff"); | |
} | |
@font-face { | |
font-display: auto; | |
font-family: "Elections-Akkurat-Mono"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CandidateImage extends HTMLElement { | |
connectedCallback() { | |
this.shadow = this.attachShadow({ mode: 'open' }); | |
this.setupImage(); | |
this.addWinnerText(); | |
// Add our styles | |
this.createStyles(); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CandidateImage extends HTMLElement { | |
connectedCallback() { | |
this.shadow = this.attachShadow({ mode: 'open' }); | |
// Create an image | |
const image = new Image(); | |
// Find the right image for the provided name | |
if (this.getAttribute('name') === 'pete') { | |
image.src = 'https://cdn-candidates.com/pete.jpg'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CandidateImage extends HTMLElement { | |
connectedCallback() { | |
this.shadow = this.attachShadow({ mode: 'open' }); | |
// Create an image | |
const image = new Image(); | |
// Find the right image for the provided name | |
if (this.getAttribute('name') === 'pete') { | |
image.src = 'https://cdn-candidates.com/pete.jpg'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CandidateImage extends HTMLElement { | |
connectedCallback() { | |
this.shadow = this.attachShadow({ mode: 'open' }); | |
// Create an image | |
const image = new Image(); | |
image.src = 'https://cdn-candidates.com/bernie.jpg'; | |
// We can use appendChild just like we do the normal document | |
this.shadow.appendChild(image); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CandidateImage extends HTMLElement { | |
connectedCallback() { | |
console.log('Adding a candidate!'); | |
this.innerHTML = '<img src="https://cdn-candidates.com/bernie.jpg" />'; | |
} | |
} | |
/** | |
* Register our custom element | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CandidateImage extends HTMLElement { | |
connectedCallback() { | |
console.log('Adding a candidate!'); | |
this.innerHTML = '<img src="https://cdn-candidates.com/bernie.jpg" />'; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// These are the mocked version of some firestore methods | |
// And we want to assert they are called correctly | |
const { | |
mockCollection, | |
mockGet, | |
mockWhere, | |
} = require('firestore-jest-mock/mocks/firestore'); | |
const { mockFirebase } = require('firestore-jest-mock'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const firebase = require('firebase'); | |
function maybeGetEventsByState(state) { | |
const db = firebase.firestore(); | |
const query = db.collection('events'); | |
if (state) { | |
query = query.where('state', '==', state); | |
} |
NewerOlder