Skip to content

Commit defdacb

Browse files
Lawndlwdmatthprost
authored andcommitted
fix: add error message on code editor (#5479)
1 parent 3528297 commit defdacb

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

.changeset/pretty-webs-share.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@ultraviolet/plus": patch
3+
---
4+
5+
Add error message on Code editor

packages/plus/src/components/CodeEditor/CodeEditor.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ const EditorContainer = styled.div`
8080
8181
.cm-editor.cm-focused {
8282
box-shadow: none;
83-
border: 1px solid transparent;
83+
border: 1px solid transparent;
8484
}
8585
}
8686
`
@@ -125,6 +125,7 @@ type CodeEditorProps = {
125125
'aria-label'?: string
126126
'data-testid'?: string
127127
className?: string
128+
error?: string
128129
lineNumbers?: boolean
129130
}
130131

@@ -145,6 +146,7 @@ export const CodeEditor = ({
145146
'aria-label': ariaLabel,
146147
'data-testid': dataTestId,
147148
className,
149+
error,
148150
lineNumbers = true,
149151
}: CodeEditorProps) => (
150152
<StyledStack data-disabled={disabled} gap={0.5}>
@@ -188,7 +190,12 @@ export const CodeEditor = ({
188190
</StyledCopyButton>
189191
) : null}
190192
</EditorContainer>
191-
{helper ? (
193+
{error && typeof error !== 'boolean' ? (
194+
<Text as="span" sentiment="danger" variant="caption">
195+
{error}
196+
</Text>
197+
) : null}
198+
{!error && helper ? (
192199
<Text as="span" prominence="weak" sentiment="neutral" variant="caption">
193200
{helper}
194201
</Text>

0 commit comments

Comments
 (0)