Skip to content

Commit

Permalink
💄 style: Fix CodeEditor
Browse files Browse the repository at this point in the history
  • Loading branch information
canisminor1990 committed Jan 5, 2025
1 parent 8638c5b commit 90569fc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/CodeEditor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export interface CodeEditorProps {
autoFocus?: boolean;
className?: string;
disabled?: boolean;
fontSize?: number | string;
form?: string;
ignoreTabKey?: boolean;
insertSpaces?: boolean;
Expand Down Expand Up @@ -55,11 +56,12 @@ const CodeEditor = forwardRef<TextAreaRef, CodeEditorProps>(
className,
textareaClassName,
type = 'ghost',
fontSize = 12,
...rest
},
ref,
) => {
const { styles, cx } = useStyles({ resize, type });
const { styles, cx } = useStyles({ fontSize, resize, type });
return (
<div className={cx(styles.container, className)} style={style}>
{/* @ts-ignore */}
Expand Down
16 changes: 15 additions & 1 deletion src/CodeEditor/style.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
import { createStyles } from 'antd-style';
import { isNumber } from 'lodash-es';

export const useStyles = createStyles(
({ cx, css, token }, { type, resize }: { resize: boolean; type: 'ghost' | 'block' | 'pure' }) => {
(
{ cx, css, token },
{
type,
resize,
fontSize,
}: { fontSize: string | number; resize: boolean; type: 'ghost' | 'block' | 'pure' },
) => {
const size = isNumber(fontSize) ? `${fontSize}px` : fontSize;
const typeStylish = css`
padding-block: 8px;
padding-inline: 12px;
Expand All @@ -28,6 +37,11 @@ export const useStyles = createStyles(
overflow: hidden auto;
width: 100%;
height: fit-content;
* {
font-size: ${size} !important;
line-height: 1.5 !important;
}
`,
),
editor: css`
Expand Down

0 comments on commit 90569fc

Please sign in to comment.