Skip to content

Commit

Permalink
fix code editor classes and styles
Browse files Browse the repository at this point in the history
  • Loading branch information
haschek committed Nov 6, 2024
1 parent a766e6f commit 51c279e
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 21 deletions.
29 changes: 21 additions & 8 deletions src/components/AutoSuggestion/AutoSuggestion.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,37 +27,50 @@
}
}

.#{$eccgui}-autosuggestion__inputfield {
background-color: $eccgui-color-textfield-background;
}

.#{$eccgui}-singlelinecodeeditor {
position: relative;
padding: 0 1px;
padding: 0;

[class^="cm-theme"] {
width: 100%;
}

&:has(.cm-editor.cm-focused) {
box-shadow: input-transition-shadow($input-shadow-color-focus, true), $input-box-shadow-focus;
}

.cm-editor {
top: 2px;
top: 1px;
height: calc(#{$eccgui-size-textfield-height-regular} - 2px);
padding: 0;
margin: 0;
overflow: hidden;
background-color: transparent;
border-radius: 0;
box-shadow: none;

&.cm-focused {
outline: none;
box-shadow: none;
}

.cm-scroller {
height: 100%;
padding: 0;
margin: 0;
overflow: auto hidden !important;
}

.CodeMirror-vscrollbar {
display: none !important;
}

.cm-content {
vertical-align: middle;
display: flex;
flex-direction: column;
justify-content: center;
height: 100%;
min-height: 100%;
padding: 0;
border: none;
}

Expand Down
1 change: 0 additions & 1 deletion src/components/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,5 @@
@import "./Typography/typography";
@import "./Workspace/workspace";
@import "./Accordion/accordion";
@import "./AutoSuggestion/AutoSuggestion";
@import "./Badge/badge";
@import "./PropertyValuePair/propertyvalue";
7 changes: 1 addition & 6 deletions src/extensions/_index.scss
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
@import "./react-flow/react-flow";

/*
CodeMirror styles are already included by the base component styles
because it is used as lib for elements there already.
@import "./codemirror/codemirror";
*/

@import "./../components/AutoSuggestion/AutoSuggestion"; // the whole element should moved to extensions forlder
@import "./uppy/fileupload";
12 changes: 8 additions & 4 deletions src/extensions/codemirror/CodeMirror.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export interface CodeEditorProps {
/** Long lines are wrapped and displayed on multiple lines */
wrapLines?: boolean;

outerDivAttributes?: Partial<AllHTMLAttributes<HTMLDivElement>>;
outerDivAttributes?: Omit<React.HTMLAttributes<HTMLDivElement>, "id" | "data-test-id">;

/**
* Size in spaces that is used for a tabulator key.
Expand Down Expand Up @@ -276,11 +276,15 @@ export const CodeEditor = ({

return (
<div
id={id ? id : `codemirror-${name}`}
{...outerDivAttributes}
// overwrite/extend some attributes
id={id ? id : name ? `codemirror-${name}` : undefined}
ref={parent}
data-test-id="codemirror-wrapper"
className={`${eccgui}-codeeditor ${eccgui}-codeeditor--mode-${mode}`}
{...outerDivAttributes}
className={
`${eccgui}-codeeditor ${eccgui}-codeeditor--mode-${mode}` +
(outerDivAttributes?.className ? ` ${outerDivAttributes?.className}` : "")
}
/>
);
};
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/codemirror/_codemirror.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ $eccgui-color-codeeditor-background: $eccgui-color-textfield-background !default
// fix size to prevent wrong calculation of other elements
padding: 0;
margin: 1px;
cursor: text;
}

&.cm-focused {
Expand All @@ -54,6 +53,7 @@ $eccgui-color-codeeditor-background: $eccgui-color-textfield-background !default
}

.cm-content {
cursor: text;
border-right-width: $eccgui-size-inline-whitespace !important;
}

Expand Down
1 change: 0 additions & 1 deletion src/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ $prefix-carbon: $prefix;
// == Load basic components styles =============================================

@import "./components";
@import "./extensions/codemirror/codemirror";

// set more readable variable for prefix
$prefix-eccgui: $eccgui;
Expand Down

0 comments on commit 51c279e

Please sign in to comment.