This file contains hidden or 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 the radio | |
| import { radio } from "./broker.js" | |
| // Listen on a channel | |
| radio.listen("potteryCreated", data => { | |
| // Use the data that was broadcast on the `potteryCreated` channel | |
| const firedPottery = firePottery(data.piece, 2100) | |
| // Broadcast on another channel with new data | |
| radio.broadcast("potteryFired", { firedPottery }) |
This file contains hidden or 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 dadJokes = [ | |
| { | |
| "id": 1, | |
| "question": "What did one pirate say to the other when he beat him at chess?", | |
| "answer": "Checkmatey" | |
| }, | |
| { | |
| "id": 2, | |
| "question": "Why did I quit my job at the coffee shop the other day?", | |
| "answer": "It was just the same old grind over and over." |
This file contains hidden or 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 "./AnimalCard.css" | |
| import React from "react" | |
| export default props => { | |
| return ( | |
| <li> | |
| <div className="card-body"> | |
| <div className="animal__header"> | |
| <h5 className="card-title"> |
This file contains hidden or 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, useContext, useEffect, useRef } from "react" | |
| import Animal from "./Animal" | |
| import AnimalDialog from "./AnimalDialog" | |
| import { AnimalContext } from "../providers/AnimalProvider" | |
| import useModal from "../../hooks/ui/useModal" | |
| import "./AnimalList.css" | |
| export default (props) => { | |
| const { toggleDialog, modalIsOpen } = useModal("#dialog--animal") |
This file contains hidden or 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 { useState } from "react" | |
| const useModal = (selector) => { | |
| const [modalIsOpen, setIsOpen] = useState(false) | |
| function toggleDialog() { | |
| setIsOpen(!modalIsOpen) | |
| if (modalIsOpen) { | |
| document.querySelector(`${selector}`).removeAttribute("open") |
This file contains hidden or 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 from "react" | |
| export default ({toggleDialog, animal}) => { | |
| return ( | |
| <dialog id="dialog--animal"> | |
| <h2> | |
| Medical History for {animal.name} | |
| </h2> | |
| { | |
| animal.treatments.map(t => ( |
This file contains hidden or 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 accounts = [ | |
| { | |
| "last_login": { | |
| "ip4": "201.154.17.193", | |
| "date_time": "Sat Oct 22 07:25:08 UTC 1983" | |
| }, | |
| "id": "cold-brook-65", | |
| "gender": "male", | |
| "email": "[email protected]", | |
| "account_age": 3 |
This file contains hidden or 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
| using System; | |
| using System.Collections.Generic; | |
| using System.Linq; | |
| // Define a bank | |
| public class Bank | |
| { | |
| public string Symbol { get; set; } | |
| public string Name { get; set; } | |
| } |
This file contains hidden or 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 ArticleMap = new WeakMap() | |
| const Articles = Object.create(null, { | |
| "init": { | |
| value: function () { | |
| ArticleMap.set(this, {}) | |
| } | |
| }, | |
| "condensed": { |
This file contains hidden or 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
| # | |
| #!/bin/bash | |
| # | |
| # To create a simple project setup with just an HTML file, a JavaScript file, and a CSS file | |
| # just pass the string "simple" as the first argument | |
| # ex: projectsetup.sh simple | |
| # | |
| # - All source code will be created in the src sub-directory | |
| # - If using json-server, it will be configured and started in the api sub-directory | |
| # - If distributing code, grunt task will be configured to create dist sub-directory |