Skip to content

Commit 7399c7e

Browse files
committed
Update docs
1 parent ff6c56b commit 7399c7e

File tree

5 files changed

+176
-35
lines changed

5 files changed

+176
-35
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ ColorHelper offers tooltips with color previews of stylesheet colors, provides c
1313
- Show all the colors in a file in a special color palette in the tooltip.
1414
- Allow saving, accessing, and managing colors in named color palettes all from the tooltip.
1515
- Select and insert colors from the color palettes via the tooltip.
16-
- Translate an existing color form to a new form the tooltip. Supports rgb, rgba, hex, hsl, hsla, and colors names.
16+
- Translate an existing color form to a new form the tooltip. Supports rgb, rgba, hex, hexa, hsl, hsla, gray, hwb, and colors names.
17+
- Can optionally treat hexa format (#RRGGBBAA) as #AARRGGBB.
1718

1819
# Documentation
1920
http://facelessuser.github.io/ColorHelper/

docs/index.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ ColorHelper offers tooltips with color previews of stylesheet colors, provides c
1616
- Show all the colors in a file in a special color palette in the tooltip.
1717
- Allow saving, accessing, and managing colors in named color palettes all from the tooltip.
1818
- Select and insert colors from the color palettes via the tooltip.
19-
- Translate an existing color form to a new form the tooltip. Supports rgb, rgba, hex, hsl, hsla, and colors names.
19+
- Translate an existing color form to a new form the tooltip. Supports rgb, rgba, hex, hexa, hsl, hsla, gray, hwb, and colors names.
20+
- Can optionally treat hexa format (#RRGGBBAA) as #AARRGGBB.

docs/usage.md

Lines changed: 152 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,19 @@ Configuration and usage of ColorHelper.
66
## General Usage
77
ColorHelper is a CSS/SCSS/Sass tooltip. When the cursor is on a CSS color, the tooltip will appear. When entering a color into a supported file, the color palette panel will be triggered so you can optionally insert a color from a saved palette. The panel will popup after either: `#`, `rgb(`, `rgba(`, `hsl(` or `hsla(`.
88

9+
10+
!!! note "Note"
11+
Popups are provided by the [`mdpopups`](https://github.com/facelessuser/sublime-markdown-popups) dependency.
12+
913
## Color Info
1014
The Color Info Panel will show a preview of the color, and other format variations of the color such as: color name, hex, rgb, rgba, hsl, and hsla format; if desired, you can convert the selected color to one of the shown formats by clicking the link to the left.
1115

1216
![color info](images/color_info.png)
1317

14-
From the color info panel, you can launch a color picker, bookmark colors as a favorite, add/save the current color to a palette of your choice, or open the [Palette Panel](#palette-panel) to select a pre-saved color from an exiting palette.
18+
From the color info panel, you can launch a color picker, bookmark colors as a favorite, add/save the current color to a palette of your choice, or open the [Palette Panel](#palette-panel) to select a pre-saved color from an existing palette.
1519

1620
## Color Picker
17-
The internal color picker can be launched from the command palette or from the [Color Info Panel](#color_info). When launched it will use the color under the cursor (if available) as its starting color. The internal color picker is contained inside a tooltip. It has a color map section at the top where different colors can be selected. It shows various valid CSS formats of the colors at the bottom. And it shows either rgba channels or hlsa channels; a toggle is available to switch between them.
21+
The internal color picker can be launched from the view's context menu, the command palette, or from the [Color Info Panel](#color_info). When launched it will use the color under the cursor (if available) as its starting color. The internal color picker is contained inside a tooltip. It has a color map section at the top where different colors can be selected. It shows various valid CSS formats of the colors at the bottom. And it shows either rgba channels or hlsa channels; a toggle is available to switch between them.
1822

1923
![color picker](images/color_picker.png)
2024

@@ -58,7 +62,7 @@ The Color Panel allows you to click a color to insert it at your current color p
5862

5963
![color palette](images/colors.png)
6064

61-
From the Color Palette, you can also bring up the [Color Delete Panel](#color-delete-panel).
65+
You can also bring up the [Color Delete Panel](#color-delete-panel) from the view's context menu or the command palette.
6266

6367
## Color Delete Panel
6468
The Color Delete Panel can delete any color from the given palette. A user simply clicks the color to remove, and it will be removed.
@@ -68,6 +72,14 @@ The Color Delete Panel can delete any color from the given palette. A user simp
6872
## Settings
6973
Settings for Color Helper are contained within the `color_helper.sublime-settings` file.
7074

75+
### auto_popup
76+
Enable/disable auto popups.
77+
78+
```js
79+
// Show popups automatically in configured files.
80+
"auto_popup": true,
81+
```
82+
7183
### upper_case_hex
7284
When inserting a color from the tooltip, this setting will determine if hex colors get uppercased or lowercased.
7385

@@ -84,24 +96,6 @@ Will determine if a HTML color name will be shown for the currently selected col
8496
"use_webcolor_names": true,
8597
```
8698

87-
### preferred_format
88-
Controls color format that will be inserted into your document when selecting a color from a palette. This will only affect colors that contain **no** transparency.
89-
90-
```js
91-
// Preferred format to output color as:
92-
// (none|hex|rgb|hsl)
93-
"preferred_format": "hex",
94-
```
95-
96-
### preferred_alpha_format
97-
Controls color format that will be inserted into your document when selecting a color from a palette. This will only affect colors **with** transparency.
98-
99-
```js
100-
// Preferred alpha format to output color as:
101-
// (none|rgba|hsla)
102-
"preferred_alpha_format": "rgba",
103-
```
104-
10599
### click_color_box_to_pick
106100
This will make the color preview box in the [Color Info Panel](#color-info-panel) clickable. When set to `color_picker` and clicked, it will open the color picker via the [ColorPicker](https://github.com/weslly/ColorPicker) plugin (if installed). When set to `palette_picker` and clicked, it will open the [Palette Panel](#palette-panel). The respective menu item will not be shown in the [Color Info Panel](#color-info-panel) once relocated to the color preview.
107101

@@ -197,17 +191,143 @@ Enables showing the color conversion options on the [Color Info Panel](#color-in
197191
"enable_color_conversions": true,
198192
```
199193

200-
### supported_syntax
201-
`supported_syntax` is a list of scope rules that will be scanned when [enable_current_file_palette](#enable_current_file_palette) is enabled. If a color is found within these scope rules, it will be indexed for the current file and shown in the Current Colors Panel in the [Palette Panel](#palette-panel).
194+
### color_scanning
195+
Setting to control color scanning which is responsible for both auto-popups and constructing "Current File Palette".
196+
197+
`color_scanning` is an array of rules. Each rule can target file(s) and enable certain scanning certain scopes for specific colors. Each rule is a dictionary. `syntax_files`, `base_scopes`, and `extensions` or used to target the a file for scanning; you can use a specific one, or multiple.
198+
199+
```js
200+
"color_scanning": [
201+
{
202+
"syntax_files": [],
203+
"syntax_filter": "whitelist",
204+
"base_scopes": [
205+
"source.css",
206+
"text.html"
207+
],
208+
"scan_scopes": [
209+
// CSS, CSS in HTML etc. (based on: Sublime Default)
210+
"meta.property-value.css -comment -string",
211+
// CSS3, CSS3 in HTML etc. (based on: https://packagecontrol.io/packages/CSS3)
212+
"meta.value.css -comment -string",
213+
// HTML attributes (based on: Sublime Default)
214+
"meta.tag.inline.any.html string.quoted",
215+
"meta.tag.any.html meta.attribute-with-value.style.html"
216+
],
217+
"scan_completion_scopes": [],
218+
"extensions": [],
219+
"allowed_colors": ["css3"],
220+
"use_hex_argb": false,
221+
"compress_hex_output": true
222+
},
223+
]
224+
```
225+
226+
#### color_scanning.syntax_files
227+
`syntax_files` is an array of syntax file (`tmLanguage` or `sublime-syntax`)names and are relative to `Packages` (extensions should be excluded). They are used to filter views that will be targeted for scanning. Depending on how [`syntax_filter`](#color_scanningsyntax_filter) is set, `syntax_files` will either require the files to be in the list or not in the list. If `syntax_files` is set as an empty array, all views will be targeted unless filtered further by other settings.
228+
229+
Assuming that you have a tmLanguage file `Packages/CSS/CSS.tmLanguage`:
230+
231+
```js
232+
"color_scanning": [
233+
{
234+
"syntax_files": ["CSS/CSS"],
235+
```
236+
237+
#### color_scanning.syntax_filter
238+
`syntax_filter` will cause [`syntax_files`](#color_scanningsyntax_files) to be treated as either a `blacklist` or `whitelist`. Acceptable values are `"blacklist"` and `"whitelist"`. `"whitelist"` is the default setting.
239+
240+
```js
241+
"color_scanning": [
242+
{
243+
"syntax_filter": "whitelist",
244+
```
245+
246+
#### color_scanning.base_scopes
247+
`base_scopes` is used to target specific file views that are syntax highlighted with a specific base scope. This allows you to target multiple syntax highlighters that all use the same base scope. `base_scopes` is an array; if the array is left empty, all views will be targeted unless filtered further by other settings.
248+
249+
```js
250+
"color_scanning": [
251+
{
252+
"base_scopes": ["source.css"],
253+
```
254+
255+
#### color_scanning.extensions
256+
`extensions` is used to target specific file views that a file name with the specified extension(s). `extensions` is an array; if the array is left empty, all views will be targeted unless filtered further by other settings. For this setting to work the file usually must exist on disk as views that do not exist on text usually do not have a file name.
257+
258+
```js
259+
"color_scanning": [
260+
{
261+
"extensions": [".css"],
262+
```
263+
264+
#### color_scanning.scan_scopes
265+
`scan_scopes` is an array of scopes that will be searched for colors. Scopes in this array contain usually `tmTheme` scope syntax, so you can include scopes or exclude scopes etc.
266+
267+
In the example below, we target `meta.property-value.css`, but only if it is not also scoped as a `string` or a `comment`.
268+
269+
```js
270+
"color_scanning": [
271+
{
272+
"scan_scopes": ["meta.property-value.css -comment -string"]
273+
```
274+
275+
#### color_scanning.scan_completion_scopes
276+
`scan_completion_scopes` is an array of scopes that will be searched for certain syntax for color completions. This is used only if `scan_scopes` is not sufficient to also capture colors that need to be completed. For example: sometimes `scan_scopes` is not broad enough to capture incomplete colors, but we don't want to generally want to scan so broadly when scanning an entire file for complete colors. Scopes in this array contain usually `tmTheme` scope syntax, so you can include scopes or exclude scopes etc.
277+
278+
In the example below, we target `source.scss` and `source.sass`, but only if they are not also scoped as `string` or `comment`.
279+
280+
```js
281+
"color_scanning": [
282+
{
283+
"scan_completion_scopes": [
284+
"source.scss -comment -string",
285+
"source.sass -comment -string"
286+
],
287+
```
288+
289+
#### color_scanning.allowed_colors
290+
`allowed_colors` defines which colors will be scanned for in a specific file. It is an array of strings where each strings specifies a color type or category of colors to scan for.
291+
292+
| Value | Description |
293+
| ----- | ----------- |
294+
| webcolors | CSS3 color names plus CSS4's `rebeccapurple`. |
295+
| hex | Hex colors in the form of `#RRGGBB`. |
296+
| hex_compressed | Hex colors in the form of `#RGB`. |
297+
| hexa | Hex colors with an alpha channel in the form `#RRGGBBAA` or `#AARRGGBB` if `use_hex_argb` is set to `true`. |
298+
| hexa_compressed | Hex colors with an alpha channel in the form `#RGBA` or `#ARGB` if `use_hex_argb` is set to `true`. |
299+
| rgb | RGB colors in the form `rgb(255, 128, 0)` or `rgb(100%, 50%, 0%)`. |
300+
| rgba | RGBA colors in the form `rgb(255, 128, 0, .5)` or `rgb(100%, 50%, 0%, .5)`. It also supports CSS4's alpha as a percentage format: `rgb(100%, 50%, 0%, 50%)`. |
301+
| hsl | HSL colors in the form `hsl(360, 100%, 50%). |
302+
| hsla | HSLA colors in the form `hsla(360, 100%, 50%, .5). It also supports CSS4's alpha as a percentage format: `hsla(360, 100%, 50%, 50%)`. |
303+
| gray | CSS4's gray format: `gray(255)` or `gray(100%)`. |
304+
| graya | CSS4's gray with alpha format: `gray(255, .5)` or `gray(100%, .5)`. It also supports alpha as a percentage format: `gray(100%, 50%)`. |
305+
| hwb | CSS4's HWB color format: `hwb(360, 50%, 100%)`. |
306+
| hwba | CSS4's HWBA color format: `hwb(360, 50%, 100%, 5)` or `hwb(360, 50%, 100%, 50%)`. |
307+
| css3 | All CSS3 formats: `webcolors`, `hex`, `hex_compressed`, `rgb`, `rgba`, `hsl`, `hsla`. |
308+
| css4 | All CSS4 formats: `css3`, `gray`, `graya`, `hwb`, `hwba`, `hexa`, `hexa_compressed`. |
309+
| all | All color formats. |
310+
311+
```js
312+
"color_scanning": [
313+
{
314+
"allowed_colors": ["css3"]
315+
```
316+
317+
#### color_scanning.use_hex_argb
318+
When scanning and processing hex rgb colors with alpha channels, process them as and output them with the alpha channel first opposed to at the end. By default the value is `false`.
319+
320+
```js
321+
"color_scanning": [
322+
{
323+
"use_hex_argb": true
324+
```
325+
326+
#### color_scanning.compress_hex_output
327+
When outputting hex formats compress the color if possible `#334455` --> `#345`. The default is `false`.
202328
203329
```js
204-
// File scoping that will be used when indexing colors in an opened or saved file.
205-
// These are the syntaxes which the auto popup tooltip uses to recogize scannable regions.
206-
"supported_syntax": [
207-
"meta.property-value.css -comment -string", // CSS, CSS in HTML etc. (based on: Sublime Default)
208-
"meta.value.css -comment -string", // CSS3, CSS3 in HTML etc. (based on: https://packagecontrol.io/packages/CSS3)
209-
"meta.property-list.css.sass -comment -string", // Sass and SCSS (based on: https://packagecontrol.io/packages/Syntax%20Highlighting%20for%20Sass)
210-
"sass-script-maps -variable.other -comment -string", // Sass and SCSS script maps (based on: https://packagecontrol.io/packages/Syntax%20Highlighting%20for%20Sass)
211-
"meta.tag.inline.any.html string.quoted" // HTML attributes (based on: Sublime Default)
212-
],
330+
"color_scanning": [
331+
{
332+
"compress_hex_output": true
213333
```

messages.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
22
"1.1.0": "messages/1.1.0.md",
3-
"1.2.0": "messages/1.2.0.md"
3+
"1.2.0": "messages/1.2.0.md",
4+
"1.3.0": "messages/1.3.0.md"
45
}

messages/1.3.0.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# ColorHelper 1.2.0
2+
3+
## New
4+
5+
- Color preview will now show transparent colors with and without transparency.
6+
- Transparent colors can now be stored and showed in palettes.
7+
- Specifying files for scanning has been reworked and is now more flexible. Read docs for more info.
8+
- Color Helper no longer has preferred formats when inserting. It will always prompt the user for their desired input format.
9+
- Added CSS4's `rebeccapurple` to the `webcolor` names.
10+
- Added better `rgb` and `rgba` support: percentage format, decimal format (CSS4), percentage alpha (CSS4).
11+
- Added support for alpha channel as percentage for `hsla` (CSS4).
12+
- Clamp color channel values out of range.
13+
- Support CSS4 `gray`, `hwb`, and hex values with alpha channels.
14+
- Option to read hex with alpha channel as `#AARRGGBB` instead of `#RRGGBBAA`.
15+
- Option to compress hex values if possible on output: `#334455` --> `#345`.
16+
- Can disable auto-popups if desired.
17+
- Insert options now are now more dynamic and only show valid options for the current view.
18+
- Anything else I might have missed.

0 commit comments

Comments
 (0)