Skip to content

Commit

Permalink
feat: begin lightweight CSS editor
Browse files Browse the repository at this point in the history
  • Loading branch information
SpikeHD committed Nov 1, 2023
1 parent 8a65bbe commit af22450
Show file tree
Hide file tree
Showing 8 changed files with 151 additions and 42 deletions.
Binary file modified bun.lockb
Binary file not shown.
6 changes: 6 additions & 0 deletions plugins/inline-css/components/Editor.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.ceditor {
padding: 12px;
margin-top: 28px;
border-radius: 5px;
background: var(--input-background);
}
46 changes: 46 additions & 0 deletions plugins/inline-css/components/Editor.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { CodeInput } from '@srsholmes/solid-code-input'
import hljs from 'highlight.js/lib/core'
import cssModule from 'highlight.js/lib/languages/css'

import {css, classes} from './Editor.scss'

hljs.registerLanguage('css', cssModule)

const {
ui: {
injectCss,
Header,
HeaderTags
},
plugin: { store },
solid: { createSignal },
} = shelter

let injectedCss = false

export default function () {
if (!injectedCss) {
injectCss(css)
injectedCss = true
}

const [inlineCss, setInlineCss] = createSignal('')

return (
<>
<Header tag={HeaderTags.H1}>CSS Editor</Header>

<div class={classes.ceditor}>
<CodeInput
highlightjs={hljs}
autoHeight={false}
resize="none"
placeholder="Enter any CSS here..."
onChange={setInlineCss}
value={inlineCss()}
language={'css'}
/>
</div>
</>
)
}
13 changes: 13 additions & 0 deletions plugins/inline-css/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import Editor from './components/Editor'

const {
settings: {
registerSection,
}
} = shelter

const unload = registerSection('section', 'inline-css', 'CSS Editor', Editor)

export const onUnload = () => {
unload()
}
7 changes: 7 additions & 0 deletions plugins/inline-css/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "inline-css",
"dependencies": {
"@srsholmes/solid-code-input": "^0.0.18",
"highlight.js": "^11.9.0"
}
}
5 changes: 5 additions & 0 deletions plugins/inline-css/plugin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "Inline CSS",
"author": "SpikeHD",
"description": "Dead-simple inline CSS editor with hot-reloading."
}
111 changes: 71 additions & 40 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"compilerOptions": {
"jsx": "react",
"types": ["./types.d.ts", "./css.d.ts"],
"target": "es6"
}
"target": "es6",
},
"include": ["plugins/**/*.ts", "plugins/**/*.tsx", "node_modules/@uwu/shelter-defs/**/*.d.ts"]
}

0 comments on commit af22450

Please sign in to comment.