Continue learning React.
Read:
As in Unit 4, I strongly recommend that you type in the examples and try them in a browser. This program is more complex than the previous one, be sure to allow enough time to complete it.
Create a page similar to the following (example is for Valentine's Day, you can choose some other theme). Figure 1 shows a greeting card with default settings.
Figure 2 shows the same card after it has been "customized" by making selections in the Card Definition box.
For simplicity, I set up variables to contain the hard-coded color choices.
var foregroundColors = ["#00FFFF","#FF7F50","#FFD700", "#FFF", "#000"];
var backgroundColors = ["#0000FF","#DC143C","#20B2AA", "#FFF", "#000"];
Potentially helpful links for dealing with the Ascii Art:
The structure of this program will be similar to the last example on
the Events in React page (the code
that includes increase(e)
). Be sure to
understand that example before you begin to code! A few
specific hints:
CounterParent
component to contain the
"state" of the application (the counter). You will need a component to
maintain your program's "state" - the to/from fields and colors. I called
my component CardCreator
(your name may vary, but note that
this is separate from GreetingCard and CardDefinition)Counter
component to display the "state" (the
counter). In your program, the GreetingCard
component will
display the "state" - i.e., the updated greeting card. CardDefinition
- to
allow the user to update the state.increase(e)
method called when the button is pressed
is part of CounterParent
, bind
method ensures the variable updated
by increase(e)
is part of CounterParent
, NOT
the button which triggered the event,increase(e)
method is used as the onclick
handler, and shiftKey
)e.target
. You should draw your component design on paper before you begin to code (maybe review the design process from chapter 5). If you have questions, post on piazza or email me.
Name your file [YourLastName].html and submit on Canvas.
Because this assignment is more complex, I will assign two grades:
For each of these grades, programs that meet all requirements will receive a grade of A. Programs missing one or two minor requirements will receive A-. Programs missing more substantial requirements will be graded accordingly.
NOTE: A program that does not update at all will receive a failing grade for correct behavior - so be sure that you leave plenty of time to ensure at least some of the fields will update.