From 739829331bfb9591d6bfcc165a3dbfd290f3d477 Mon Sep 17 00:00:00 2001 From: Ajay Bura <32841439+ajbura@users.noreply.github.com> Date: Sun, 27 Jul 2025 12:15:44 +0530 Subject: [PATCH] move floating expand button to code block header --- src/app/plugins/react-custom-html-parser.tsx | 38 ++++++++++---------- src/app/styles/CustomHtml.css.ts | 5 +-- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/src/app/plugins/react-custom-html-parser.tsx b/src/app/plugins/react-custom-html-parser.tsx index e90e0399..665922c9 100644 --- a/src/app/plugins/react-custom-html-parser.tsx +++ b/src/app/plugins/react-custom-html-parser.tsx @@ -16,7 +16,7 @@ import { } from 'html-react-parser'; import { MatrixClient } from 'matrix-js-sdk'; import classNames from 'classnames'; -import { Box, Chip, Header, Icon, IconButton, Icons, Scroll, Text, toRem } from 'folds'; +import { Box, Chip, config, Header, Icon, IconButton, Icons, Scroll, Text, toRem } from 'folds'; import { IntermediateRepresentation, Opts as LinkifyOpts, OptFn } from 'linkifyjs'; import Linkify from 'linkify-react'; import { ErrorBoundary } from 'react-error-boundary'; @@ -265,21 +265,34 @@ export function CodeBlock({ {language ?? 'Code'} - + } > {copied ? 'Copied' : 'Copy'} + {largeCodeBlock && ( + + + + )} - {largeCodeBlock && ( - - - - - - )} + {largeCodeBlock && !expanded && } ); } diff --git a/src/app/styles/CustomHtml.css.ts b/src/app/styles/CustomHtml.css.ts index e600c1cc..f717669c 100644 --- a/src/app/styles/CustomHtml.css.ts +++ b/src/app/styles/CustomHtml.css.ts @@ -95,6 +95,7 @@ export const CodeBlock = style([ export const CodeBlockHeader = style({ padding: `0 ${config.space.S200} 0 ${config.space.S300}`, borderBottomWidth: config.borderWidth.B300, + gap: config.space.S200, }); export const CodeBlockInternal = style([ CodeFont, @@ -104,14 +105,14 @@ export const CodeBlockInternal = style([ }, ]); -export const CodeBlockBottomBar = style({ +export const CodeBlockBottomShadow = style({ position: 'absolute', bottom: 0, left: 0, right: 0, pointerEvents: 'none', - padding: config.space.S200, + height: config.space.S400, background: `linear-gradient(to top, #00000022, #00000000)`, });