-
Notifications
You must be signed in to change notification settings - Fork 358
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(notebook-cell): add code editor and notebook cell components (#2220
- Loading branch information
Showing
15 changed files
with
971 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
:host { | ||
--cv-editor-width: 100%; | ||
--cv-editor-height: 100%; | ||
|
||
box-sizing: border-box; | ||
|
||
.monaco-editor { | ||
.lines-content.monaco-editor-background { | ||
height: var(--cv-editor-height); | ||
width: var(--cv-editor-width); | ||
} | ||
} | ||
|
||
.monaco-editor-background { | ||
background-color: var(--cv-theme-surface); | ||
} | ||
} | ||
|
||
.editor { | ||
height: var(--cv-editor-height); | ||
min-height: var(--cv-editor-height); | ||
max-width: calc(var(--cv-editor-width) - 2px); | ||
width: var(--cv-editor-width); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/** | ||
* @vitest-environment jsdom | ||
*/ | ||
import { it, describe, expect } from 'vitest'; | ||
import { CovalentCodeEditor } from './code-editor'; | ||
|
||
describe('Code editor', () => { | ||
it('should work', () => { | ||
expect(new CovalentCodeEditor()).toBeDefined(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import './code-editor'; | ||
|
||
const sqlContent = ` | ||
SELECT * FROM load_to_teradata ( | ||
ON ( | ||
SELECT 'class' AS class_col, | ||
'variable' AS variable_col, | ||
'type' AS type_col, | ||
category, | ||
cnt, | ||
'sum' AS sum_col, | ||
'sumSq', | ||
'totalCnt' | ||
FROM aster_nb_modelSC | ||
) | ||
tdpid ('sdt12432.labs.teradata.com') | ||
username ('sample_user') | ||
password ('sample_user') | ||
target_table ('td_nb_modelSC') | ||
); | ||
`; | ||
|
||
export default { | ||
title: 'Components/Code Editor', | ||
args: { | ||
theme: 'cv-light', | ||
code: sqlContent, | ||
language: 'sql', | ||
}, | ||
}; | ||
|
||
const Template = ({ theme, language, code }) => { | ||
return ` | ||
<div style="width: 800px; height: 100%"> | ||
<cv-code-editor language="${language}" theme="${theme}" code="${code}"> | ||
</cv-code-editor> | ||
</div> | ||
`; | ||
}; | ||
|
||
export const Basic = Template.bind(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
import * as tokens from '@covalent/tokens'; | ||
|
||
export const cvEditorDarkTheme = { | ||
base: 'vs-dark', | ||
inherit: true, | ||
rules: [ | ||
{ | ||
token: '', | ||
foreground: tokens.CvDarkCodeSnippetColor, | ||
background: tokens.CvThemeDarkColorsSurface, | ||
}, | ||
{ | ||
token: 'comment', | ||
foreground: tokens.CvDarkCodeSnippetComment, | ||
fontStyle: 'italic', | ||
}, | ||
{ token: 'keyword', foreground: tokens.CvDarkCodeSnippetKeyword }, | ||
{ token: 'variable', foreground: tokens.CvDarkCodeSnippetVariable }, | ||
{ token: 'string', foreground: tokens.CvDarkCodeSnippetString }, | ||
{ token: 'number', foreground: tokens.CvDarkCodeSnippetVariable }, | ||
{ token: 'type', foreground: tokens.CvDarkCodeSnippetClass }, | ||
{ token: 'class', foreground: tokens.CvDarkCodeSnippetClass }, | ||
{ token: 'function', foreground: tokens.CvDarkCodeSnippetTitle }, | ||
{ token: 'operator', foreground: tokens.CvDarkCodeSnippetLiteral }, | ||
{ token: 'constant', foreground: tokens.CvDarkCodeSnippetLiteral }, | ||
{ token: 'builtin', foreground: tokens.CvDarkCodeSnippetClass }, | ||
{ token: 'punctuation', foreground: tokens.CvDarkCodeSnippetColor }, | ||
{ token: 'meta', foreground: tokens.CvDarkCodeSnippetTitle }, | ||
{ token: 'tag', foreground: tokens.CvDarkCodeSnippetSelector }, | ||
{ token: 'attribute.name', foreground: tokens.CvDarkCodeSnippetVariable }, | ||
{ token: 'attribute.value', foreground: tokens.CvDarkCodeSnippetString }, | ||
{ token: 'invalid', foreground: tokens.CvDarkNegative }, | ||
{ token: 'strong', fontStyle: 'bold' }, | ||
{ token: 'emphasis', fontStyle: 'italic' }, | ||
{ | ||
token: 'link', | ||
foreground: tokens.CvDarkCodeSnippetTitle, | ||
fontStyle: 'underline', | ||
}, | ||
], | ||
colors: { | ||
'editor.background': tokens.CvThemeDarkColorsSurface, | ||
'editor.foreground': tokens.CvDarkCodeSnippetColor, | ||
'editorCursor.foreground': tokens.CvDarkTextSecondaryOnBackground, | ||
}, | ||
}; | ||
|
||
export const cvEditorLightTheme = { | ||
base: 'vs', | ||
inherit: true, | ||
rules: [ | ||
{ | ||
token: '', | ||
foreground: tokens.CvLightCodeSnippetColor, | ||
background: tokens.CvLightSurfaceCanvas, | ||
}, | ||
{ | ||
token: 'comment', | ||
foreground: tokens.CvLightCodeSnippetComment, | ||
fontStyle: 'italic', | ||
}, | ||
{ token: 'keyword', foreground: tokens.CvLightCodeSnippetKeyword }, | ||
{ token: 'doctag', foreground: tokens.CvLightCodeSnippetKeyword }, | ||
{ token: 'formula', foreground: tokens.CvLightCodeSnippetKeyword }, | ||
{ token: 'variable', foreground: tokens.CvLightCodeSnippetVariable }, | ||
{ token: 'string', foreground: tokens.CvLightCodeSnippetString }, | ||
{ token: 'number', foreground: tokens.CvLightCodeSnippetVariable }, | ||
{ token: 'type', foreground: tokens.CvLightCodeSnippetClass }, | ||
{ token: 'class', foreground: tokens.CvLightCodeSnippetClass }, | ||
{ token: 'function', foreground: tokens.CvLightCodeSnippetTitle }, | ||
{ token: 'literal', foreground: tokens.CvLightCodeSnippetLiteral }, | ||
{ token: 'operator', foreground: tokens.CvLightCodeSnippetLiteral }, | ||
{ token: 'constant', foreground: tokens.CvLightCodeSnippetLiteral }, | ||
{ token: 'builtin', foreground: tokens.CvLightCodeSnippetClass }, | ||
{ token: 'punctuation', foreground: tokens.CvLightCodeSnippetColor }, | ||
{ token: 'meta', foreground: tokens.CvLightCodeSnippetTitle }, | ||
{ token: 'tag', foreground: tokens.CvLightCodeSnippetSelector }, | ||
{ token: 'attribute.name', foreground: tokens.CvLightCodeSnippetVariable }, | ||
{ token: 'attribute.value', foreground: tokens.CvLightCodeSnippetString }, | ||
{ token: 'invalid', foreground: tokens.CvLightNegative }, | ||
{ token: 'strong', fontStyle: 'bold' }, | ||
{ token: 'emphasis', fontStyle: 'italic' }, | ||
{ | ||
token: 'link', | ||
foreground: tokens.CvLightCodeSnippetTitle, | ||
fontStyle: 'underline', | ||
}, | ||
], | ||
colors: { | ||
'editor.background': tokens.CvThemeLightColorsSurface, | ||
'editor.foreground': tokens.CvLightCodeSnippetColor, | ||
'editorCursor.foreground': tokens.CvLightTextSecondaryOnBackground, | ||
}, | ||
}; |
Oops, something went wrong.