Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

https://github.com/replit/Codemirror-CSS-color-picker

A codemirror extension that adds a color picker input next to CSS color values. Development happens on Replit, just fork and hit run! https://replit.com/@util/Codemirror-CSS-color-picker
https://github.com/replit/Codemirror-CSS-color-picker

Last synced: 4 months ago
JSON representation

A codemirror extension that adds a color picker input next to CSS color values. Development happens on Replit, just fork and hit run! https://replit.com/@util/Codemirror-CSS-color-picker

Lists

README

        

# CodeMirror Color Picker

Run on Replit badge
NPM version badge

A CodeMirror extension that adds a color picker input next to CSS color values.

![preview](https://replit.com/cdn-cgi/image/width=3840,quality=80/https://storage.googleapis.com/replit/images/1632627522442_46320608eaa3f0c58bebd5fe4a10efc2.gif)

### Usage

```ts
import { basicSetup } from 'codemirror';
import { EditorState } from '@codemirror/state';
import { EditorView } from '@codemirror/view';
import { css } from '@codemirror/lang-css';
import { colorPicker } from '@replit/codemirror-css-color-picker';

new EditorView({
parent: document.querySelector('#editor'),
state: EditorState.create({
doc: '.wow {\n color: #fff;\n}',
extensions: [
basicSetup,
css(),
colorPicker({
style: {
wrapper: {
outlineColor: 'transparent',
},
},
}),
],
}),
});
```

```ts
interface CSSColorPickerOptions {
/**
* Additional [`style-mod`](https://github.com/marijnh/style-mod#documentation)
* style spec providing theme for the color picker.
*/
style?: {
/** Style spec for the color picker `

` container */
wrapper?: StyleSpec;
/** Style spec for the color picker `` element */
input?: StyleSpec;
};
}
```

### Todos

- Investigate solutions for alpha values. `input[type="color"]` doesn't support alpha values, we could show another number input next to it for the alpha value.