0.5.6 • Published 3 years ago

google-classroom-share v0.5.6

Weekly downloads
99
License
MIT
Repository
github
Last release
3 years ago

google-classroom-share

You can add and customize the Classroom share button to meet the needs of your website, such as modifying the button size and load technique. By adding the Classroom share button to your website, you allow your users to share your content to their classes and drive traffic to your site.

Install

yarn add google-classroom-share react-load-script

Demo

npm.io https://robertov8.github.io/google-classroom-share

https://developers.google.com/classroom/guides/sharebutton

Usage

import React from 'react';

import GoogleShareToClassRoom from '../index';

function App() {
  return (
    <GoogleShareToClassRoom
      body="Example Body"
      itemType="assignment"
      url="https://developers.google.com/classroom"
      size={50}
      title="Example Title"
      theme="light"
      onShare={(type) => console.log(`GoogleShareToClassRoom:${type}`)}
      onShareComplete={() => console.log('GoogleShareToClassRoom:onShareComplete')}
      onShareStart={() => console.log('GoogleShareToClassRoom:onShareStart')}
    />
  );
}

export default App;

Props

PropTypeDescription
bodyStringSets the item body text to share to Classroom.
itemTypeString"announcement, assignment, material, question" This will automatically show the creation dialog after the user first selects a course (or immediately if courseid is also specified).
urlStringSets the URL to share to Classroom. If you set this attribute by using gapi.sharetoclassroom.render, you should not escape the URL.
sizeNumberSets the size in pixels of the share button. If the size is omitted, the button uses 32.
titleStringSets the item title to share to Classroom.
themeStringSets the button icon for the selected theme.
onShareStringIf specified, sets the name of a function is called when the share dialog opens and user finishes sharing your link.
onShareCompleteFunctionIf specified, sets the name of a function is called when the user finishes sharing your link.
onShareStartFunctionIf specified, sets the name of a function is called when the share dialog opens.