feat: Add Google Calendar Embed

This commit is contained in:
Matheus Breguêz
2021-07-07 14:29:49 -03:00
parent b037ae5dc1
commit e98f94c02d
4 changed files with 64 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
// @flow
import * as React from "react";
import Image from "components/Image";
import Frame from "./components/Frame";
const URL_REGEX = new RegExp("^https?://calendar.google.com/calendar/(.*)$");
type Props = {|
attrs: {|
href: string,
matches: string[],
|},
|};
export default class GoogleCalendar extends React.Component<Props> {
static ENABLED = [URL_REGEX];
render() {
return (
<Frame
{...this.props}
src={this.props.attrs.href}
icon={
<Image
src="/images/google-calendar.png"
alt="Google Calendar Icon"
width={16}
height={16}
/>
}
canonicalUrl={this.props.attrs.href}
title="Google Calendar"
border
/>
);
}
}

View File

@@ -0,0 +1,19 @@
/* eslint-disable flowtype/require-valid-file-annotation */
import GoogleCalendar from "./GoogleCalendar";
describe("GoogleCalendar", () => {
const match = GoogleCalendar.ENABLED[0];
test("to be enabled on share link", () => {
expect(
"https://calendar.google.com/calendar/embed?src=tom%40outline.com&ctz=America%2FSao_Paulo".match(
match
)
).toBeTruthy();
});
test("to not be enabled elsewhere", () => {
expect("https://calendar.google.com/calendar".match(match)).toBe(null);
expect("https://calendar.google.com".match(match)).toBe(null);
expect("https://www.google.com".match(match)).toBe(null);
});
});

View File

@@ -11,6 +11,7 @@ import Descript from "./Descript";
import Figma from "./Figma";
import Framer from "./Framer";
import Gist from "./Gist";
import GoogleCalendar from "./GoogleCalendar";
import GoogleDocs from "./GoogleDocs";
import GoogleDrawings from "./GoogleDrawings";
import GoogleDrive from "./GoogleDrive";
@@ -148,6 +149,13 @@ export default [
component: GoogleSlides,
matcher: matcher(GoogleSlides),
},
{
title: "Google Calendar",
keywords: "calendar",
icon: () => <Img src="/images/google-calendar.png" />,
component: GoogleCalendar,
matcher: matcher(GoogleCalendar),
},
{
title: "InVision",
keywords: "design prototype",

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB