Skip to content

Commit ece08ed

Browse files
authored
Merge pull request #178 from wsheung/143
Added custom placeholder option
2 parents 40c82bb + 362a5a1 commit ece08ed

File tree

5 files changed

+11
-3
lines changed

5 files changed

+11
-3
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ module API. Options include:
128128
{
129129
container: '#some-query-selector'; // container to attach to
130130
APIUrl: 'https://www.example.com/.netlify/functions/identity'; // Absolute url to endpoint. ONLY USE IN SPECIAL CASES!
131+
namePlaceholder: 'some-placeholder-for-Name'; // custom placeholder for name input form
131132
}
132133
```
133134

src/components/app.js

+1
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ class App extends Component {
117117
message={store.message}
118118
saving={store.saving}
119119
onSubmit={this.handleUser}
120+
namePlaceholder={store.namePlaceholder}
120121
/>
121122
{!store.user && page.link && store.gotrue && (
122123
<button

src/components/forms/user.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export default class UserForm extends Component {
1818
};
1919

2020
render() {
21-
const { page, message, saving } = this.props;
21+
const { page, message, saving, namePlaceholder } = this.props;
2222
const { name, email, password } = this.state;
2323

2424
return (
@@ -36,7 +36,7 @@ export default class UserForm extends Component {
3636
type="name"
3737
name="name"
3838
value={name}
39-
placeholder="Name"
39+
placeholder={namePlaceholder ? namePlaceholder : "Name"}
4040
autocapitalize="off"
4141
required
4242
oninput={this.handleInput}

src/netlify-identity.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ function runRoutes() {
184184
}
185185

186186
function init(options = {}) {
187-
const { APIUrl, logo = true } = options;
187+
const { APIUrl, logo = true, namePlaceholder } = options;
188188
const controlEls = document.querySelectorAll(
189189
"[data-netlify-identity-menu],[data-netlify-identity-button]"
190190
);
@@ -205,6 +205,7 @@ function init(options = {}) {
205205

206206
store.init(instantiateGotrue(APIUrl));
207207
store.modal.logo = logo;
208+
store.setNamePlaceholder(namePlaceholder);
208209
iframe = document.createElement("iframe");
209210
iframe.id = "netlify-identity-widget";
210211
iframe.onload = () => {

src/state/store.js

+5
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,18 @@ const store = observable({
1212
saving: false,
1313
invite_token: null,
1414
email_change_token: null,
15+
namePlaceholder: null,
1516
modal: {
1617
page: "login",
1718
isOpen: false,
1819
logo: true
1920
}
2021
});
2122

23+
store.setNamePlaceholder = action(function setNamePlaceholder(namePlaceholder) {
24+
store.namePlaceholder = namePlaceholder;
25+
});
26+
2227
store.startAction = action(function startAction() {
2328
store.saving = true;
2429
store.error = null;

0 commit comments

Comments
 (0)