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
requestInventory = (inventoryItems) => { | |
const [first] = inventoryItems; | |
inventoryItems = inventoryItems.slice(1); | |
return { first, inventoryItems }; | |
}; |
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
requestInventory = () => { | |
const [first] = this.inventoryItems; | |
this.inventoryItems = this.inventoryItems.slice(1); | |
return first; | |
}; |
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
processInventory = (widget) => { | |
displayLoader(); | |
switch (this.action) { | |
case "REQUEST": { | |
return this.requestInventory(); | |
} | |
case "CLEAR": { | |
return this.clearInventory(); | |
} | |
case "ADD": { |
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 { displayLoader } from "./loader"; | |
export default class InventoryManager { | |
inventoryItems = []; | |
action; | |
processInventory = (widget) => { | |
displayLoader(); | |
switch (this.action) { | |
case "REQUEST": { |
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 { useSharedNotes } from "./notesState"; | |
import "./styles.css"; | |
export default function Content() { | |
const { notes } = useSharedNotes(); | |
return ( | |
<div className="content"> | |
{notes.map((note, index) => ( | |
<p key={index}>{note}</p> | |
))} |
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 { useState } from "react"; | |
import { useSharedNotes } from "./notesState"; | |
export default function Header() { | |
const [value, setValue] = useState(""); | |
const { addNote, clear } = useSharedNotes(); | |
const handleChange = (e) => { | |
setValue(e.target.value); | |
}; |
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 { useState, useEffect } from "react"; | |
import { BehaviorSubject } from "rxjs"; | |
let subject = null; | |
export const getNotes = () => { | |
if (!subject) { | |
return undefined; | |
} |
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
<Dropdown text="File"> | |
<Dropdown.Menu> | |
<Dropdown.Item text="New" /> | |
<Dropdown.Item text="Open..." description="ctrl + o" /> | |
<Dropdown.Item text="Save as..." description="ctrl + s" /> | |
</Dropdown.Menu> | |
</Dropdown> |
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 useAccordionContext = () => useContext(AccordionContext); | |
const AccordionHeaderContainer = styled.div` | |
padding: 8px 16px; | |
background: #f5f5f5; | |
border-top: 1px solid #d3d3d3; | |
cursor: pointer; | |
`; | |
const AccordionPanelContainer = styled.div<{ height: string; padding: string }>` |