Skip to content

Commit cffac43

Browse files
committed
simplify API
1 parent 4a3d6ab commit cffac43

1 file changed

Lines changed: 9 additions & 26 deletions

File tree

components/dash-core-components/src/components/Clipboard.react.js

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -128,32 +128,24 @@ export default class Clipboard extends React.Component {
128128
}
129129

130130
render() {
131-
const {
132-
id,
133-
title,
134-
className,
135-
style,
136-
copied_className,
137-
copied_style,
138-
children,
139-
copied_children,
140-
} = this.props;
131+
const {id, title, className, style, children, copied_children} =
132+
this.props;
141133

142134
const isCopied = this.state.copied;
143135

144-
const content = isCopied
136+
const button_children = isCopied
145137
? copied_children ?? <FontAwesomeIcon icon={faCheckCircle} />
146138
: children ?? <FontAwesomeIcon icon={faCopy} />;
147139

148140
return clipboardAPI ? (
149141
<LoadingElement
150142
id={id}
151143
title={title}
152-
style={isCopied ? copied_style ?? style : style}
153-
className={isCopied ? copied_className ?? className : className}
144+
style={style}
145+
className={className}
154146
onClick={this.onClickHandler}
155147
>
156-
{content}
148+
{button_children}
157149
</LoadingElement>
158150
) : null;
159151
}
@@ -173,12 +165,12 @@ Clipboard.propTypes = {
173165
id: PropTypes.string,
174166

175167
/**
176-
* The children of this component. By default copy icon
168+
* Children rendered inside the Clipboard button before copying. By default, a copy icon.
177169
*/
178170
children: PropTypes.node,
179171

180172
/**
181-
* The children of this component displayed while copying. By default checked icon
173+
* Children rendered inside the Clipboard button after the value has been copied. By default, a check icon.
182174
*/
183175
copied_children: PropTypes.node,
184176

@@ -195,7 +187,7 @@ Clipboard.propTypes = {
195187
content: PropTypes.string,
196188

197189
/**
198-
* The number of times copy button was clicked
190+
* The number of times Clipboard button was clicked
199191
*/
200192
n_clicks: PropTypes.number,
201193

@@ -218,15 +210,6 @@ Clipboard.propTypes = {
218210
* The class name of the icon element
219211
*/
220212
className: PropTypes.string,
221-
/**
222-
* The icon's styles while copying
223-
*/
224-
copied_style: PropTypes.object,
225-
226-
/**
227-
* The class name of the icon element while copying
228-
*/
229-
copied_className: PropTypes.string,
230213

231214
/**
232215
* Dash-assigned callback that gets fired when the value changes.

0 commit comments

Comments
 (0)