forked from vasanthk/react-bits
-
Notifications
You must be signed in to change notification settings - Fork 0
/
02.toggle-ui-elements.jsx
38 lines (35 loc) · 1014 Bytes
/
02.toggle-ui-elements.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/**
* Handling minor UX variations in the component by toggling ON/OFF features.
*
* Modify the component to take in a prop to control it’s behavior.
*
* Gotcha:
* Easy to overuse this idea by adding props for every variation.
* Only add in props for features specific to the current feature that the component.
* Basically, not violate the Single Responsibility Principle.
*
* @Reference:
* https://speakerdeck.com/vasa/building-multitenant-ui-with-react-dot-js
*
*/
/**
* Example
* Show/Hide password feature in Login form
*/
class PasswordField extends Component {
render() {
const {password, showHidePassword, showErrorOnTop, showLabels, shouldComplyAda} = this.props;
return (
<div>
<Password
field={password}
label="Password"
showErrorOnTop={showErrorOnTop}
placeholder={shouldComplyAda ? "" : "Password"}
showLabel={showLabels}
showHidePassword={showHidePassword}
/>
</div>
);
}
}