Skip to content

Commit 6a2f498

Browse files
committed
ContentRenderer: accept 'screen' prop and override styles with given preview screen/device type
1 parent ea8edf2 commit 6a2f498

File tree

4 files changed

+281
-45
lines changed

4 files changed

+281
-45
lines changed

packages/perseus-editor/src/article-editor.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ export default class ArticleEditor extends React.Component<Props, State> {
242242
apiOptions={apiOptions}
243243
question={section}
244244
seamless={!nochrome}
245+
screen={this.props.screen}
245246
linterContext={{
246247
contentType: "article",
247248
highlightLint: this.state.highlightLint,
@@ -259,6 +260,7 @@ export default class ArticleEditor extends React.Component<Props, State> {
259260
apiOptions={apiOptions}
260261
question={sections[sectionIndex]}
261262
seamless={!nochrome}
263+
screen={this.props.screen}
262264
linterContext={{
263265
contentType: "article",
264266
highlightLint: this.state.highlightLint,

packages/perseus-editor/src/content-renderer.tsx

+8-2
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,29 @@ import {color, spacing} from "@khanacademy/wonder-blocks-tokens";
1111
import {StyleSheet} from "aphrodite";
1212
import * as React from "react";
1313

14-
import type {APIOptions, PerseusRenderer} from "@khanacademy/perseus";
14+
import type {
15+
APIOptions,
16+
DeviceType,
17+
PerseusRenderer,
18+
} from "@khanacademy/perseus";
1519
import type {LinterContextProps} from "@khanacademy/perseus-linter";
1620

1721
function ContentRenderer({
1822
question,
1923
apiOptions,
24+
screen,
2025
seamless,
2126
linterContext,
2227
legacyPerseusLint,
2328
}: {
2429
question?: PerseusRenderer;
2530
apiOptions?: APIOptions;
31+
screen: DeviceType;
2632
seamless?: boolean;
2733
linterContext?: LinterContextProps;
2834
legacyPerseusLint?: ReadonlyArray<string>;
2935
}) {
30-
const className = apiOptions?.isMobile ? "perseus-mobile" : "";
36+
const className = `${apiOptions?.isMobile ? "perseus-mobile" : ""} perseus-preview-${screen}`;
3137

3238
return (
3339
<View

packages/perseus-editor/src/item-editor.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const ITEM_DATA_VERSION = itemDataVersion;
1919

2020
type Props = {
2121
apiOptions?: APIOptions;
22-
deviceType?: DeviceType;
22+
deviceType: DeviceType;
2323
gradeMessage?: string;
2424
imageUploader?: ImageUploader;
2525
wasAnswered?: boolean;
@@ -115,6 +115,7 @@ class ItemEditor extends React.Component<Props> {
115115
<ContentRenderer
116116
apiOptions={this.props.apiOptions}
117117
question={this.props.question}
118+
screen={this.props.deviceType}
118119
linterContext={{
119120
contentType: "exercise",
120121
highlightLint: true,

0 commit comments

Comments
 (0)