Skip to content

Commit 12a04bc

Browse files
authored
adjust SnackPlayer height and presentation (#3864)
1 parent ff4233d commit 12a04bc

File tree

8 files changed

+168
-30
lines changed

8 files changed

+168
-30
lines changed

plugins/remark-snackplayer/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"unist-util-visit-parents": "^3.1.1"
2525
},
2626
"devDependencies": {
27-
"remark": "^12.0.1",
28-
"tape": "^5.0.1"
27+
"remark": "^14.0.3",
28+
"tape": "^5.7.0"
2929
}
3030
}

plugins/remark-snackplayer/src/index.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ async function toJsxNode(node) {
5252
const theme = params.theme || 'light';
5353
const preview = params.preview || 'true';
5454
const loading = params.loading || 'lazy';
55-
const deviceAndroid = params.deviceAndroid || 'pixel4';
56-
const deviceIos = params.deviceIos || 'iphone12';
5755

5856
// Need help constructing this AST node?
5957
// Use the MDX Playground and explore what your output mdast should look like
@@ -72,8 +70,7 @@ async function toJsxNode(node) {
7270
attr('data-snack-theme', theme),
7371
attr('data-snack-preview', preview),
7472
attr('data-snack-loading', loading),
75-
attr('data-snack-device-android', deviceAndroid),
76-
attr('data-snack-device-ios', deviceIos),
73+
attr('data-snack-device-frame', 'false'),
7774
],
7875
children: [],
7976
};

plugins/remark-snackplayer/tests/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
const path = require('path');
99
const fs = require('fs');
1010
const test = require('tape');
11-
const remark = require('remark');
1211
const snackplayer = require('../');
1312

1413
const read = name => fs.readFileSync(path.join(__dirname, name), 'utf8');
1514
const normalizeLineEndings = str => str.replace(/\r\n/g, '\n');
1615

1716
test('remark-snackplayer', async t => {
17+
const {remark} = await import('remark');
1818
const processor = remark().use(snackplayer);
1919

2020
processor.process(read('markdown/test1.md'), (err, file) => {

plugins/remark-snackplayer/tests/output/output1.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@
99
data-snack-theme="light"
1010
data-snack-preview="true"
1111
data-snack-loading="lazy"
12+
data-snack-device-frame="false"
1213
></div>

plugins/remark-snackplayer/tests/output/output2.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
data-snack-theme="light"
1010
data-snack-preview="true"
1111
data-snack-loading="lazy"
12+
data-snack-device-frame="false"
1213
></div>
1314

1415
<div
@@ -22,4 +23,5 @@
2223
data-snack-theme="dark"
2324
data-snack-preview="false"
2425
data-snack-loading="eager"
26+
data-snack-device-frame="false"
2527
></div>

website/modules/snackPlayerInitializer.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,15 @@ export default (() => {
2020
};
2121

2222
const initSnackPlayers = () => {
23-
// console.log('initSnackPlayers');
2423
updateSnacksTheme();
2524
window.ExpoSnack && window.ExpoSnack.initialize();
2625
};
2726

2827
const setupTabPanelsMutationObservers = () => {
2928
const tabPanels = document.querySelectorAll('[role=tabpanel]');
30-
// console.log('setupTabPanelsMutationObservers', {tabPanels});
3129
tabPanels.forEach(tabPanel => {
32-
new MutationObserver((mutations, observer) => {
30+
new MutationObserver(() => {
3331
initSnackPlayers();
34-
// console.log('tabPanel MutationObserver triggered', {tabPanels});
3532
}).observe(tabPanel, {childList: true});
3633
});
3734
};
@@ -52,7 +49,7 @@ export default (() => {
5249
// Hacky, but no better solution for now
5350
// see https://github.com/expo/snack/blob/main/website/src/client/components/EmbedCode.tsx#L61
5451
const setupThemeSynchronization = () => {
55-
new MutationObserver((mutations, observer) => {
52+
new MutationObserver(() => {
5653
if ('ExpoSnack' in window) {
5754
document.querySelectorAll('.snack-player').forEach(container => {
5855
updateSnacksTheme();
@@ -73,9 +70,7 @@ export default (() => {
7370
setupThemeSynchronization();
7471

7572
return {
76-
onRouteDidUpdate({location}) {
77-
// console.log('onRouteDidUpdate', {location});
78-
73+
onRouteDidUpdate() {
7974
initSnackPlayers();
8075
setupTabPanelsMutationObservers();
8176
},

website/src/css/customTheme.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1714,7 +1714,7 @@ html[data-theme="dark"] .docsRating {
17141714
/* Snack Player */
17151715

17161716
.snack-player {
1717-
height: 544px;
1717+
height: 635px;
17181718
width: 100%;
17191719
overflow: hidden;
17201720
margin-bottom: 24px;

0 commit comments

Comments
 (0)