Skip to content

Commit c3b81a7

Browse files
authored
Wrap diagrams and transparent images with background (#11891)
By adding a `.diagram-wrap` CSS class that can be added to images as needed. To improve legibility in dark mode and visual separation in light mode. Contributes to #11883
1 parent 4b0e10a commit c3b81a7

File tree

11 files changed

+46
-39
lines changed

11 files changed

+46
-39
lines changed

src/_sass/components/_content.scss

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,18 @@
1919

2020
img {
2121
object-fit: contain;
22+
23+
&.diagram-wrap {
24+
background-color: #f8f9fa;
25+
padding: 1rem;
26+
border-radius: 1rem;
27+
}
28+
29+
&.small-diagram-wrap {
30+
background-color: #f8f9fa;
31+
padding: 0.5rem;
32+
border-radius: 0.5rem;
33+
}
2234
}
2335

2436
> img {
Loading
Loading

src/content/data-and-backend/state-mgmt/declarative.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ it. Flutter is fast enough to do that, even on every frame if needed.
2020
Flutter is _declarative_. This means that Flutter builds its user interface to
2121
reflect the current state of your app:
2222

23-
<img src='/assets/images/docs/development/data-and-backend/state-mgmt/ui-equals-function-of-state.png' width="100%" alt="A mathematical formula of UI = f(state). 'UI' is the layout on the screen. 'f' is your build methods. 'state' is the application state.">
23+
<img src='/assets/images/docs/development/data-and-backend/state-mgmt/ui-equals-function-of-state.png' width="100%" class="diagram-wrap" alt="A mathematical formula of UI = f(state). 'UI' is the layout on the screen. 'f' is your build methods. 'state' is the application state.">
2424

2525
{% comment %}
2626
Source drawing for the png above: : https://docs.google.com/drawings/d/1RDcR5LyFtzhpmiT5-UupXBeos2Ban5cUTU0-JujS3Os/edit?usp=sharing

src/content/data-and-backend/state-mgmt/ephemeral-vs-app.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ it might need to be moved to app state.
122122

123123
For that reason, take the following diagram with a large grain of salt:
124124

125-
<img src='/assets/images/docs/development/data-and-backend/state-mgmt/ephemeral-vs-app-state.png' width="100%" alt="A flow chart. Start with 'Data'. 'Who needs it?'. Three options: 'Most widgets', 'Some widgets' and 'Single widget'. The first two options both lead to 'App state'. The 'Single widget' option leads to 'Ephemeral state'.">
125+
<img src='/assets/images/docs/development/data-and-backend/state-mgmt/ephemeral-vs-app-state.png' width="100%" class="diagram-wrap" alt="A flow chart. Start with 'Data'. 'Who needs it?'. Three options: 'Most widgets', 'Some widgets' and 'Single widget'. The first two options both lead to 'App state'. The 'Single widget' option leads to 'Ephemeral state'.">
126126

127127
{% comment %}
128128
Source drawing for the png above: : https://docs.google.com/drawings/d/1p5Bvuagin9DZH8bNrpGfpQQvKwLartYhIvD0WKGa64k/edit?usp=sharing

src/content/data-and-backend/state-mgmt/simple.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ you can find packages and tutorials listed on the [options page][].
2828

2929
## Our example
3030

31-
<img src='/assets/images/docs/development/data-and-backend/state-mgmt/model-shopper-screencast.webp' alt='An animated gif showing a Flutter app in use. It starts with the user on a login screen. They log in and are taken to the catalog screen, with a list of items. The click on several items, and as they do so, the items are marked as "added". The user clicks on a button and gets taken to the cart view. They see the items there. They go back to the catalog, and the items they bought still show "added". End of animation.' class='site-image-right'>
31+
<img src='/assets/images/docs/development/data-and-backend/state-mgmt/model-shopper-screencast.webp' alt='An animated gif showing a Flutter app in use. It starts with the user on a login screen. They log in and are taken to the catalog screen, with a list of items. The click on several items, and as they do so, the items are marked as "added". The user clicks on a button and gets taken to the cart view. They see the items there. They go back to the catalog, and the items they bought still show "added". End of animation.' class='site-image-right' style="max-height: 24rem;">
3232

3333
For illustration, consider the following simple app.
3434

@@ -43,7 +43,7 @@ and a scrolling view of many list items (`MyListItems`).
4343

4444
Here's the app visualized as a widget tree.
4545

46-
<img src='/assets/images/docs/development/data-and-backend/state-mgmt/simple-widget-tree.png' width="100%" alt="A widget tree with MyApp at the top, and MyCatalog and MyCart below it. MyCart area leaf nodes, but MyCatalog have two children: MyAppBar and a list of MyListItems.">
46+
<img src='/assets/images/docs/development/data-and-backend/state-mgmt/simple-widget-tree.png' width="100%" class="diagram-wrap" alt="A widget tree with MyApp at the top, and MyCatalog and MyCart below it. MyCart area leaf nodes, but MyCatalog have two children: MyAppBar and a list of MyListItems.">
4747

4848
{% comment %}
4949
Source drawing for the png above: https://docs.google.com/drawings/d/1KXxAl_Ctxc-avhR4uE58BXBM6Tyhy0pQMCsSMFHVL_0/edit?zx=y4m1lzbhsrvx
@@ -135,7 +135,7 @@ it rebuilds `MyCart` from above (more on that later). Because of this,
135135
what to show for any given `contents`. When that changes, the old
136136
`MyCart` widget disappears and is completely replaced by the new one.
137137

138-
<img src='/assets/images/docs/development/data-and-backend/state-mgmt/simple-widget-tree-with-cart.png' width="100%" alt="Same widget tree as above, but now we show a small 'cart' badge next to MyApp, and there are two arrows here. One comes from one of the MyListItems to the 'cart', and another one goes from the 'cart' to the MyCart widget.">
138+
<img src='/assets/images/docs/development/data-and-backend/state-mgmt/simple-widget-tree-with-cart.png' width="100%" class="diagram-wrap" alt="Same widget tree as above, but now we show a small 'cart' badge next to MyApp, and there are two arrows here. One comes from one of the MyListItems to the 'cart', and another one goes from the 'cart' to the MyCart widget.">
139139

140140
{% comment %}
141141
Source drawing for the png above: https://docs.google.com/drawings/d/1ErMyaX4fwfbIW9ABuPAlHELLGMsU6cdxPDFz_elsS9k/edit?zx=j42inp8903pt

src/content/perf/isolates.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ to painting a frame on the screen.
3737
The following figure shows an example event queue
3838
with 3 events waiting to be processed.
3939

40-
![The main isolate diagram](/assets/images/docs/development/concurrency/basics-main-isolate.png){:width="50%"}
40+
![The main isolate diagram](/assets/images/docs/development/concurrency/basics-main-isolate.png){:width="50%" .diagram-wrap}
4141

4242
For smooth rendering,
4343
Flutter adds a "paint frame" event to the event queue
@@ -47,7 +47,7 @@ the application experiences UI jank,
4747
or worse,
4848
become unresponsive altogether.
4949

50-
![Event jank diagram](/assets/images/docs/development/concurrency/event-jank.png){:width="50%"}
50+
![Event jank diagram](/assets/images/docs/development/concurrency/event-jank.png){:width="60%" .diagram-wrap}
5151

5252
Whenever a process can't be completed in a frame gap,
5353
the time between two frames,
@@ -74,7 +74,7 @@ to experience UI jank.
7474
This jank happens when there is any computation that takes longer than
7575
Flutter's frame gap.
7676

77-
![Event jank diagram](/assets/images/docs/development/concurrency/event-jank.png){:width="50%"}
77+
![Event jank diagram](/assets/images/docs/development/concurrency/event-jank.png){:width="60%" .diagram-wrap}
7878

7979
Any process _could_ take longer to complete,
8080
depending on the implementation
@@ -141,7 +141,7 @@ and then shuts the isolate down when the computation is complete.
141141
This all happens concurrently with the main isolate,
142142
and doesn't block it.
143143

144-
![Isolate diagram](/assets/images/docs/development/concurrency/isolate-bg-worker.png){:width="50%"}
144+
![Isolate diagram](/assets/images/docs/development/concurrency/isolate-bg-worker.png){:width="70%" .diagram-wrap}
145145

146146
The `Isolate.run` method requires a single argument,
147147
a callback function,

src/content/resources/architectural-overview.md

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ You can use `InheritedWidget` to create a state widget
489489
that wraps a common ancestor in the
490490
widget tree, as shown in this example:
491491

492-
![Inherited widgets](/assets/images/docs/arch-overview/inherited-widget.png){:width="50%"}
492+
![Inherited widgets](/assets/images/docs/arch-overview/inherited-widget.png){:width="50%" .diagram-wrap}
493493

494494
[`InheritedWidget`]: {{site.api}}/flutter/widgets/InheritedWidget-class.html
495495

@@ -602,8 +602,7 @@ rendering pipeline is that **simple is fast**.
602602
Flutter has a straightforward pipeline for how data flows to
603603
the system, as shown in the following sequencing diagram:
604604

605-
![Render pipeline sequencing
606-
diagram](/assets/images/docs/arch-overview/render-pipeline.png){:width="100%"}
605+
![Render pipeline sequencing diagram](/assets/images/docs/arch-overview/render-pipeline.png){:width="100%" .diagram-wrap}
607606

608607
Let's take a look at some of these phases in greater detail.
609608

@@ -648,8 +647,7 @@ as `RawImage` and `RichText` during the build process. The eventual widget
648647
hierarchy might therefore be deeper than what the code represents,
649648
as in this case[^2]:
650649

651-
![Render pipeline sequencing
652-
diagram](/assets/images/docs/arch-overview/widgets.png){:width="35%"}
650+
![Render pipeline sequencing diagram](/assets/images/docs/arch-overview/widgets.png){:width="40%" .diagram-wrap}
653651

654652
This explains why, when you examine the tree through
655653
a debug tool such as the
@@ -667,8 +665,7 @@ hierarchy. There are two basic types of elements:
667665
- `RenderObjectElement`, an element that participates in the layout or paint
668666
phases.
669667

670-
![Render pipeline sequencing
671-
diagram](/assets/images/docs/arch-overview/widget-element.png){:width="85%"}
668+
![Render pipeline sequencing diagram](/assets/images/docs/arch-overview/widget-element.png){:width="85%" .diagram-wrap}
672669

673670
`RenderObjectElement`s are an intermediary between their widget analog and the
674671
underlying `RenderObject`, which we'll come to later.
@@ -715,8 +712,7 @@ an image, and
715712
[`RenderTransform`]({{site.api}}/flutter/rendering/RenderTransform-class.html)
716713
applies a transformation before painting its child.
717714

718-
![Differences between the widgets hierarchy and the element and render
719-
trees](/assets/images/docs/arch-overview/trees.png){:width="100%"}
715+
![Differences between the widgets hierarchy and the element and render trees](/assets/images/docs/arch-overview/trees.png){:width="100%" .diagram-wrap}
720716

721717
Most Flutter widgets are rendered by an object that inherits from the
722718
`RenderBox` subclass, which represents a `RenderObject` of fixed size in a 2D
@@ -730,8 +726,7 @@ the child _must_ respect the constraints given to it by its parent. Children
730726
respond by **passing up a size** to their parent object within the constraints
731727
the parent established.
732728

733-
![Constraints go down, sizes go
734-
up](/assets/images/docs/arch-overview/constraints-sizes.png){:width="80%"}
729+
![Constraints go down, sizes go up](/assets/images/docs/arch-overview/constraints-sizes.png){:width="70%" .diagram-wrap}
735730

736731
At the end of this single walk through the tree, every object has a defined size
737732
within its parent's constraints and is ready to be painted by calling the
@@ -853,8 +848,7 @@ Swift. Data is serialized from a Dart type like `Map` into a standard format,
853848
and then deserialized into an equivalent representation in Kotlin (such as
854849
`HashMap`) or Swift (such as `Dictionary`).
855850

856-
![How platform channels allow Flutter to communicate with host
857-
code](/assets/images/docs/arch-overview/platform-channels.png){:width="70%"}
851+
![How platform channels allow Flutter to communicate with host code](/assets/images/docs/arch-overview/platform-channels.png){:width="65%" .diagram-wrap}
858852

859853
The following is a short platform channel example of a Dart call to a receiving
860854
event handler in Kotlin (Android) or Swift (iOS):
@@ -1100,6 +1094,7 @@ Flutter offers two _build_ modes:
11001094
<td>`--wasm`</td>
11011095
<td>Skwasm (preferred), CanvasKit (fallback)</td>
11021096
</tr>
1097+
</table>
11031098

11041099

11051100
The default mode makes only CanvasKit renderer available.
@@ -1112,7 +1107,7 @@ and falls back to CanvasKit otherwise.
11121107
The draw.io source for the following image is in /diagrams/resources
11131108
{% endcomment %}
11141109

1115-
![Flutter web architecture](/assets/images/docs/arch-overview/web-framework-diagram.png)
1110+
![Flutter web architecture](/assets/images/docs/arch-overview/web-framework-diagram.png){:width="80%" .diagram-wrap}
11161111

11171112
Perhaps the most notable difference compared to other
11181113
platforms on which Flutter runs is that there is no need

src/content/ui/interactivity/actions-and-shortcuts.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ contexts. An [`Action`][] can be a simple callback (as in the case of
2929
the [`CallbackAction`][]) or something more complex that integrates with entire
3030
undo/redo architectures (for example) or other logic.
3131

32-
![Using Shortcuts Diagram][]{:width="100%"}
32+
![Using Shortcuts Diagram][]{:width="100%" .diagram-wrap}
3333

3434
[`Shortcuts`][] are key bindings that activate by pressing a key or combination
3535
of keys. The key combinations reside in a table with their bound intent. When

src/content/ui/interactivity/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ replacing the solid star with an outline and
3333
decreasing the count. Tapping again favorites the lake,
3434
drawing a solid star and increasing the count.
3535

36-
{% render docs/app-figure.md, image:"ui/favorited-not-favorited.png", alt:"The custom widget you'll create" %}
36+
{% render docs/app-figure.md, image:"ui/favorited-not-favorited.png", alt:"The custom widget you'll create", img-class:"diagram-wrap" %}
3737

3838
To accomplish this, you'll create a single custom widget
3939
that includes both the star and the count,

src/content/ui/layout/index.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ can see the visual layout.
4949
Here's a diagram of the widget tree for the previous
5050
example:
5151

52-
<img src='/assets/images/docs/ui/layout/sample-flutter-layout.png' class="text-center" alt="Node tree">
52+
<img src='/assets/images/docs/ui/layout/sample-flutter-layout.png' class="text-center diagram-wrap" alt="Node tree">
5353

5454
Most of this should look as you might expect, but you might be wondering
5555
about the containers (shown in pink). [`Container`][] is a widget class
@@ -361,11 +361,11 @@ columns inside of rows or columns.
361361
This layout is organized as a `Row`. The row contains two children:
362362
a column on the left, and an image on the right:
363363

364-
<img src='/assets/images/docs/ui/layout/pavlova-diagram.png' alt="Screenshot with callouts showing the row containing two children">
364+
<img src='/assets/images/docs/ui/layout/pavlova-diagram.png' class="diagram-wrap" alt="Screenshot with callouts showing the row containing two children">
365365

366366
The left column's widget tree nests rows and columns.
367367

368-
<img src='/assets/images/docs/ui/layout/pavlova-left-column-diagram.png' alt="Diagram showing a left column broken down to its sub-rows and sub-columns">
368+
<img src='/assets/images/docs/ui/layout/pavlova-left-column-diagram.png' class="diagram-wrap" alt="Diagram showing a left column broken down to its sub-rows and sub-columns">
369369

370370
You'll implement some of Pavlova's layout code in
371371
[Nesting rows and columns](#nesting-rows-and-columns).
@@ -399,10 +399,10 @@ axis runs horizontally.
399399

400400
<div class="side-by-side">
401401
<div class="centered-rows">
402-
<img src='/assets/images/docs/ui/layout/row-diagram.png' alt="Diagram showing the main axis and cross axis for a row">
402+
<img src='/assets/images/docs/ui/layout/row-diagram.png' class="diagram-wrap" alt="Diagram showing the main axis and cross axis for a row">
403403
</div>
404404
<div class="centered-rows">
405-
<img src='/assets/images/docs/ui/layout/column-diagram.png' alt="Diagram showing the main axis and cross axis for a column">
405+
<img src='/assets/images/docs/ui/layout/column-diagram.png' class="diagram-wrap" alt="Diagram showing the main axis and cross axis for a column">
406406
</div>
407407
</div>
408408

@@ -442,7 +442,7 @@ space evenly between, before, and after each image.
442442

443443
</div>
444444
<div>
445-
<img src='/assets/images/docs/ui/layout/row-spaceevenly-visual.png' alt="Row with 3 evenly spaced images">
445+
<img src='/assets/images/docs/ui/layout/row-spaceevenly-visual.png' class="small-diagram-wrap" alt="Row with 3 evenly spaced images">
446446

447447
**App source:** [row_column]({{examples}}/layout/row_column)
448448
</div>
@@ -471,7 +471,7 @@ space evenly between, above, and below each image.
471471

472472
</div>
473473
<div class="text-center">
474-
<img src='/assets/images/docs/ui/layout/column-visual.png' height="250px" alt="Column showing 3 images spaced evenly">
474+
<img src='/assets/images/docs/ui/layout/column-visual.png' height="250px" class="small-diagram-wrap" alt="Column showing 3 images spaced evenly">
475475

476476
**App source:** [row_column]({{examples}}/layout/row_column)
477477
</div>
@@ -487,7 +487,7 @@ When a layout is too large to fit a device, a yellow
487487
and black striped pattern appears along the affected edge.
488488
Here is an [example][sizing] of a row that is too wide:
489489

490-
<img src='/assets/images/docs/ui/layout/layout-too-large.png' class="text-center" alt="Overly-wide row">
490+
<img src='/assets/images/docs/ui/layout/layout-too-large.png' class="text-center" style="max-height: 15rem;" alt="Overly-wide row">
491491

492492
Widgets can be sized to fit within a row or column by using the
493493
[`Expanded`][] widget. To fix the previous example where the
@@ -511,7 +511,7 @@ wrap each image with an `Expanded` widget.
511511

512512
</div>
513513
<div>
514-
<img src='/assets/images/docs/ui/layout/row-expanded-2-visual.png' alt="Row of 3 images that are too wide, but each is constrained to take only 1/3 of the space">
514+
<img src='/assets/images/docs/ui/layout/row-expanded-2-visual.png' class="small-diagram-wrap" alt="Row of 3 images that are too wide, but each is constrained to take only 1/3 of the space">
515515

516516
**App source:** [sizing]({{examples}}/layout/sizing)
517517
</div>
@@ -540,7 +540,7 @@ the flex factor of the middle image to 2:
540540

541541
</div>
542542
<div>
543-
<img src='/assets/images/docs/ui/layout/row-expanded-visual.png' alt="Row of 3 images with the middle image twice as wide as the others">
543+
<img src='/assets/images/docs/ui/layout/row-expanded-visual.png' class="small-diagram-wrap" alt="Row of 3 images with the middle image twice as wide as the others">
544544

545545
**App source:** [sizing]({{examples}}/layout/sizing)
546546
</div>
@@ -575,7 +575,7 @@ uses this property to pack the star icons together.
575575

576576
</div>
577577
<div>
578-
<img src='/assets/images/docs/ui/layout/packed.png' class="simple-border" alt="Row of 5 stars, packed together in the middle of the row">
578+
<img src='/assets/images/docs/ui/layout/packed.png' class="small-diagram-wrap" alt="Row of 5 stars, packed together in the middle of the row">
579579

580580
**App source:** [pavlova]({{examples}}/layout/pavlova)
581581
</div>
@@ -596,7 +596,7 @@ columns of icons and text.
596596

597597
The widget tree for the ratings row:
598598

599-
<img src='/assets/images/docs/ui/layout/widget-tree-pavlova-rating-row.png' class="text-center" alt="Ratings row widget tree">
599+
<img src='/assets/images/docs/ui/layout/widget-tree-pavlova-rating-row.png' class="text-center diagram-wrap" alt="Ratings row widget tree">
600600

601601
The `ratings` variable creates a row containing a smaller row
602602
of 5-star icons, and text:
@@ -645,7 +645,7 @@ The icons row, below the ratings row, contains 3 columns;
645645
each column contains an icon and two lines of text,
646646
as you can see in its widget tree:
647647

648-
<img src='/assets/images/docs/ui/layout/widget-tree-pavlova-icon-row.png' class="text-center" alt="Icon widget tree">
648+
<img src='/assets/images/docs/ui/layout/widget-tree-pavlova-icon-row.png' class="text-center diagram-wrap" alt="Icon widget tree">
649649

650650
The `iconList` variable defines the icons row:
651651

@@ -848,7 +848,7 @@ color or image.
848848

849849
</div>
850850
<div class="text-center">
851-
<img src='/assets/images/docs/ui/layout/margin-padding-border.png' alt="Diagram showing: margin, border, padding, and content">
851+
<img src='/assets/images/docs/ui/layout/margin-padding-border.png' class="diagram-wrap" alt="Diagram showing: margin, border, padding, and content">
852852
</div>
853853
</div>
854854

0 commit comments

Comments
 (0)