├── .gitignore
├── .npmignore
├── .travis.yml
├── History.md
├── Makefile
├── Readme.md
├── bin
├── logger.js
└── myth
├── bower.json
├── component.json
├── lib
├── features.js
└── index.js
├── myth.js
├── package.json
└── test
├── cases
├── myth.io.css
└── myth.io.out.css
├── cli
├── compress.css
├── error.css
├── input.css
└── input.out.css
├── features
├── calc.css
├── calc.out.css
├── color.css
├── color.out.css
├── custom-media.css
├── custom-media.out.css
├── font-variant.css
├── font-variant.out.css
├── hex-alpha.css
├── hex-alpha.out.css
├── import.css
├── import.include.css
├── import.out.css
├── prefixes.css
├── prefixes.out.css
├── rebeccapurple.css
├── rebeccapurple.out.css
├── variables.css
└── variables.out.css
├── index.js
└── sourcemap
├── imported.css
├── in.css
├── index.html
└── out.css
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | test
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: node_js
2 | node_js:
3 | - "0.10"
4 | # - "0.11"
5 | # - "0.8"
6 | # - "0.6"
7 |
--------------------------------------------------------------------------------
/History.md:
--------------------------------------------------------------------------------
1 |
2 | 1.5.0 - July 11, 2015
3 | ---------------------
4 | * upgrade `autoprefixer` to `5.2.0`
5 | * add `--ignore-errors` flag to the cli
6 |
7 | 1.4.0 - March 6, 2015
8 | ---------------------
9 | * add `variables` and `preserve` options
10 |
11 | 1.3.0 - January 25, 2015
12 | ------------------------
13 | * add `--sourcemap` flag to the cli
14 |
15 | 1.2.1 - October 15, 2014
16 | --------------------------
17 | * upgrade `read-file-stdin` to `0.2.0`
18 |
19 | 1.2.0 - September 12, 2014
20 | --------------------------
21 | * upgrade `autoprefixer` to `3.0.0`
22 |
23 | 1.1.1 - July 17, 2014
24 | ---------------------
25 | * fix `browsers` option [#97](https://github.com/segmentio/myth/pull/97)
26 | * add cli options to disable individual features
27 |
28 | 1.1.0 - July 14, 2014
29 | ---------------------
30 | * add [custom media](http://dev.w3.org/csswg/mediaqueries/#custom-mq) feature
31 | * add [rebeccapurple](http://lists.w3.org/Archives/Public/www-style/2014Jun/0312.html) support
32 | * improve `calc()` support
33 | * improve `@import` support
34 | * upgrade autoprefixer to `2.0.0`
35 | * upgrade rework to `1.0.0` for sourcemap support
36 | * fix `maximum call stack` issue [#91](https://github.com/segmentio/myth/issues/91)
37 | * fix empty `font-feature` value issue [#79](https://github.com/segmentio/myth/issues/79)
38 |
39 | 1.0.4 - June 3, 2014
40 | --------------------
41 | * upgrade `rework-inline` to `0.2.0` to fix import bugs
42 |
43 | 1.0.3 - May 16, 2014
44 | --------------------
45 | * fix returning plugin on empty string
46 |
47 | 1.0.2 - May 7, 2014
48 | -------------------
49 | * upgrade to `read-file-stdin` version `0.0.4`
50 |
51 | 1.0.1 - May 5, 2014
52 | -------------------
53 | * add `compress` cli flag
54 |
55 | 1.0.0 - May 5, 2014
56 | -------------------
57 | * add `@import` support
58 | * add support for new css variables syntax
59 | * add `compress` option
60 | * add `browsers` option
61 |
62 | 0.3.4 - March 31, 2014
63 | ----------------------
64 | * upgrade `rework-vars` to `2.0.3` to properly clear variables
65 |
66 | 0.3.3 - March 18, 2014
67 | ----------------------
68 | * add ability to pass options to `rework.toString`
69 |
70 | 0.3.2 - March 18, 2014
71 | ----------------------
72 | * add bower support
73 |
74 | 0.3.1 - March 4, 2014
75 | ---------------------
76 | * upgrade color plugins to fix media query support
77 |
78 | 0.3.0 - January 7, 2014
79 | -----------------------
80 | * add browser support
81 | * add component support
82 |
83 | 0.2.0 - December 25, 2013
84 | -------------------------
85 | * add nice error logging
86 | * upgrade `rework-color-function` to `0.1.2`
87 |
88 | 0.1.8 - December 23, 2013
89 | -------------------------
90 | * upgrade logger
91 |
92 | 0.1.7 - December 23, 2013
93 | -------------------------
94 | * change to `node-watch`
95 |
96 | 0.1.6 - December 19, 2013
97 | -------------------------
98 | * add cli tests
99 |
100 | 0.1.5 - December 19, 2013
101 | -------------------------
102 | * add `read-file-stdin`
103 | * add `write-file-stdout`
104 | * fix exists check
105 |
106 | 0.1.4 - December 18, 2013
107 | -------------------------
108 | * upgrade `rework-vars` to `2.0.2`
109 |
110 | 0.1.3 - December 18, 2013
111 | -------------------------
112 | * add exists check
113 |
114 | 0.1.1 - December 17, 2013
115 | -------------------------
116 | * add returning rework plugin
117 | * upgrade `rework-calc` dependency
118 |
119 | 0.1.0 - December 17, 2013
120 | -------------------------
121 | :sparkles:
122 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 |
2 | # Binaries.
3 | browserify = ./node_modules/.bin/browserify
4 | mocha = ./node_modules/.bin/mocha
5 |
6 | # Remove non-checked-in files.
7 | clean:
8 | @rm -rf node_modules myth.js
9 |
10 | # Build the browser-side myth.js file with Browserify.
11 | myth.js: lib/*.js node_modules
12 | @$(browserify) lib/index.js \
13 | --standalone myth \
14 | --outfile myth.js
15 |
16 | # Install dependencies from npm.
17 | node_modules: package.json
18 | @npm install
19 | @touch package.json
20 |
21 | # Run the tests.
22 | test: myth.js node_modules
23 | @$(mocha) \
24 | --reporter spec \
25 | --slow 700 \
26 | --bail
27 |
28 | # Run the tests.
29 | test-debug: myth.js node_modules
30 | @$(mocha) debug \
31 | --reporter spec \
32 | --slow 700
33 |
34 | # Phony commands.
35 | .PHONY: clean
36 | .PHONY: test
37 | .PHONY: test-debug
--------------------------------------------------------------------------------
/Readme.md:
--------------------------------------------------------------------------------
1 |
2 | # Myth [](http://travis-ci.org/segmentio/myth)
3 |
4 | _CSS the way it was imagined._
5 |
6 | Myth is a preprocessor that lets you write pure CSS without having to worry about slow browser support, or even slow spec approval. It's like a CSS polyfill.
7 |
8 |
9 | ## Installation
10 |
11 | $ npm install -g myth
12 |
13 |
14 | ## Usage
15 |
16 | $ myth input.css output.css
17 | # Generated output.css from input.css
18 |
19 |
20 | ## Community
21 |
22 | - [mnmly/builder-myth](https://github.com/mnmly/builder-myth): `component-builder` plugin
23 | - [gulp-myth](https://github.com/sindresorhus/gulp-myth): Gulp plugin
24 | - [grunt-myth](https://github.com/sindresorhus/grunt-myth): Grunt plugin
25 | - [duo-myth](https://github.com/duojs/myth): Duo plugin
26 | - [myth-loader](https://github.com/luigy/myth-loader): Webpack Loader
27 | - [meteor-myth](https://github.com/aquator/meteor-myth): Meteor plugin
28 | - [myth-transformer](https://github.com/ppvk/myth-transform): Dart transformer
29 |
30 | ## Why?
31 |
32 | Myth lets you write pure CSS while still giving you the benefits of tools like LESS and Sass. You can still use variables and math functions, just like you do in preprocessors. It's like a polyfill for future versions of the spec.
33 |
34 | Some of the features in CSS require runtime calculations, which neither Myth nor preprocessors handle, but what Myth does is let you write your code today in the future syntax, so that your code is future-proof. When browsers finally support these features you won't need to rewrite anything, just start using the cascade!
35 |
36 | Taking plain CSS as an input also means you can use Myth to re-process anyone else's CSS (or another preprocessors output), adding the browser support you need, without having to re-write the code in a completely different syntax.
37 |
38 | Myth is built with Rework so it's incredibly fast, and has a nice Javascript API in addition to the CLI.
39 |
40 |
41 | ## Example
42 |
43 | An example is the easiest way to explain it. If you write spec-compliant CSS:
44 |
45 | ```css
46 | :root {
47 | --green: #a6c776;
48 | }
49 |
50 | @custom-media --narrow-window screen and (max-width: 30em);
51 |
52 | @media (--narrow-window) {
53 | html {
54 | font-size: 1.2rem;
55 | }
56 | }
57 |
58 | a {
59 | color: var(--green);
60 | font-variant: all-small-caps;
61 | transition: color 1s;
62 | }
63 |
64 | a:hover {
65 | color: color(var(--green) shade(20%));
66 | }
67 |
68 | ::placeholder {
69 | opacity: .4;
70 | transition: opacity 1s;
71 | }
72 |
73 | :focus::placeholder {
74 | opacity: .2;
75 | }
76 | ```
77 |
78 | ... Myth will transform it for you, into browser-compliant CSS:
79 |
80 | ```css
81 | @media screen and (max-width: 30em) {
82 | html {
83 | font-size: 1.2rem;
84 | }
85 | }
86 |
87 | a {
88 | color: #a6c776;
89 | -webkit-font-feature-settings: "smcp", "c2sc";
90 | -moz-font-feature-settings: "smcp", "c2sc";
91 | font-feature-settings: "smcp", "c2sc";
92 | font-variant: all-small-caps;
93 | -webkit-transition: color 1s;
94 | transition: color 1s;
95 | }
96 |
97 | a:hover {
98 | color: rgb(133, 159, 94);
99 | }
100 |
101 | ::-webkit-input-placeholder {
102 | opacity: .4;
103 | -webkit-transition: opacity 1s;
104 | transition: opacity 1s;
105 | }
106 |
107 | ::-moz-placeholder {
108 | opacity: .4;
109 | transition: opacity 1s;
110 | }
111 |
112 | :-ms-input-placeholder {
113 | opacity: .4;
114 | transition: opacity 1s;
115 | }
116 |
117 | ::placeholder {
118 | opacity: .4;
119 | -webkit-transition: opacity 1s;
120 | transition: opacity 1s;
121 | }
122 |
123 | :focus::-webkit-input-placeholder {
124 | opacity: .2;
125 | }
126 |
127 | :focus::-moz-placeholder {
128 | opacity: .2;
129 | }
130 |
131 | :focus:-ms-input-placeholder {
132 | opacity: .2;
133 | }
134 |
135 | :focus::placeholder {
136 | opacity: .2;
137 | }
138 | ```
139 |
140 |
141 | ## Features
142 |
143 | #### Variables
144 |
145 | Using the same syntax as the [CSS spec](http://dev.w3.org/csswg/css-variables/). Just like future CSS, but without the cascade. Thanks to [`rework-vars`](https://github.com/visionmedia/rework-vars).
146 |
147 | ```css
148 | :root {
149 | --purple: #847AD1;
150 | }
151 |
152 | a {
153 | color: var(--purple);
154 | }
155 | ```
156 |
157 | #### Math
158 |
159 | Using the same syntax as the [CSS spec](http://www.w3.org/TR/css3-values/#calc-notation). Just like future CSS, but without runtime interpolation. Thanks to [`rework-calc`](https://github.com/klei-dev/rework-calc).
160 |
161 | ```css
162 | pre {
163 | margin: calc(50px * 2);
164 | }
165 | ```
166 |
167 | #### Custom media queries
168 |
169 | Using the same syntax as the [CSS spec](http://dev.w3.org/csswg/mediaqueries/#custom-mq). Thanks to [`rework-custom-media`](https://github.com/reworkcss/rework-custom-media).
170 |
171 | ```css
172 | @custom-media --narrow-window (max-width: 30em);
173 |
174 | @media (--narrow-window) {
175 | /* narrow window styles */
176 | }
177 |
178 | @media (--narrow-window) and (script) {
179 | /* special styles for when script is allowed */
180 | }
181 | ```
182 |
183 | #### Color Manipulation
184 |
185 | Using the same syntax as the [CSS spec](http://dev.w3.org/csswg/css-color/#modifying-colors). Thanks to [`rework-color-function`](https://github.com/ianstormtaylor/rework-color-function).
186 |
187 | ```css
188 | a {
189 | color: #847AD1;
190 | }
191 |
192 | a:hover {
193 | color: color(#847AD1 tint(20%));
194 | }
195 | ```
196 |
197 | #### No Prefixes
198 |
199 | The prefixes from the most-common *and* most-recent browsers are supported, so you never need to worry about what the current browser support landscape is. Big thanks to [`autoprefixer`](https://github.com/postcss/autoprefixer)!
200 |
201 | ```css
202 | .button {
203 | background: linear-gradient(to bottom, black, white);
204 | transition: transform .25s;
205 | }
206 | ```
207 |
208 | #### And more...
209 |
210 | - 4-digit and 8-digit hex color support. [`Spec`](http://dev.w3.org/csswg/css-color/#hex-notation) - [`Thanks`](https://github.com/ianstormtaylor/rework-hex-alpha)
211 | - Font-variant shorthands. [`Spec`](http://www.w3.org/TR/css3-fonts/#font-variant-prop) - [`Thanks`](https://github.com/ianstormtaylor/rework-font-variant)
212 |
213 | ## API
214 |
215 | #### Command Line
216 |
217 | ```
218 | Usage: myth [] [