| Conditions | 1 |
| Total Lines | 88 |
| Code Lines | 80 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | import React, { Component, createRef } from "react"; |
||
| 69 | |||
| 70 | public render(): React.ReactElement { |
||
| 71 | const { id, title, subtitle, openText, confirmText, children } = this.props; |
||
| 72 | |||
| 73 | const { visible } = this.state; |
||
| 74 | |||
| 75 | return ( |
||
| 76 | <> |
||
| 77 | <div data-c-alignment="center"> |
||
| 78 | <button |
||
| 79 | className="modal-info__open-button" |
||
| 80 | data-c-dialog-id={id} |
||
| 81 | data-c-dialog-action="open" |
||
| 82 | type="button" |
||
| 83 | onClick={this.handleOpen} |
||
| 84 | > |
||
| 85 | {openText} |
||
| 86 | </button> |
||
| 87 | </div> |
||
| 88 | |||
| 89 | <div data-c-dialog-overlay={visible && "active"} /> |
||
| 90 | |||
| 91 | <div |
||
| 92 | aria-hidden={visible} |
||
| 93 | aria-describedby={`${id}-description`} |
||
| 94 | aria-labelledby={`${id}-title`} |
||
| 95 | data-c-dialog="" |
||
| 96 | data-c-dialog-id={id} |
||
| 97 | data-c-padding="top(double) bottom(double)" |
||
| 98 | role="dialog" |
||
| 99 | ref={this.divElement} |
||
| 100 | > |
||
| 101 | <div data-c-background="white(100)" data-c-radius="rounded"> |
||
| 102 | <div |
||
| 103 | data-c-padding="normal" |
||
| 104 | data-c-border="bottom(thin, solid, black)" |
||
| 105 | data-c-background="black(90)" |
||
| 106 | className="modal-info__header" |
||
| 107 | > |
||
| 108 | <h5 |
||
| 109 | data-c-font-size="h4" |
||
| 110 | data-c-colour="white" |
||
| 111 | id={`${id}-title`} |
||
| 112 | > |
||
| 113 | {title} |
||
| 114 | </h5> |
||
| 115 | |||
| 116 | {subtitle && ( |
||
| 117 | <span data-c-font-size="h5" data-c-margin="top(half)"> |
||
| 118 | {subtitle} |
||
| 119 | </span> |
||
| 120 | )} |
||
| 121 | |||
| 122 | <button |
||
| 123 | className="modal-info__close-button" |
||
| 124 | data-c-dialog-action="close" |
||
| 125 | data-c-dialog-id={id} |
||
| 126 | type="button" |
||
| 127 | onClick={this.handleClose} |
||
| 128 | > |
||
| 129 | <i className="fas fa-times" /> |
||
| 130 | </button> |
||
| 131 | </div> |
||
| 132 | |||
| 133 | <div |
||
| 134 | data-c-border="bottom(thin, solid, black)" |
||
| 135 | data-c-padding="normal" |
||
| 136 | > |
||
| 137 | <div id={`${id}-description`}>{children}</div> |
||
| 138 | </div> |
||
| 139 | |||
| 140 | <div data-c-padding="normal"> |
||
| 141 | <div data-c-alignment="center"> |
||
| 142 | <button |
||
| 143 | data-c-button="solid(go)" |
||
| 144 | data-c-radius="rounded" |
||
| 145 | data-c-dialog-action="close" |
||
| 146 | data-c-dialog-id={id} |
||
| 147 | type="button" |
||
| 148 | onClick={this.handleClose} |
||
| 149 | > |
||
| 150 | {confirmText} |
||
| 151 | </button> |
||
| 152 | </div> |
||
| 153 | </div> |
||
| 154 | </div> |
||
| 155 | </div> |
||
| 156 | </> |
||
| 157 | ); |
||
| 162 |