Skip to content

Commit

Permalink
feat: allow padding sides to be set individually (#96)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasmotta committed Aug 18, 2022
1 parent ff082f8 commit 7f10c67
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/index.tsx
@@ -1,5 +1,7 @@
import * as React from 'react';

type Padding<T> = T | { top?: T; right?: T; bottom?: T; left?: T };

type Props = React.HTMLAttributes<HTMLDivElement> & {
// Props for the component
value: string;
Expand All @@ -8,7 +10,7 @@ type Props = React.HTMLAttributes<HTMLDivElement> & {
tabSize: number;
insertSpaces: boolean;
ignoreTabKey: boolean;
padding: number | string;
padding: Padding<number | string>;
style?: React.CSSProperties;

// Props for the textarea
Expand Down Expand Up @@ -539,10 +541,10 @@ export default class Editor extends React.Component<Props, State> {
} = this.props;

const contentStyle = {
paddingTop: padding,
paddingRight: padding,
paddingBottom: padding,
paddingLeft: padding,
paddingTop: typeof padding === 'object' ? padding.top : padding,
paddingRight: typeof padding === 'object' ? padding.right : padding,
paddingBottom: typeof padding === 'object' ? padding.bottom : padding,
paddingLeft: typeof padding === 'object' ? padding.left : padding,
};

const highlighted = highlight(value);
Expand Down

0 comments on commit 7f10c67

Please sign in to comment.