-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Co-authored-by: Marco Scarciofolo <[email protected]>
- Loading branch information
1 parent
0984486
commit 1c499d2
Showing
9 changed files
with
178 additions
and
50 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<title>Static HTML Demo</title> | ||
<style> | ||
#wrapper, | ||
#wrapper2 { | ||
width: 100%; | ||
max-width: 600px; | ||
height: 400px; | ||
margin: 80px auto; | ||
} | ||
.element { | ||
position: fixed; | ||
bottom: 0; | ||
right: 0; | ||
background: red; | ||
color: white; | ||
padding: 10px; | ||
width: 200px; | ||
height: 60px; | ||
line-height: 40px; | ||
z-index: 10000; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div class="element">I have z-index 10k</div> | ||
<div id="wrapper" data-tf-widget="HLjqXS5W" data-tf-medium="demo-test" data-tf-transitive-search-params></div> | ||
<div | ||
id="wrapper2" | ||
data-tf-widget="HLjqXS5W" | ||
data-tf-medium="demo-test" | ||
data-tf-transitive-search-params="foo,bar" | ||
></div> | ||
<script src="./lib/embed-next.js"></script> | ||
<script> | ||
window.onload = () => { | ||
if (!window.location.search) { | ||
window.location.search = '?foo=hi&bar=hello&biz=bye' | ||
} | ||
} | ||
</script> | ||
</body> | ||
</html> |
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,59 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<title>Static HTML Demo</title> | ||
<style> | ||
#wrapper, | ||
#wrapper2 { | ||
width: 100%; | ||
max-width: 600px; | ||
height: 400px; | ||
margin: 80px auto; | ||
} | ||
.element { | ||
position: fixed; | ||
bottom: 0; | ||
right: 0; | ||
background: red; | ||
color: white; | ||
padding: 10px; | ||
width: 200px; | ||
height: 60px; | ||
line-height: 40px; | ||
z-index: 10000; | ||
} | ||
</style> | ||
<link rel="stylesheet" href="./lib/css/widget.css" /> | ||
</head> | ||
<body> | ||
<div class="element">I have z-index 10k</div> | ||
<div id="wrapper"></div> | ||
<div id="wrapper2"></div> | ||
<script src="./lib/embed-next.js"></script> | ||
<script> | ||
window.onload = () => { | ||
if (!window.location.search) { | ||
window.location.search = '?foo=hi&bar=hello&biz=bye' | ||
} | ||
} | ||
|
||
window.tf.createWidget('HLjqXS5W', { | ||
container: document.getElementById('wrapper'), | ||
transitiveSearchParams: ['foo', 'bar'], | ||
medium: 'demo-test', | ||
hidden: { foo: 'foo value', bar: 'bar value' }, | ||
iframeProps: { title: 'Foo Bar' }, | ||
}) | ||
|
||
window.tf.createWidget('HLjqXS5W', { | ||
container: document.getElementById('wrapper2'), | ||
transitiveSearchParams: true, | ||
medium: 'demo-test', | ||
hidden: { foo: 'foo value', bar: 'bar value' }, | ||
iframeProps: { title: 'Foo Bar' }, | ||
}) | ||
</script> | ||
</body> | ||
</html> |
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,20 @@ | ||
export const getTransitiveSearchParams = (transitiveSearchParams?: string[]) => { | ||
export const getTransitiveSearchParams = (transitiveSearchParams?: string[] | boolean) => { | ||
const url = new URL(window.location.href) | ||
const queryParamsWithTransitiveParams = {} | ||
|
||
if (transitiveSearchParams && transitiveSearchParams.length > 0) { | ||
transitiveSearchParams.forEach((key: string) => { | ||
if (typeof transitiveSearchParams === 'boolean' && transitiveSearchParams) { | ||
return Object.fromEntries(url.searchParams.entries()) | ||
} | ||
|
||
if (Array.isArray(transitiveSearchParams) && transitiveSearchParams.length > 0) { | ||
return transitiveSearchParams.reduce<Record<string, string>>((queryParamsMap, key) => { | ||
if (url.searchParams.has(key)) { | ||
queryParamsWithTransitiveParams[key] = url.searchParams.get(key) | ||
const keyValue = url.searchParams.get(key) as string | ||
return { ...queryParamsMap, [key]: keyValue } | ||
} | ||
}) | ||
|
||
return queryParamsMap | ||
}, {}) | ||
} | ||
|
||
return queryParamsWithTransitiveParams | ||
return {} | ||
} |
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