forked from sdoomz/react-google-picker
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from rembly/feature/customize_picker
Feature/customize picker
- Loading branch information
Showing
7 changed files
with
2,131 additions
and
558 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,63 @@ | ||
import React, { Component } from 'react' | ||
import ReactDOM from 'react-dom'; | ||
import GooglePicker from '../'; | ||
import React from 'react' | ||
import ReactDOM from 'react-dom' | ||
import GooglePicker from '../' | ||
|
||
const CLIENT_ID = '206339496672-eie1j7vvr0plioslt41l2qsddmdjloqj.apps.googleusercontent.com'; | ||
const DEVELOPER_KEY = 'AIzaSyChPXI8ByCl68kcpy0zwjrfjEc_8mtwH_w'; | ||
const SCOPE = ['https://www.googleapis.com/auth/drive.readonly']; | ||
const CLIENT_ID = '206339496672-eie1j7vvr0plioslt41l2qsddmdjloqj.apps.googleusercontent.com' | ||
const DEVELOPER_KEY = 'AIzaSyChPXI8ByCl68kcpy0zwjrfjEc_8mtwH_w' | ||
const SCOPE = ['https://www.googleapis.com/auth/drive.readonly'] | ||
|
||
function App() { | ||
function App () { | ||
return ( | ||
<div className="container"> | ||
<div className='container'> | ||
<GooglePicker clientId={CLIENT_ID} | ||
developerKey={DEVELOPER_KEY} | ||
scope={SCOPE} | ||
onChange={data => console.log('on change:', data)} | ||
onAuthFailed={data => console.log('on auth failed:', data)} | ||
multiselect={true} | ||
navHidden={true} | ||
authImmediate={false} | ||
mimeTypes={['image/png', 'image/jpeg', 'image/jpg']} | ||
viewId={'DOCS'}> | ||
developerKey={DEVELOPER_KEY} | ||
scope={SCOPE} | ||
onChange={data => console.log('on change:', data)} | ||
onAuthFailed={data => console.log('on auth failed:', data)} | ||
multiselect | ||
navHidden | ||
authImmediate={false} | ||
mimeTypes={['image/png', 'image/jpeg', 'image/jpg']} | ||
viewId={'DOCS'}> | ||
<span>Click me!</span> | ||
<div className="google"></div> | ||
<div className='google' /> | ||
</GooglePicker> | ||
<br/> | ||
<hr/> | ||
<br/> | ||
<GooglePicker clientId={CLIENT_ID} | ||
developerKey={DEVELOPER_KEY} | ||
scope={SCOPE} | ||
onChange={data => console.log('on change:', data)} | ||
onAuthFailed={data => console.log('on auth failed:', data)} | ||
multiselect={true} | ||
navHidden={true} | ||
authImmediate={false} | ||
viewId={'FOLDERS'} | ||
createPicker={ (google, oauthToken) => { | ||
const googleViewId = google.picker.ViewId.FOLDERS; | ||
const docsView = new google.picker.DocsView(googleViewId) | ||
.setIncludeFolders(true) | ||
.setMimeTypes('application/vnd.google-apps.folder') | ||
.setSelectFolderEnabled(true); | ||
<br /> | ||
<hr /> | ||
<br /> | ||
<GooglePicker clientId={CLIENT_ID} | ||
developerKey={DEVELOPER_KEY} | ||
scope={SCOPE} | ||
onChange={data => console.log('on change:', data)} | ||
onAuthFailed={data => console.log('on auth failed:', data)} | ||
multiselect | ||
navHidden | ||
authImmediate={false} | ||
viewId={'FOLDERS'} | ||
createPicker={(google, oauthToken) => { | ||
const googleViewId = google.picker.ViewId.FOLDERS | ||
const docsView = new google.picker.DocsView(googleViewId) | ||
.setIncludeFolders(true) | ||
.setMimeTypes('application/vnd.google-apps.folder') | ||
.setSelectFolderEnabled(true) | ||
|
||
const picker = new window.google.picker.PickerBuilder() | ||
.addView(docsView) | ||
.setOAuthToken(oauthToken) | ||
.setDeveloperKey(DEVELOPER_KEY) | ||
.setCallback(()=>{ | ||
console.log('Custom picker is ready!'); | ||
}); | ||
const picker = new window.google.picker.PickerBuilder() | ||
.addView(docsView) | ||
.setOAuthToken(oauthToken) | ||
.setDeveloperKey(DEVELOPER_KEY) | ||
.setCallback(() => { | ||
console.log('Custom picker is ready!') | ||
}) | ||
|
||
picker.build().setVisible(true); | ||
}} | ||
> | ||
<span>Click to build a picker which shows folders and you can select folders</span> | ||
<div className="google"></div> | ||
</GooglePicker> | ||
picker.build().setVisible(true) | ||
}} | ||
> | ||
<span>Click to build a picker which shows folders and you can select folders</span> | ||
<div className='google' /> | ||
</GooglePicker> | ||
|
||
</div> | ||
) | ||
} | ||
|
||
ReactDOM.render(<App />, document.getElementById('root')); | ||
ReactDOM.render(<App />, document.getElementById('root')) |
Oops, something went wrong.