Skip to content

Commit 334f205

Browse files
committed
content: Match code blocks' background and border colors to web
(Specifically by eliminating the border and using a particular shade of gray for the background.) Also the background of inline code, which in web uses the same CSS variable as the background color for code blocks.
1 parent bd37691 commit 334f205

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

lib/widgets/content.dart

+7-6
Original file line numberDiff line numberDiff line change
@@ -406,12 +406,13 @@ class CodeBlock extends StatelessWidget {
406406

407407
final CodeBlockNode node;
408408

409-
static final _borderColor = const HSLColor.fromAHSL(0.15, 0, 0, 0).toColor();
410-
411409
@override
412410
Widget build(BuildContext context) {
413411
return _CodeBlockContainer(
414-
borderColor: _borderColor,
412+
// (The other caller, MathBlock, passes a nontransparent color.)
413+
// TODO(#46) remove comment about MathBlock when TeX is implemented;
414+
// presumably it won't apply anymore.
415+
borderColor: Colors.transparent,
415416
child: Text.rich(_buildNodes(node.spans)));
416417
}
417418

@@ -436,7 +437,7 @@ class _CodeBlockContainer extends StatelessWidget {
436437
Widget build(BuildContext context) {
437438
return Container(
438439
decoration: BoxDecoration(
439-
color: Colors.white,
440+
color: const HSLColor.fromAHSL(0.04, 0, 0, 0).toColor(),
440441
border: Border.all(
441442
width: 1,
442443
color: borderColor),
@@ -725,7 +726,6 @@ class _InlineContentBuilder {
725726
// TODO `code`: find equivalent of web's `unicode-bidi: embed; direction: ltr`
726727

727728
return _buildNodes(
728-
// Use a light gray background, instead of a border.
729729
style: widget.style
730730
.merge(_kInlineCodeStyle)
731731
.apply(fontSizeFactor: _kInlineCodeFontSizeFactor),
@@ -770,7 +770,8 @@ const _kInlineCodeFontSizeFactor = 0.825;
770770
// assuming the text gets the effect of [weightVariableTextStyle]
771771
// through inheritance, e.g., from a [DefaultTextStyle].
772772
final _kInlineCodeStyle = kMonospaceTextStyle
773-
.merge(const TextStyle(backgroundColor: Color(0xffeeeeee)));
773+
.merge(TextStyle(
774+
backgroundColor: const HSLColor.fromAHSL(0.04, 0, 0, 0).toColor()));
774775

775776
final _kCodeBlockStyle = kMonospaceTextStyle
776777
.merge(const TextStyle(fontSize: 0.825 * kBaseFontSize))

0 commit comments

Comments
 (0)