nss-day-cohort-24 / chatty-pineapple-metal

chatty-pineapple-metal created by GitHub Classroom
0 stars 1 forks source link

Chatty Group Project

Setup

Every teammate copy and run the following commands in the host machine terminal.

mkdir -p ~/workspace/group-projects && cd $_
git clone [Github Classroom repo URL]
cd [repo name]

Requirements

The users for this chat application are NSS students. You must interview at least two students and come up with a persona and challenge statement that your application will be built for.

Your group will use the following style guide for this application. Make sure you sketch the screens as part of your planning process. The design of the final interface is up to your group.

Make sure you spend time defining MVP and creating a plan to reach that goal. Use Github projects to create issues/tasks to track the progress of your project.

Technical Requirements

  1. Sass
  2. Bootstrap
  3. Grunt
  4. Browserify
  5. JSHint
  6. JSON
  7. XHR
  8. Javascript
  9. HTML

Navigation bar

  1. Create an element to serve as the navigation bar for your application.
  2. Create an element to hold the logo for your application. It can be as simple as text, but if you want to find an image, that's fine.
  3. Create a input field for a user to enter in a message.
  4. Add an event listener for "keypress" and detect when then return key has been pressed in the message field.
  5. When return key is detected, you'll create a new message (see details below).
  6. Create a button to clear all messages.
  7. When the user clicks the clear messages button, all current chat messages should be removed from the application.
  8. If there are no messages, then the clear messages button should be disabled (see example above).
  9. The navigation bar should remain at the top of the screen, even if the contents of the page start to scroll.

Options

  1. Create two checkboxes below the message input field. One labeled "Dark theme" and the other labeled "Large text".
  2. When the user clicks on the dark theme checkbox, change the background color of your application to a darker shade, and the font color for messages should be light.
  3. If the user unchecks the box, the background color should change back to a lighter color with darker color text for messages.
  4. Make sure for both themes, you stick to the provided style guide.

Messages

  1. When the page is first loaded, you must load 5 messages from a local JSON file and pre-fill a message area <div> below the input field that will also hold all new messages as they get created.
  2. When the user presses the return key in the message field, the new message should be inserted into the message area.
  3. The message should have a button displayed after it with the text "Delete" inside of it.
  4. When the delete button next to a message is clicked, only that message should be removed from the DOM.

Modular Code

Create multiple private modules, using Browserify, that perform the following functions.

  1. One module should load the JSON file and returns the array of objects.
  2. One module should contain a function that accepts an element id, and the user message, and then add the user's message - along with the delete button - to the specified parent element. Each message should be stored in a private array in this module. This module should also expose a function to read all messages, and delete a single message.
  3. One module should accept a message element id and then remove the correct element from the DOM. This module should also remove the corresponding message from the private array that was created in the previous module.

Helpful hints

Adding listeners to dynamically created elements

When you add a DOM element to your page with JavaScript, you cannot add a listener to them directly in your code with addEventListener. This is because the element didn't exist when your JavaScript file got parsed and executed by the browser when it loaded. What you need to do is listen for the event on the <body> element, and then inspect what the target of the event is (i.e. which element the user actually performed the action on).

document.querySelector("body").addEventListener("click", function(event) {
  console.log(event);

  // Handle the click event on any li
  if (event.target.tagName.toLowerCase() === "li") {
    console.log("You clicked on an <li> element");
  }

  // Handle the click event on any DOM element with a certain class
  if (event.target.className === "article-section") {
    console.log("You clicked on an `article-section` element");
  }

  // Inspect the `id` property of the event target
  if (event.target.id === "page-title") {
    console.log("You clicked on the page-title element");
  }
});

Setting element attributes

You can use JavaScript to set any attribute on a DOM element. You've seen how to add/remove classes with classList.add(), classList.remove(), and classList.toggle(), but you can also add id, href, src, or any other attribute.

Here's an example of how to add a disabled attribute to a button in the DOM.

<button class="clear-messages">Clear messages</button>
// This will disable the first button with a class of "button-message"
document.getElementsByClassName("clear-messages")[0].setAttribute("disabled", true);

Bonus criteria

For you overachievers, once you've completed the basic criteria, take a stab at these.

Multiple JSON files

Instead of having one JSON file with five messages in it, break each message into its own JSON file. How do you handle loading them in succession?

Editing

  1. Let users edit an existing message. Add an edit button next to the delete button that, when clicked, will take the message and put it back in the message input at the top.
  2. Once user edits the message and presses the return key again, the message text in the list should be updated.

Custom themes

  1. Add a button/link to the UI labeled "Change Theme".
  2. Remove the existing elements for changing the theme.
  3. When user click on Change Theme element, show a Bootstrap modal dialog box.
  4. Inside the modal, show two color picker fields - one for background color and one for font color.
  5. Add a Save and Cancel button to modal.
  6. When user clicks Save apply the chosen colors.

Multiple users

  1. Create an object in your JavaScript that holds an array of names (see example below).
  2. Next to the message input box, there should be a radio button group for each name in the list.
  3. When a user enters a message, it should be prepended with the chosen user's name, in bold text.
  4. Keep in mind that this will likely change the structure of your JSON file since the pre-loaded messages have to have this information on them.
// User object
var users = {
  names: ["Xavier", "Joanna", "Mackenzie", "Gunter", "Iveta", "Sven"];
};

Message limit

  1. Only show the last 20 messages.

Timestamp

  1. Put a timestamp on each message.
  2. Again, this will change the structure of your JSON file.

Presentations

  1. Each group's presentation should be no more than seven minutes (plan and practice so you are ready to go).
  2. Your presentation must include: challenge statement, persona, demo of your application, lessons learned about development & design.
  3. Present like you are presenting to potential new clients (think: Shark Tank).