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
<section class="card"> | |
<div class="card--content"></div> | |
<div class="card--content"></div> | |
<div class="card--content"></div> | |
<div class="card--content"></div> | |
<div class="card--content"></div> | |
<div class="card--content"></div> | |
<div class="card--content"></div> | |
<div class="card--content"></div> | |
<div class="card--content"></div> |
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
html, | |
body { | |
width: 100%; | |
height: 100%; | |
} | |
body { | |
background-color: #8e44ad; | |
margin: 0; | |
display: flex; |
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
.card { | |
background-color: #fff; | |
min-width: 100%; | |
min-height: 200px; | |
} |
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
.card--content { | |
background-color: #e74c3c; | |
min-width: 200px; | |
margin: 5px; | |
} |
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
export function updateCardTextReducer(cardId, event) { | |
event.persist(); | |
return function updateCard(state) { | |
const {cards, cardIds} = state; | |
const index = cardIds.indexOf(cardId); | |
const card = getCardById(cardId, cards); | |
const newCardUpdatedText = { | |
...card, | |
text: event.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
export const DEFAULT_STATE = { | |
cards: [ | |
{ | |
id: 1234, | |
text: defaultTextForCards, | |
isActiveCard: true | |
}, | |
{ | |
id: '12d3x4', | |
text: defaultTextForCards, |
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
export function getCardById (id, cards) { | |
const cardArr = cards.filter(card => { | |
return card.id === id; | |
}); | |
return cardArr[0]; | |
} |
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
// An example of an action | |
const action = { | |
type: "WITHDRAW_MONEY", | |
amount: "$10,000" | |
} | |
// A basic reducer. Takes in two parameters: state, and action. | |
const reducer = (state, action) => { | |
return state; | |
}; |
OlderNewer