generated from solidjs-community/solid-lib-starter
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
509 additions
and
29 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
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,56 @@ | ||
import { createSignal, JSX } from 'solid-js' | ||
import { MonacoDiffEditor } from '../src' | ||
|
||
import styles from './MonacoPlayground.module.css' | ||
import { exampleData } from './example-data' | ||
|
||
const builtinThemes = ['vs', 'vs-dark', 'hc-light', 'hc-black'] as const | ||
|
||
export const MonacoDiffPlayground = () => { | ||
const [theme, setTheme] = createSignal<string>(builtinThemes[0]) | ||
const [modified, setModified] = createSignal<string>(exampleData[0].content) | ||
const [original, setOriginal] = createSignal<string>(exampleData[0].content) | ||
const [language, setLanguage] = createSignal<string>(exampleData[0].language) | ||
|
||
const handleThemeChange: JSX.EventHandler<HTMLSelectElement, Event> = e => { | ||
setTheme(e.currentTarget.value) | ||
} | ||
|
||
const handleLanguageChange: JSX.EventHandler<HTMLSelectElement, Event> = e => { | ||
const sampleContent = exampleData.find(data => data.language === e.currentTarget.value) | ||
if (!sampleContent) { | ||
return | ||
} | ||
|
||
setLanguage(sampleContent.language) | ||
setModified(sampleContent.content) | ||
setOriginal(sampleContent.content) | ||
} | ||
|
||
return ( | ||
<div class={styles.root}> | ||
<div class={styles.settings}> | ||
<select name="theme" onChange={handleThemeChange}> | ||
{builtinThemes.map(theme => ( | ||
<option value={theme}>{theme}</option> | ||
))} | ||
</select> | ||
|
||
<select name="language" onChange={handleLanguageChange}> | ||
{exampleData.map(data => ( | ||
<option value={data.language}>{data.language}</option> | ||
))} | ||
</select> | ||
</div> | ||
<MonacoDiffEditor | ||
options={{ padding: { top: 24 } }} | ||
originalLanguage={language()} | ||
modifiedLanguage={language()} | ||
theme={theme()} | ||
onChange={setModified} | ||
modified={modified()} | ||
original={original()} | ||
/> | ||
</div> | ||
) | ||
} |
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 |
---|---|---|
@@ -1,9 +1,12 @@ | ||
.root { | ||
height: 100%; | ||
display: flex; | ||
flex-direction: column; | ||
} | ||
|
||
.settings { | ||
display: flex; | ||
gap: 1rem; | ||
padding: 1rem 2rem; | ||
} | ||
|
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 |
---|---|---|
|
@@ -39,3 +39,4 @@ select option:hover, | |
select option:active { | ||
background-color: #f0f0f0; | ||
} | ||
|
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,13 @@ | ||
import { createRoot } from 'solid-js' | ||
import { describe, expect, it } from 'vitest' | ||
import { MonacoDiffEditor } from '../src' | ||
|
||
// TODO: add real tests | ||
describe('MonacoDiffEditor', () => { | ||
it('renders a MonacoDiffEditor component', async () => { | ||
createRoot(() => { | ||
const container = (<MonacoDiffEditor />) as HTMLDivElement | ||
expect(container.outerHTML).toMatchSnapshot() | ||
}) | ||
}) | ||
}) |
Oops, something went wrong.