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
<script src="https://api.trello.com/1/client.js?key=MY_KEY"></script> | |
<script type="text/javascript"> | |
Trello.authorize({ | |
name: "My site", | |
scope: { | |
read: true, | |
write: false | |
}, | |
expiration: "never", |
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
getBoards() { | |
return new Promise((resolve, reject) => { | |
Trello.get( | |
"/members/me/boards/", | |
boards => resolve(boards), | |
error => reject(new Error(`Getting boards failed: ${error}`)) | |
); | |
}); | |
} |
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
let boards = await trelloData.getBoards(); | |
boards = await Promise.all( | |
boards.map(async board => { | |
const lists = await trelloData.getLists(board.id, true); | |
board.lists = lists; | |
return board; | |
}) | |
); |
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 filterCards = (boards, filter) => | |
boards.reduce((result, board) => { | |
const cardsResult = board.lists.reduce((cards, list) => { | |
if ( | |
board.closed === false && | |
list.closed === false && | |
(filter.length === 0 || | |
list.name.toLowerCase() === filter.toLowerCase()) | |
) { | |
return cards.concat(list.cards.filter(card => card.closed === false)); |
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
<form | |
name="register" | |
data-netlify="true" | |
data-netlify-honeypot="sneaky-sneaky" | |
onSubmit={handleSubmit} | |
> | |
<input | |
type="text" | |
name="email" | |
placeholder="Enter your email" |
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 [email, setEmail] = useState("") | |
const handleSubmit = e => { | |
fetch("/", { | |
method: "POST", | |
headers: { "Content-Type": "application/x-www-form-urlencoded" }, | |
body: formEncode({ "form-name": "register", email: email }), | |
}) | |
.then(() => alert("Success!")) | |
.catch(error => alert(error)) |
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
import React, { useState } from "react" | |
const formEncode = data => { | |
return Object.keys(data) | |
.map(key => encodeURIComponent(key) + "=" + encodeURIComponent(data[key])) | |
.join("&") | |
} | |
const RegistrationForm = () => { | |
const [email, setEmail] = useState("") |
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
override func viewDidLoad() { | |
super.viewDidLoad() | |
contentView.addSubview(collectionView) | |
collectionView.topAnchor.constraint(equalTo: self.contentView.topAnchor, constant: 0).isActive = true | |
collectionView.bottomAnchor.constraint(equalTo: self.contentView.bottomAnchor, constant: 0).isActive = true | |
collectionView.leadingAnchor.constraint(equalTo: self.contentView.leadingAnchor, constant: 0).isActive = true | |
collectionView.trailingAnchor.constraint(equalTo: self.contentView.trailingAnchor, constant: 0).isActive = true | |
} |
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
var itemsPerRow: CGFloat = 3 | |
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { | |
guard let flow = collectionViewLayout as? UICollectionViewFlowLayout else { | |
fatalError("only flow layout is supported") | |
} | |
let paddingSpace = flow.sectionInset.left + flow.sectionInset.right + (minimumInteritemSpacing * itemsPerRow) | |
let availableWidth = collectionView.frame.width - paddingSpace | |
let widthPerItem = availableWidth / itemsPerRow |
OlderNewer