Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lions - Jessica A. #115

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"python.testing.pytestArgs": [
"node_modules"
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true
}
Comment on lines +1 to +7

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think these are correct settings - we're not using Python. Also, your individual VS Code settings should not be committed. They should be added to the .gitignore if needed.

7 changes: 5 additions & 2 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
import React from 'react';
import React, { useState } from 'react';
import './App.css';
import chatMessages from './data/messages.json';
import ChatLog from './components/ChatLog';

const App = () => {
const [chatLogList, setchatLogList] = useState([]);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The state should start from the chatMessages, not empty.

return (
<div id="App">
<header>
<h1>Application title</h1>
</header>
<main>
<ChatLog chatLogList={chatMessages} />

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be using the state instead of the messages directly

{/* Wave 01: Render one ChatEntry component
Wave 02: Render ChatLog component */}
Wave 02: Render ChatLog component */}{' '}
</main>
</div>
);
Expand Down
28 changes: 23 additions & 5 deletions src/components/ChatEntry.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,40 @@
import React from 'react';
import './ChatEntry.css';
import PropTypes from 'prop-types';
import TimeStamp from './TimeStamp.js';
import { useState } from 'react';

const ChatEntry = (props) => {
const sender = props.sender;
const senderBody = props.body;
const timeStamp = props.timeStamp;
Comment on lines 7 to +10

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the future consider destructuring props in the constructor.

const [isLiked, setIsLiked] = useState(false);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This type of state should be lifted up


const changeColorHeart = () => {
setIsLiked(!isLiked);
};

return (
<div className="chat-entry local">
<h2 className="entry-name">Replace with name of sender</h2>
<h2 className="entry-name">{sender}</h2>
<section className="entry-bubble">
<p>Replace with body of ChatEntry</p>
<p className="entry-time">Replace with TimeStamp component</p>
<button className="like">🤍</button>
<p>{senderBody}</p>
<div className="entry-time">
<TimeStamp time={timeStamp} />
</div>

<button className="like" onClick={changeColorHeart}>
{isLiked ? <div>❤️</div> : <div>🤍</div>}
</button>
</section>
</div>
);
};

ChatEntry.propTypes = {
//Fill with correct proptypes
sender: PropTypes.string.isRequired,
body: PropTypes.string.isRequired,
timeStamp: PropTypes.string.isRequired,
};

export default ChatEntry;
36 changes: 36 additions & 0 deletions src/components/ChatLog.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import React from 'react';
import './ChatLog.css';
import PropTypes from 'prop-types';
import ChatEntry from './ChatEntry';

const ChatLog = (props) => {
const chatLogComponents = [];
const chatLogList = props.chatLogList;

for (const chat of chatLogList) {
chatLogComponents.push(
<ChatEntry
key={chat.id}
sender={chat.sender}
body={chat.body}
timeStamp={chat.timeStamp}
/>
);
}

return <div>{chatLogComponents}</div>;
};

ChatLog.propTypes = {
chatLogList: PropTypes.arrayOf(
PropTypes.shape({
id: PropTypes.number.isRequired,
sender: PropTypes.string.isRequired,
body: PropTypes.string.isRequired,
timeStamp: PropTypes.string.isRequired,
liked: PropTypes.bool.isRequired,
})
),
};
Comment on lines +24 to +34

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure to make the overall array prop as required.


export default ChatLog;
13 changes: 4 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3864,15 +3864,10 @@ caniuse-api@^3.0.0:
lodash.memoize "^4.1.2"
lodash.uniq "^4.5.0"

caniuse-lite@^1.0.0, caniuse-lite@^1.0.30001332:
version "1.0.30001344"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001344.tgz#8a1e7fdc4db9c2ec79a05e9fd68eb93a761888bb"
integrity sha512-0ZFjnlCaXNOAYcV7i+TtdKBp0L/3XEU2MF/x6Du1lrh+SRX4IfzIVL4HNJg5pB2PmFb8rszIGyOvsZnqqRoc2g==

caniuse-lite@^1.0.30001400, caniuse-lite@^1.0.30001426:
version "1.0.30001439"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001439.tgz#ab7371faeb4adff4b74dad1718a6fd122e45d9cb"
integrity sha512-1MgUzEkoMO6gKfXflStpYgZDlFM7M/ck/bgfVCACO5vnAf0fXoNVHdWtqGU+MYca+4bL9Z5bpOVmR33cWW9G2A==
caniuse-lite@^1.0.0, caniuse-lite@^1.0.30001332, caniuse-lite@^1.0.30001400, caniuse-lite@^1.0.30001426:
version "1.0.30001441"
resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001441.tgz"
integrity sha512-OyxRR4Vof59I3yGWXws6i908EtGbMzVUi3ganaZQHmydk1iwDhRnvaPG2WaR0KcqrDFKrxVZHULT396LEPhXfg==

case-sensitive-paths-webpack-plugin@^2.4.0:
version "2.4.0"
Expand Down