Skip to content

Commit

Permalink
Fix repo setup
Browse files Browse the repository at this point in the history
Yarn -> npm
Use nix modules
Upgrade vite
Add demo for HTML document
  • Loading branch information
masad-frost authored and replitfaris committed Sep 7, 2023
1 parent 9185b06 commit 5867afc
Show file tree
Hide file tree
Showing 8 changed files with 4,186 additions and 1,296 deletions.
13 changes: 3 additions & 10 deletions .replit
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
run="yarn run dev"
run="npm run dev"

[packager]
language = "nodejs-yarn"
[packager.features]
packageSearch = true
guessImports = true
modules = ["nodejs-18:v3-20230608-f4cd419"]

[languages.js]
pattern = "**/*.ts"
[languages.js.languageServer]
start = ["typescript-language-server", "--stdio"]
channel = "stable-23_05"
4 changes: 3 additions & 1 deletion dev/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
<title>Vite App</title>
</head>
<body>
<div id="editor"></div>
<div id="editor-css"></div>

<div id="editor-html"></div>
<script type="module" src="./index.ts"></script>
</body>
</html>
55 changes: 52 additions & 3 deletions dev/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { basicSetup } from 'codemirror';
import { css } from '@codemirror/lang-css';
import { html } from '@codemirror/lang-html';
import { EditorState } from '@codemirror/state';
import { EditorView } from '@codemirror/view';
import { colorPicker, wrapperClassName } from '../src/';

const doc = `
const cssDoc = `
.wow {
font-family: Helvetica Neue;
font-size: 17px;
Expand All @@ -16,6 +17,7 @@ const doc = `
#alpha {
color: #FF00FFAA;
border-color: rgb(255, 50%, 64, 0.5);
border-color: rgba(255, 50%, 64, 0.5);
}
.hex4 {
Expand All @@ -36,9 +38,37 @@ const doc = `
}
`;

const htmlDoc = `
<html>
<head>
<style>
${cssDoc}
</style>
</head>
<body>
<div style="color: red">
<div style="color: #ff0000">
<div style="color: rgb(0, 255, 0%)">
<div style="color: #00f">
<div style="color: #FF00FFAA">
<div style="color: rgb(255, 50%, 64, 0.5)">
<div style="color: #ABCD">
</body>
</html>
`

const cssParent = document.querySelector('#editor-css');
const htmlParent = document.querySelector('#editor-html');

if (!cssParent || !htmlParent) {
throw new Error('Could not find #editor-css or #editor-html');
}

new EditorView({
state: EditorState.create({
doc,
doc: cssDoc,
extensions: [
colorPicker,
basicSetup,
Expand All @@ -50,5 +80,24 @@ new EditorView({
}),
],
}),
parent: document.querySelector('#editor'),
parent: cssParent,
});


new EditorView({
state: EditorState.create({
doc: htmlDoc,
extensions: [
colorPicker,
basicSetup,
html(),
EditorView.theme({
[`.${wrapperClassName}`]: {
outlineColor: '#000',
},
}),
],
}),
parent: cssParent,
});

13 changes: 7 additions & 6 deletions dev/vite.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
export default {
import { defineConfig } from 'vite';

// https://vitejs.dev/config/
export default defineConfig({
plugins: [],
server: {
host: '0.0.0.0',
hmr: {
port: 443,
},
},
};
}
})
Loading

0 comments on commit 5867afc

Please sign in to comment.