feat: Add Google Calendar Embed

This commit is contained in:
Matheus Breguêz
2021-07-07 14:29:49 -03:00
parent b037ae5dc1
commit ec5c47e0c8
3 changed files with 56 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);
});
});

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB