Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RNMobile] Add viewport optional props #49699

Merged
merged 4 commits into from
Apr 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion packages/components/src/sandbox/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ const Sandbox = forwardRef( function Sandbox(
type,
url,
onWindowEvents = {},
viewportProps = '',
},
ref
) {
Expand Down Expand Up @@ -213,13 +214,19 @@ const Sandbox = forwardRef( function Sandbox(
// we can use this in the future to inject custom styles or scripts.
// Scripts go into the body rather than the head, to support embedded content such as Instagram
// that expect the scripts to be part of the body.

// Avoid comma issues with props.viewportProps.
const addViewportProps = viewportProps
.trim()
.replace( /(^[^,])/, ', $1' );

const htmlDoc = (
<html lang={ lang }>
<head>
<title>{ title }</title>
<meta
name="viewport"
content="width=device-width, initial-scale=1"
content={ `width=device-width, initial-scale=1${ addViewportProps }` }
></meta>
<style dangerouslySetInnerHTML={ { __html: style } } />
{ styles.map( ( rules, i ) => (
Expand Down