Skip to content
This repository was archived by the owner on Nov 4, 2022. It is now read-only.

Commit e484975

Browse files
committed
fix: use the correct attribute name
1 parent 31fca04 commit e484975

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

README.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ document.loadWidget({
6464
Within the `<body>` tag add the instanceId div wherever you want this widget to render.
6565

6666
```html
67-
<div id="example-widget-1" data-attr="foobar"></div>
67+
<div id="example-widget-1" data-button-text="foobar"></div>
6868
```
6969

7070
- [See an example](https://github.com/js-widgets/example-widget/blob/master/src/public/index.html#L79) of the widget placement implementation.
@@ -85,8 +85,8 @@ document.loadWidgets({
8585
```
8686

8787
```html
88-
<div id="example-widget-1" data-attr="foo"></div>
89-
<div id="example-widget-2" data-attr="bar"></div>
88+
<div id="example-widget-1" data-button-text="foo"></div>
89+
<div id="example-widget-2" data-button-text="bar"></div>
9090
```
9191

9292
#### Parameters
@@ -109,7 +109,7 @@ import React, { Component } from 'react';
109109
class Widget extends Component {
110110
render() {
111111
return (
112-
<div className="App">{this.props.obj.getAttribute('data-attr')}</div>
112+
<div className="App">{this.props.obj.getAttribute('data-button-text')}</div>
113113
);
114114
}
115115
}
@@ -122,15 +122,15 @@ export default Widget;
122122
#### DIV attributes
123123

124124
```html
125-
<div id="example-widget-1" data-attr="Hello world!"></div>
125+
<div id="example-widget-1" data-button-text="Hello world!"></div>
126126
```
127127

128128
- [See an example](https://github.com/js-widgets/example-widget/blob/master/src/public/index.html#L79) of the widget attribute implementation.
129129

130130
#### Query string values
131131

132132
```
133-
http://localhost:3000/?data-attr=Hello%20world!
133+
http://localhost:3000/?data-button-text=Hello%20world!
134134
```
135135

136136
Note: DIV attributes are the preferred method and will always take precedence over the use of query

public/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ <h1 class="title">Widget Example</h1>
4747
</div>
4848
<div class="message-body">
4949
<!-- START: WIDGET -->
50-
<div id="example-widget" data-attr="Click here">
50+
<div id="example-widget" data-button-text="Click here">
5151
<progress class="progress is-small is-primary" max="100">0%</progress>
5252
</div>
5353
<!-- END: WIDGET -->

src/components/Widget.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function Widget({ element }) {
2323
</p>
2424
<p className="is-size-6 pb-4">
2525
<button className="button is-primary">
26-
{element.getAttribute('data-attr')}
26+
{element.getAttribute('data-button-text')}
2727
</button>
2828
</p>
2929
<p>

0 commit comments

Comments
 (0)