Sublime Forum

CSScheme - Create Color Schemes using CSS, SCSS or stylus

#1

https://github.com/FichteFoll/CSScheme (available from Package Control)

Inspired by Color Scheme Builder (yeah, long ago) I was suddenly really motivated to write this, and this is what came out of that.

It parses a slightly modified CSS syntax to support the complete syntax of tmTheme files, or at least everything I know about. You use arbitrary @at-rules to specify things such as the names or comments, and normal properties are added to the “settings” dictionary. There is some magic involved that checks for valid input, but not everything is checked. More information in the readme.

Since it parses CSS you can basically use any other CSS-like language that compiles it. I decided to use SCSS as the main target here, but SASS and stylus are supported too. Leave an issue on the repo if you’d like to see another language supported (such as LESS).

Most of the features can be seen in my example file (colors might cause cancer, I selected them randomly), so I recommend checking that out.

You can also convert an existing tmTheme file to a CSScheme version for your to edit (only ST3).

Finally, have an animated screenshot:

0 Likes

Dayle Rees Colour & UI Schemes
#2

-Wow. I haven’t had a chance to check the ST forums in weeks. I only decided to pop in today and see if I could help out because I have a deadline looming (so of course I am procrastinating). And… this!

I haven’t checked it, yet, because I can hear the whoosh of that deadline. But I’ll definately be checking this out soon :smile:

Thanks FichteFoll!

P.S. I see you’ve also updated InsertDate. I should really pay more attention… :smile:

0 Likes

#3

Interesting.

0 Likes

#4

Really Cool!

0 Likes

#5

@FichteFoll I am encountering some weirdness . . . either that or it’s late and my mind is foggy. Do you prefer bug reports here or on github?

0 Likes

#6

I can’t figure it out what’s wrong.

Given this:

@name "Test";

$hotpink: #fe57a1;

* {
	selection:       transparentize($hotpink, .85);
	selectionBorder: transparentize($hotpink, .76);
}

I get this:

Traceback (most recent call last):
  File "my_sublime_lib in C:\Alex\Dropbox\Apps\Sublime Text 3\Data\Installed Packages\CSScheme.sublime-package", line 62, in run_
  File "C:\Alex\Dropbox\Apps\Sublime Text 3\sublime_plugin.py", line 526, in run_
    return self.run()
  File "csscheme in C:\Alex\Dropbox\Apps\Sublime Text 3\Data\Installed Packages\CSScheme.sublime-package", line 182, in run
  File "tinycsscheme.dumper in C:\Alex\Dropbox\Apps\Sublime Text 3\Data\Installed Packages\CSScheme.sublime-package", line 65, in dump_stylesheet_file
  File "tinycsscheme.dumper in C:\Alex\Dropbox\Apps\Sublime Text 3\Data\Installed Packages\CSScheme.sublime-package", line 114, in datafy_stylesheet
  File "tinycsscheme.dumper in C:\Alex\Dropbox\Apps\Sublime Text 3\Data\Installed Packages\CSScheme.sublime-package", line 147, in datafy_ruleset
  File "tinycsscheme.dumper in C:\Alex\Dropbox\Apps\Sublime Text 3\Data\Installed Packages\CSScheme.sublime-package", line 147, in <genexpr>
AttributeError: 'FunctionToken' object has no attribute 'value'

It’s line 7 (selectionBorder) that causes the issue, but I don’t understand why. It will work if I change the line to:

selectionBorder: $hotpink;

Let me know if the above make sense.

Alex

0 Likes

#7

I prefer bugs on github because I get notifications when a new issue is created and I check those regularly, this forum not so much but you would get an answer. (Also it’s an actual issue tracker where you can “close” stuff and refer to it from commits for example.)

Anyway, I can work with this here. It seems indeed like a weird case. I don’t have time to debug this today but I will look into it tomorrow.

0 Likes

#8

OK --> github.com/FichteFoll/CSScheme/issues/1

Let me know if I can help with troubleshooting the issue.

Alex

0 Likes

#9

Some bug fixes were pushed, including for the one reported above.

Please report any issue you find in the github issues or alternatively here if you don’t have a github account.

I’m considering providing some kind of utility functions that work in the HCL color system and could do work like this vis4.net/blog/posts/mastering-m … or-scales/, which looks pretty impressive and useful (tool to play with).

0 Likes

#10

For anyone interested in playing along, I have built a color scheme in CSScheme:
github.com/alehandrof/Writerly

It’s a port of an unreleased scheme that I’ve been using for a long time. It’s fully functional and very pretty (if I do say so myself) although I am more interest in CSS and Markdown than C++ so it may not be everyone’s cup of tea.

@FichteFoll: the color stuff you linked to are very interesting. But wouldn’t make more sense to hook these on top of Sass rather than on top of CSScheme? (Not that I know anything about Sass development :smile: )

Alex

0 Likes

#11

Sure. I actually plan to write (if they don’t exist already) some SASS functions for the HCL that can be included (from anywhere because I add the CSScheme path to the build command or something) and just didn’t come around it yet. It’s on a somewhat low priority though.

Btw, updates.

0 Likes

#12

Fair enough. The possibilities of automatically generating a balanced palette are very intriguing.

Even without this stuff, it should be possible to use CSScheme to build a meta-framework (or more than one, probably) for color schemes. I’ve began to abstract stuff in my theme, but it’s still nascent.

0 Likes

#13

Great idea.

I started a minimal Solarized theme the other day, and was sufficiently annoyed by plists that I wrote a little Python script to generate themes from YAML sources. If I had googled a little earlier, I might have found this project and used it instead.

0 Likes

#14

Basic CSSchemes don’t really have advantages over other data representations of plist, such as YAML, but the ability to use other precompilers such as SCSS and thus nested scopes and basic statements like if and for makes it really useful.

Btw, I myself wrote a yaml to plist conversion in the scope of github.com/SublimeText/AAAPackageDev that you can use for YAML-tmLanguages but it’s not limited to just those. You can use it with any yaml, plist or json file if you want to.

0 Likes

#15

New version (1.0.0)

I mainly added stylus support, templates for creating new scheme files and fixed a few things.

Also, have this animated screenshot:

0 Likes

#16

I don’t see any docs on the templates. Can you elaborate?

0 Likes

#17

The first paragraph in Usage covers them. I’m overall not too satisfied with them since I just re-used my example SCSS file, removed the special constructs and reduced it to a minimum (of scopes that I consider a must in any scheme). I then do some regular expression hocus pocus and suddenly I have templates for SASS and stylus as well.

Long story short: enter cssnew in the command palette.

0 Likes

#18

OK. I see what you mean.

FWIW, what I want to do with Writerly – but I haven’t gotten around to cleaning the repo to show this clearly – is to create a sort of uber color scheme framework. This would handle all the strange edge cases, such as Python using the “string” scope for comments. All you’d have to do is to plug in your favorite colors.

Easier said than done, though :smile:

Alex

0 Likes

#19

1.1.0 was released few days ago (only ST3!) featuring:

  • Command to convert an existing tmTheme file to a CSScheme version for your to edit
  • Bug fix for SASS/SCSScheme negative scope selector escaping
0 Likes