Functional Component Refactor: Google Calendar, DataStudio, & Drawings (#4261)
This commit is contained in:
@@ -2,21 +2,14 @@ import * as React from "react";
|
||||
import Frame from "../components/Frame";
|
||||
import { EmbedProps as Props } from ".";
|
||||
|
||||
const URL_REGEX = new RegExp(
|
||||
"^https?://calendar\\.google\\.com/calendar/embed\\?src=(.*)$"
|
||||
);
|
||||
|
||||
export default class GoogleCalendar extends React.Component<Props> {
|
||||
static ENABLED = [URL_REGEX];
|
||||
|
||||
render() {
|
||||
return (
|
||||
<Frame
|
||||
{...this.props}
|
||||
src={this.props.attrs.href}
|
||||
title="Google Calendar"
|
||||
border
|
||||
/>
|
||||
);
|
||||
}
|
||||
function GoogleCalendar(props: Props) {
|
||||
return (
|
||||
<Frame {...props} src={props.attrs.href} title="Google Calendar" border />
|
||||
);
|
||||
}
|
||||
|
||||
GoogleCalendar.ENABLED = [
|
||||
new RegExp("^https?://calendar\\.google\\.com/calendar/embed\\?src=(.*)$"),
|
||||
];
|
||||
|
||||
export default GoogleCalendar;
|
||||
|
||||
@@ -3,30 +3,30 @@ import Frame from "../components/Frame";
|
||||
import Image from "../components/Image";
|
||||
import { EmbedProps as Props } from ".";
|
||||
|
||||
const URL_REGEX = new RegExp(
|
||||
"^https?://datastudio\\.google\\.com/(embed|u/0)/reporting/(.*)/page/(.*)(/edit)?$"
|
||||
);
|
||||
|
||||
export default class GoogleDataStudio extends React.Component<Props> {
|
||||
static ENABLED = [URL_REGEX];
|
||||
|
||||
render() {
|
||||
return (
|
||||
<Frame
|
||||
{...this.props}
|
||||
src={this.props.attrs.href.replace("u/0", "embed").replace("/edit", "")}
|
||||
icon={
|
||||
<Image
|
||||
src="/images/google-datastudio.png"
|
||||
alt="Google Data Studio Icon"
|
||||
width={16}
|
||||
height={16}
|
||||
/>
|
||||
}
|
||||
canonicalUrl={this.props.attrs.href}
|
||||
title="Google Data Studio"
|
||||
border
|
||||
/>
|
||||
);
|
||||
}
|
||||
function GoogleDataStudio(props: Props) {
|
||||
return (
|
||||
<Frame
|
||||
{...props}
|
||||
src={props.attrs.href.replace("u/0", "embed").replace("/edit", "")}
|
||||
icon={
|
||||
<Image
|
||||
src="/images/google-datastudio.png"
|
||||
alt="Google Data Studio Icon"
|
||||
width={16}
|
||||
height={16}
|
||||
/>
|
||||
}
|
||||
canonicalUrl={props.attrs.href}
|
||||
title="Google Data Studio"
|
||||
border
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
GoogleDataStudio.ENABLED = [
|
||||
new RegExp(
|
||||
"^https?://datastudio\\.google\\.com/(embed|u/0)/reporting/(.*)/page/(.*)(/edit)?$"
|
||||
),
|
||||
];
|
||||
|
||||
export default GoogleDataStudio;
|
||||
|
||||
@@ -3,30 +3,30 @@ import Frame from "../components/Frame";
|
||||
import Image from "../components/Image";
|
||||
import { EmbedProps as Props } from ".";
|
||||
|
||||
const URL_REGEX = new RegExp(
|
||||
"^https://docs\\.google\\.com/drawings/d/(.*)/(edit|preview)(.*)$"
|
||||
);
|
||||
|
||||
export default class GoogleDrawings extends React.Component<Props> {
|
||||
static ENABLED = [URL_REGEX];
|
||||
|
||||
render() {
|
||||
return (
|
||||
<Frame
|
||||
{...this.props}
|
||||
src={this.props.attrs.href.replace("/edit", "/preview")}
|
||||
icon={
|
||||
<Image
|
||||
src="/images/google-drawings.png"
|
||||
alt="Google Drawings"
|
||||
width={16}
|
||||
height={16}
|
||||
/>
|
||||
}
|
||||
canonicalUrl={this.props.attrs.href.replace("/preview", "/edit")}
|
||||
title="Google Drawings"
|
||||
border
|
||||
/>
|
||||
);
|
||||
}
|
||||
function GoogleDrawings(props: Props) {
|
||||
return (
|
||||
<Frame
|
||||
{...props}
|
||||
src={props.attrs.href.replace("/edit", "/preview")}
|
||||
icon={
|
||||
<Image
|
||||
src="/images/google-drawings.png"
|
||||
alt="Google Drawings"
|
||||
width={16}
|
||||
height={16}
|
||||
/>
|
||||
}
|
||||
canonicalUrl={props.attrs.href.replace("/preview", "/edit")}
|
||||
title="Google Drawings"
|
||||
border
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
GoogleDrawings.ENABLED = [
|
||||
new RegExp(
|
||||
"^https://docs\\.google\\.com/drawings/d/(.*)/(edit|preview)(.*)$"
|
||||
),
|
||||
];
|
||||
|
||||
export default GoogleDrawings;
|
||||
|
||||
Reference in New Issue
Block a user