Skip to content

Commit f732ce3

Browse files
presentation: fix blockquote and updated paragraph presentation (#1541)
1 parent 634933b commit f732ce3

10 files changed

Lines changed: 85 additions & 45 deletions

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
* Fix: [Presentation](flow/presentation) mode renders blockquotes correctly
2+
* Add: [Presentation](flow/presentation) mode wraps long paragraphs better

znai-reactjs/src/App.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
--znai-zoom-overlay-background-color: rgba(70, 70, 70, 0.9);
2727
--znai-zoom-container-border: 1px #000 solid;
2828

29+
--znai-presentation-paragraph-background: linear-gradient(135deg, #eef3fb 0%, #dfe8f6 100%);
30+
2931
/*
3032
single column render width to keep content centered
3133
it changes its value for mobile and when other content is nested

znai-reactjs/src/doc-elements/paragraph/Paragraph.css

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,14 @@ not belong to the same parent node so margins won't even each other out.
4747
justify-content: center;
4848
}
4949

50+
.presentation .znai-presentation-paragraph-wrapper > *:not(.znai-attention-block) {
51+
max-width: var(--znai-presentation-text-max-width);
52+
font-size: var(--znai-presentation-text-font-size);
53+
overflow-wrap: break-word;
54+
}
55+
5056
.znai-presentation-paragraph-default {
51-
background-color: var(--znai-attention-note-background-color);
52-
border-left: 3px solid var(--znai-attention-note-color);
53-
padding: 16px;
57+
background: var(--znai-presentation-paragraph-background);
58+
padding: 2.5cqw 3cqw;
59+
border-radius: 1.2cqw;
5460
}

znai-reactjs/src/doc-elements/paragraph/Paragraph.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,13 @@ const presentationParagraph = {
178178
? 1
179179
: 0;
180180
},
181+
// plain/forced paragraphs are fixed-font text (not transform-scaled), so the font stays
182+
// consistent and the text wraps into more lines. attention paragraphs (Question:/Note:/...)
183+
// render as attention blocks and are auto-scaled like a standalone attention block, so
184+
// their chrome (icon/label) and any inline code scale uniformly with the slide
185+
slideInfoProvider: ({ content }: { content: DocElementContent }) => ({
186+
isSlideScaled: allSuffixes.some((suffix) => paragraphStartsWith(content, suffix)),
187+
}),
181188
};
182189

183190
function isParagraphPresentationForced(content: DocElementContent) {

znai-reactjs/src/doc-elements/presentation/Presentation.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
flex-direction: column;
2121
height: 100vh;
2222
width: 100vw;
23+
24+
--znai-presentation-text-font-size: 4cqw;
25+
--znai-presentation-text-max-width: 70cqw;
2326
}
2427

2528
.presentation .header {

znai-reactjs/src/doc-elements/presentation/SlidePanel.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,6 @@
1717
.znai-presentation-slide-panel {
1818
height: 100%;
1919
overflow-y: hidden;
20+
21+
container-type: inline-size;
2022
}

znai-reactjs/src/doc-elements/quote/BlockQuote.css

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,32 +27,37 @@ blockquote {
2727
}
2828

2929
.presentation blockquote {
30-
max-width: 400px;
3130
margin: 0;
32-
font-size: 20px;
31+
max-width: var(--znai-presentation-text-max-width);
32+
font-size: var(--znai-presentation-text-font-size);
33+
padding-left: 4cqw;
34+
overflow-wrap: break-word;
35+
}
36+
37+
.presentation blockquote .content-block {
38+
max-width: none;
3339
}
3440

3541
.presentation .znai-presentation-slide-container blockquote {
36-
display: none;
42+
visibility: hidden;
3743
}
3844

3945
.presentation .znai-presentation-slide-appeared blockquote.no-animation {
40-
display: block;
46+
visibility: visible;
4147
}
4248

4349
.presentation .znai-presentation-slide-appeared blockquote.animate {
44-
display: block;
45-
animation: blockquote-presentation-appear;
46-
animation-fill-mode:forwards;
47-
animation-duration: 1.5s;
50+
visibility: visible;
51+
animation: blockquote-presentation-appear 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
4852
}
4953

5054
@keyframes blockquote-presentation-appear {
5155
from {
52-
padding: 10px 20px 10px 120px;
53-
max-width: 500px;
56+
opacity: 0;
57+
transform: translateX(-12%) scale(0.94);
5458
}
5559
to {
56-
padding: 10px 20px 10px 20px;
60+
opacity: 1;
61+
transform: translateX(0) scale(1);
5762
}
5863
}

znai-reactjs/src/doc-elements/quote/BlockQuote.jsx

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,32 @@
1515
* limitations under the License.
1616
*/
1717

18-
import React from 'react'
18+
import React from "react";
1919

20-
import './BlockQuote.css'
20+
import "./BlockQuote.css";
2121

2222
const BlockQuote = (props) => (
23-
<blockquote className="content-block">
24-
<props.elementsLibrary.DocElement {...props}/>
25-
</blockquote>
26-
)
23+
<blockquote className="content-block">
24+
<props.elementsLibrary.DocElement {...props} />
25+
</blockquote>
26+
);
2727

2828
const PresentationBlockQuote = (props) => {
29-
const className = props.isPresentationDisplayed ? "no-animation" : "animate";
30-
return (
31-
<blockquote className={className}>
32-
<props.elementsLibrary.DocElement {...props}/>
33-
</blockquote>
34-
)
35-
}
29+
const className = props.isPresentationDisplayed ? "no-animation" : "animate";
30+
return (
31+
<blockquote className={className}>
32+
<props.elementsLibrary.DocElement {...props} />
33+
</blockquote>
34+
);
35+
};
3636

3737
const presentationBlockQuoteHandler = {
38-
component: PresentationBlockQuote,
39-
numberOfSlides: () => 1
40-
}
38+
component: PresentationBlockQuote,
39+
numberOfSlides: () => 1,
40+
// don't transform-scale the quote to fill the slide. instead it renders at a fixed,
41+
// slide-relative size (font-size/max-width in cqw, see BlockQuote.css) so the font
42+
// stays consistent and the text simply wraps into more lines when space is tight
43+
slideInfoProvider: () => ({ isSlideScaled: false }),
44+
};
4145

42-
export {BlockQuote, presentationBlockQuoteHandler}
46+
export { BlockQuote, presentationBlockQuoteHandler };
Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/*
2+
* Copyright 2026 znai maintainers
23
* Copyright 2019 TWO SIGMA OPEN SOURCE, LLC
34
*
45
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,24 +15,30 @@
1415
* limitations under the License.
1516
*/
1617

17-
import {createPresentationDemo} from '../demo-utils/PresentationDemo'
18+
import { createPresentationDemo } from "../demo-utils/PresentationDemo";
1819

1920
export function blockQuotePresentationDemo(registry) {
20-
registry
21-
.add('block quote', createPresentationDemo([{
22-
type: 'BlockQuote',
23-
content: paragraph()
24-
}]))
21+
registry.add(
22+
"block quote",
23+
createPresentationDemo([
24+
{
25+
type: "BlockQuote",
26+
content: paragraph(),
27+
},
28+
])
29+
);
2530
}
2631

2732
function paragraph() {
28-
return [
33+
return [
34+
{
35+
type: "Paragraph",
36+
content: [
2937
{
30-
type: 'Paragraph',
31-
content: [{
32-
type: 'SimpleText',
33-
text: 'quote text quote text'
34-
}]
35-
}
36-
]
38+
type: "SimpleText",
39+
text: "quote text quote text. More long text more text for some extra lines and then some more ",
40+
},
41+
],
42+
},
43+
];
3744
}

znai-reactjs/src/theme/znai-dark/znai-dark.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121

2222
--znai-background-color: #1e2529;
2323

24+
--znai-presentation-paragraph-background: linear-gradient(135deg, #2c3744 0%, #1f272f 100%);
25+
2426
--znai-zoom-overlay-background-color: rgba(10, 10, 10, 0.9);
2527
--znai-zoom-container-border: 1px #333 solid;
2628

0 commit comments

Comments
 (0)