-
Notifications
You must be signed in to change notification settings - Fork 126
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 #2095 from tf/tiktok
Add TikTok content element
- Loading branch information
Showing
21 changed files
with
254 additions
and
12 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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
de: | ||
pageflow_scrolled: | ||
editor: | ||
content_elements: | ||
tikTokEmbed: | ||
attributes: | ||
url: | ||
label: TikTok-URL | ||
description: Bettet Inhalte von TikTok ein | ||
name: TikTok | ||
tabs: | ||
general: TikTok-Embed |
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
en: | ||
pageflow_scrolled: | ||
editor: | ||
content_elements: | ||
tikTokEmbed: | ||
attributes: | ||
url: | ||
label: TikTok URL | ||
description: Embed content from TikTok | ||
name: TikTok | ||
tabs: | ||
general: TikTok Embed |
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
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,4 +1,5 @@ | ||
/node_modules | ||
/contentElements | ||
/editor.js | ||
/frontend | ||
/frontend-server.js | ||
|
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import 'pageflow-scrolled/contentElements-frontend'; | ||
import 'pageflow-scrolled/contentElements/tikTokEmbed-frontend'; |
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
53 changes: 53 additions & 0 deletions
53
entry_types/scrolled/package/src/contentElements/tikTokEmbed/TikTokEmbed.js
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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import React from 'react'; | ||
import Embed from 'react-tiny-oembed'; | ||
|
||
import { | ||
ContentElementBox, | ||
ThirdPartyOptIn, | ||
useContentElementEditorState, | ||
ThirdPartyOptOutInfo, | ||
useContentElementLifecycle, | ||
useIsStaticPreview | ||
} from 'pageflow-scrolled/frontend'; | ||
|
||
import styles from './TikTokEmbed.module.css'; | ||
|
||
const tikTokProvider = { | ||
provider_name: "TikTok", | ||
provider_url: "http://www.tiktok.com/", | ||
endpoints: [ | ||
{ | ||
schemes: [ | ||
"https://www.tiktok.com/*", | ||
"https://www.tiktok.com/*/video/*" | ||
], | ||
url: "https://www.tiktok.com/oembed" | ||
} | ||
] | ||
}; | ||
|
||
export function TikTokEmbed({configuration}) { | ||
const {url} = configuration; | ||
const {isEditable, isSelected} = useContentElementEditorState(); | ||
const {shouldLoad} = useContentElementLifecycle(); | ||
const isStaticPreview = useIsStaticPreview(); | ||
|
||
return ( | ||
<ContentElementBox> | ||
<div style={{pointerEvents: isEditable && !isSelected ? 'none' : undefined}}> | ||
<div className={styles.wrapper}> | ||
{shouldLoad && url && !isStaticPreview && | ||
<ThirdPartyOptIn | ||
providerName="tiktok"> | ||
<div className={styles.inner} data-percy="hide"> | ||
<Embed key={url} | ||
url={url} | ||
providers={[tikTokProvider]} /> | ||
</div> | ||
</ThirdPartyOptIn>} | ||
</div> | ||
<ThirdPartyOptOutInfo inset providerName="tiktok" /> | ||
</div> | ||
</ContentElementBox> | ||
); | ||
} |
17 changes: 17 additions & 0 deletions
17
entry_types/scrolled/package/src/contentElements/tikTokEmbed/TikTokEmbed.module.css
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
.wrapper { | ||
margin: 0 auto; | ||
max-width: 325px; | ||
min-height: 450px; | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
} | ||
|
||
.inner { | ||
background-color: #fff; | ||
visibility: hidden; | ||
} | ||
|
||
.inner:has(iframe) { | ||
visibility: visible; | ||
} |
25 changes: 25 additions & 0 deletions
25
entry_types/scrolled/package/src/contentElements/tikTokEmbed/editor.js
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import {editor} from 'pageflow-scrolled/editor'; | ||
import {UrlInputView} from 'pageflow/ui'; | ||
import pictogram from './pictogram.svg' | ||
|
||
editor.contentElementTypes.register('tikTokEmbed', { | ||
pictogram, | ||
category: 'media', | ||
supportedPositions: ['inline', 'sticky', 'standAlone', 'left', 'right'], | ||
supportedWidthRange: ['md', 'full'], | ||
|
||
configurationEditor() { | ||
this.tab('general', function() { | ||
this.input('url', UrlInputView, { | ||
supportedHosts: [ | ||
'https://www.tiktok.com' | ||
], | ||
displayPropertyName: 'displayUrl', | ||
required: true, | ||
permitHttps: true | ||
}); | ||
this.group('ContentElementPosition'); | ||
}); | ||
}, | ||
defaultConfig: {}, | ||
}); |
19 changes: 19 additions & 0 deletions
19
entry_types/scrolled/package/src/contentElements/tikTokEmbed/frontend.js
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import {frontend} from 'pageflow-scrolled/frontend'; | ||
import {TikTokEmbed} from './TikTokEmbed'; | ||
|
||
frontend.contentElementTypes.register('tikTokEmbed', { | ||
component: TikTokEmbed, | ||
lifecycle: true, | ||
customMargin: true, | ||
|
||
consentVendors({t}) { | ||
const prefix = 'pageflow_scrolled.public.tiktok'; | ||
|
||
return [{ | ||
name: 'tiktok', | ||
displayName: t(`${prefix}.consent_vendor_name`), | ||
description: t(`${prefix}.consent_vendor_description`), | ||
paradigm: 'lazy opt-in' | ||
}]; | ||
} | ||
}); |
1 change: 1 addition & 0 deletions
1
entry_types/scrolled/package/src/contentElements/tikTokEmbed/pictogram.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions
10
entry_types/scrolled/package/src/contentElements/tikTokEmbed/stories.js
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import './frontend'; | ||
import {storiesOfContentElement} from 'pageflow-scrolled/spec/support/stories'; | ||
|
||
storiesOfContentElement(module, { | ||
typeName: 'tikTokEmbed', | ||
baseConfiguration: { | ||
url: 'https://www.tiktok.com/@scout2015/video/6718335390845095173' | ||
}, | ||
consent: true | ||
}); |
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
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
Oops, something went wrong.