Skip to content

Commit 275281e

Browse files
author
Nicolas Garnier
committed
Releasing v1.1.0
1 parent d8d293b commit 275281e

File tree

9 files changed

+536
-17
lines changed

9 files changed

+536
-17
lines changed

dist/FirebaseAuth.js

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/FirebaseAuth.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/README.md

Lines changed: 43 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,25 @@ npm install --save firebase
2222
```
2323

2424
In your app:
25-
1. Import the `FirebaseAuth` component from `react-firebaseui` and import `firebase`.
25+
1. Import the `FirebaseAuth` or the `StyledFirebaseAuth` component from `react-firebaseui` and import `firebase`.
2626
2. Configure Firebase as described in [the Firebase Docs](https://firebase.google.com/docs/web/setup).
2727
3. Write a Firebase UI configuration as described in [firebase/firebaseui-web](https://github.com/firebase/firebaseui-web#configuration).
2828
4. Use the `FirebaseAuth` component in your template passing it the **Firebase UI configuration** and a **Firebase Auth instance**.
2929

3030

31-
### Using `FirebaseAuth` with a redirect
31+
### `FirebaseAuth` vs `StyledFirebaseAuth`
32+
33+
There are two components that allow you to add FirebaseUI auth to your application: `FirebaseAuth` and `StyledFirebaseAuth`. The difference is that `FirebaseAuth` has a reference to the Firebase UI CSS (it `requires` the CSS) whereas `StyledFirebaseAuth` includes the CSS directly in its built. For simplicity you should use `StyledFirebaseAuth` and for better performances and build sizes you should use `FirebaseAuth`. `FirebaseAuth` is meant to be used with a CSS/style loader as part of yor webpack built configuration. See the [Packing your app](#packing) section
34+
35+
36+
### Using `StyledFirebaseAuth` with a redirect
3237

3338
Below is an example on how to use `FirebaseAuth` with a redirect upon sign-in:
3439

3540
```js
3641
// Import FirebaseAuth and firebase.
3742
import React from 'react';
38-
import { FirebaseAuth } from 'react-firebaseui';
43+
import StyledFirebaseAuth from 'react-firebaseui/StyledFirebaseAuth';
3944
import firebase from 'firebase';
4045

4146
// Configure Firebase.
@@ -65,7 +70,7 @@ class SignInScreen extends React.Component {
6570
<div>
6671
<h1>My App</h1>
6772
<p>Please sign-in:</p>
68-
<FirebaseAuth uiConfig={uiConfig} firebaseAuth={firebase.auth()}/>
73+
<StyledFirebaseAuth uiConfig={uiConfig} firebaseAuth={firebase.auth()}/>
6974
</div>
7075
);
7176
}
@@ -79,7 +84,7 @@ Below is an example on how to use `FirebaseAuth` with a state change upon sign-i
7984
```js
8085
// Import FirebaseAuth and firebase.
8186
import React from 'react';
82-
import { FirebaseAuth } from 'react-firebaseui';
87+
import StyledFirebaseAuth from 'react-firebaseui/StyledFirebaseAuth';
8388
import firebase from 'firebase';
8489

8590
// Configure Firebase.
@@ -120,7 +125,7 @@ class SignInScreen extends React.Component {
120125
<div>
121126
<h1>My App</h1>
122127
<p>Please sign-in:</p>
123-
<FirebaseAuth uiConfig={this.uiConfig} firebaseAuth={firebase.auth()}/>
128+
<StyledFirebaseAuth uiConfig={this.uiConfig} firebaseAuth={firebase.auth()}/>
124129
</div>
125130
);
126131
}
@@ -134,9 +139,32 @@ class SignInScreen extends React.Component {
134139
}
135140
```
136141

142+
### Accessing the FirebaseUI instance
143+
144+
To allow for further configuration you can access the firebaseUI instance before it is started.
145+
To do this you can pass a `uiCallback` callback function that wil be passed the Firebase UI instance. For example here is how to enable the `disableAutoSignIn()` option:
146+
147+
```js
148+
// ...
149+
150+
render() {
151+
return (
152+
<div>
153+
<h1>My App</h1>
154+
<p>Please sign-in:</p>
155+
<StyledFirebaseAuth uiCallback={ui => ui.disableAutoSignIn()} uiConfig={this.uiConfig} firebaseAuth={firebase.auth()}/>
156+
</div>
157+
);
158+
}
159+
```
160+
161+
<a href="#packing"/>
162+
137163
## Packing your app
138164

139-
The `FirebaseAuth` component needs a global CSS to get proper styling. The CSS is already imported within `FirebaseAuth`.
165+
If you are using the `StyledFirebaseAuth` component there should not be special configuration needed to package your app since the CSS is already included within the component. if you would like to extract the CSS you should use the `FirebaseAuth` component instead.
166+
167+
The `FirebaseAuth` needs a global CSS to get proper styling. The CSS is already imported within `FirebaseAuth`.
140168
If you are using webpack you'll need to add [CSS loaders](https://github.com/webpack-contrib/css-loader):
141169

142170
```js
@@ -152,6 +180,8 @@ If you are using webpack you'll need to add [CSS loaders](https://github.com/web
152180
}
153181
```
154182

183+
PS: make sure your rule does not exclude `/node_modules/` as this is where the library, and therefore, the CSS is located.
184+
155185
### With ExtractTextPlugin
156186

157187
If you are using [`ExtractTextPlugin`](https://github.com/webpack-contrib/extract-text-webpack-plugin) to extract a CSS file from the required CSS files you would typically use:
@@ -174,6 +204,8 @@ If you are using [`ExtractTextPlugin`](https://github.com/webpack-contrib/extrac
174204
}
175205
```
176206

207+
PS: make sure your rule does not exclude `/node_modules/` as this is where the library, and therefore, the CSS is located.
208+
177209
### With ExtractTextPlugin and CSS modules
178210

179211
If you are using CSS modules in your app you need to handle the CSS files in `/node_modules/` in a separate loader so that they are imported as global CSS files and not modules. Your setup could look like:
@@ -222,10 +254,10 @@ If you are using CSS modules in your app you need to handle the CSS files in `/n
222254

223255
## Styling
224256

225-
To change the styling of the `FirebaseAuth` widget you can override its CSS. You can import a CSS that will be included globally in your packed application. For instance create a `firebaseui-overrides.globlal.css` file and import it in your app:
257+
To change the styling of the `FirebaseAuth` or the `StyledFirebaseAuth` widget you can override some of its CSS. You can import a CSS that will be included globally in your packed application. For instance create a `firebaseui-overrides.global.css` file and import it in your app:
226258

227259
```js
228-
import './firebaseui-styling.global.css'; // Import globally.
260+
import './firebaseui-overrides.global.css'; // Import globally.
229261
```
230262

231263
> Note: If you are using the "With ExtractTextPlugin and CSS modules" Webpack build rule above, the `.global.css` suffixe will make sure the CSS file is imported globally and not ran through modules support.
@@ -238,8 +270,8 @@ If you would like to see an example of styling, have a look at the [example app]
238270
In the case where you would need to load multiple instances of `FirebaseAuth` at the same time you need to set them up with a different ID using the `elementId` attribute. For instance:
239271

240272
```js
241-
<FirebaseAuth elementId="auth_1" uiConfig={this.uiConfig} firebaseAuth={firebase.auth()}/>
242-
<FirebaseAuth elementId="auth_2" uiConfig={this.otherUiConfig} firebaseAuth={firebase.auth()}/>
273+
<StyledFirebaseAuth elementId="auth_1" uiConfig={this.uiConfig} firebaseAuth={firebase.auth()}/>
274+
<StyledFirebaseAuth elementId="auth_2" uiConfig={this.otherUiConfig} firebaseAuth={firebase.auth()}/>
243275
```
244276

245277

0 commit comments

Comments
 (0)