Skip to content

Commit

Permalink
feat(ui): allow customizing min height of code editor (#9920)
Browse files Browse the repository at this point in the history
Requirement for #9645.

Dynamic code field resizing currently is broken for line-breaks - need
to address that in a future PR.
  • Loading branch information
AlessioGr authored Dec 12, 2024
1 parent c8046ca commit bae2fe5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/ui/src/elements/CodeEditor/CodeEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ const Editor = (EditorImport.default || EditorImport) as unknown as typeof Edito
const baseClass = 'code-editor'

const CodeEditor: React.FC<Props> = (props) => {
const { className, maxHeight, options, readOnly, ...rest } = props
const [dynamicHeight, setDynamicHeight] = useState(20)
const { theme } = useTheme()
const { className, maxHeight, minHeight, options, readOnly, ...rest } = props
const MIN_HEIGHT = minHeight ?? 56 // equivalent to 3 lines

const MIN_HEIGHT = 56 // equivalent to 3 lines
const [dynamicHeight, setDynamicHeight] = useState(MIN_HEIGHT)
const { theme } = useTheme()

const classes = [
baseClass,
Expand Down
4 changes: 4 additions & 0 deletions packages/ui/src/elements/CodeEditor/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@ import type { EditorProps } from '@monaco-editor/react'

export type Props = {
maxHeight?: number
/**
* @default 56 (3 lines)
*/
minHeight?: number
readOnly?: boolean
} & EditorProps

0 comments on commit bae2fe5

Please sign in to comment.