-
-
Notifications
You must be signed in to change notification settings - Fork 1
Create component with dynamic style
Vetrivel edited this page Jan 24, 2020
·
4 revisions
-
Select
Components panel -> "HelloWorldComponent"
. -
Edit
Editor panel -> Component markup field
from<h1 id="header">{state.content}</h1>
to<h1 className={state.status} id="header">{state.content}</h1>
. -
Edit state in
Editor panel -> Component state field
from{"content":"Hello world"}
to{"content":"Hello world", "status":"valid"}
. -
Type
.valid{border: 1px solid green;}
inEditor panel -> Component css field
. -
Click
Editor panel -> Save button
. - Reload.
-
Click
Components panel -> HelloWorldComponent
. Notice preview has "Hello world" with green border. -
Select
Settings panel -> h1-header check box
. -
Edit
Settings panel -> Events -> Existing -> onClick -> reducer
fromstate.content = "Hi World"
tostate.content = "Hi World"; state.status = "invalid"
. -
Click
Settings panel -> Save button
. -
Edit
Editor panel -> Component css field
from.valid{border: 1px solid green;}
to.valid{border: 1px solid green;} .invalid{border: 1px solid red;}
. Now we have two classes created. -
Click
Editor panel -> Save button
. - Reload.
-
Click
Components panel -> HelloWorldComponent
. Preview panel should show "Hello World". -
Click
Preview panel -> "Hello World"
. "Hello world" with green border should change to "Hi World" with red border.
Sidebar