Minimalist Notation Docs
Try this tests:
Home page: http://minimalist-notation.org
I would be grateful for your feedback and comments. Write me in a telegram.
With love, your mr.Amirka :)
Are you interested in the development of this project? Do your bit.
Minimalist Notation (MN) is a technology for generating styles based on parsing the markup. In the current version for web applications, the generation is done directly in the CSS. Technology tremendously speeds up the layout process and can be used additionally with traditional technologies, or replace completely those.
The advantage over the traditional technologies of CSS-preprocessing is that the developer gets rid of the need to write CSS. CSS is generated automatically based on the notation and the style generate rules specified by the developer. The developer no longer needs to control which styles are used in his markup and which ones are not, for from now on the styles are generated dynamically only for what is present in the markup.
The technology is focused on the methodology Functional/Atomic CSS.
If you are using the Functional/Atomic CSS methodology, then:
- over time, you will at a glance understand the meaning of each name in the markup;
- you can easily standardize the rules of notation and naming;
- easy to reuse markup in the new project, if it provides the same basic set of functional styles in CSS.
- in case of making changes to the design, you only change the HTML markup.
- you have straight arms - you do not stumble on a rake with overrided styles;
- you can customize your build system for automatic generation of CSS from attributes in the markup;
- do not specify bulky attributes for long selectors in every place you want, for example, just add smoothness to the transformation. In the functional approach, this is done once, as in the CSS code below:
If you are concerned about why some attributes have the
!important flag, this is due to the fact that atomic styles should be given higher priority than traditional classes and complex selectors, since the use of atomic styles implies a more precise markup customization over top of other more general CSS rules. For example, the flag
!important Was necessary when I applied the technology
MN along with
Angular Material (MD) to customize the appearance of some elements, since styles MD's complex selectors did override MN styles. However, this approach can create a rake for you if you want to use JS to dynamically change the style of an element covered by the
!important flag from CSS. Therefore, this nuance is worth considering. For example, this is provided for in some default MN rules for the generation of style essences. You can add the suffix
-i to the end of the name of the essence:
Thanks to MN:
- CSS is generated automatically from attribute values in the markup, and we save time by saving ourselves from writing "satanic" CSS-code;
- We do not have dead CSS code, because CSS is generated only for the markup that is available.
- we have the opportunity not to contact the server for "heavy" CSS-files, generating CSS in runtime.
- when making changes to the design, we only change the HTML markup, without touching the CSS.
If you want to have available to customize / change the theme of your application, replacing only the CSS file, then nothing prevents you from doing it according to the BEM naming convention methodology, limiting yourself to customizing color schemes, font sizes and other attributes that do not require changing the markup itself.
For the purpose of customizing markup styles for a specific topic, MN provides for the possibility of manipulating global CSS rules in runtime, for example, with specific selectors:
or you can do this with the essences:
PS: If it is necessary to set several alternative values for one attribute by analogy with this in CSS:
You can do this:
Technology "Minimalist Notation" supports:
- parameterizable name notation
- parameterizable state;
- contexts of parent / child selectors;
- complex selector contexts;
- control the depth in the dom-tree through the notation;
- management of the priority of styles through the notation;
- media query contexts;
- grouping of substrings in notation;
- synonyms of states and media queries;
- inheritance from style essences (extension; analogue of
- admixture of essences (similar to
- association of selectors with style essences;
- manipulation of global CSS styles in runtime.
Example for class name
Example for attr
Record of notation in MN is divided into 2 parts:
- name of the essence;
- context of the essence (combined selector and media query).
The substring from the beginning of the name to the first service character (
<>. : + @) is responsible for the name of the essence.
The rest of the notation, including the first service symbol, refers to the context of the essence, within which the styles of the essence are applied (selectors and media queries). For example:
ph10; essence context:
bgF00 ; essence context:
cF; essence context:
mh-10; essence context:
The part of the name that is responsible for the essence is parsed to generate styles and is also divided into 2 parts:
- essence prefix (static part, the actual name of the essence itself);
- essence suffix (parameterizable part, meaning of essence).
The prefix of the name of the essence is the first part of the name of the essence, consisting of Latin letters in lower case. It may be an abbreviation. Accordingly, the rest of the name of the essence is the prefix - the parameterizable part. For example:
ph; essence suffix:
bg; essence suffix:
c; essence suffix
The part of the notation responsible for the context of the essence can be divided into several parts by the
> symbol, which is a sequence of child elements up to the target element affected by the essence. For example:
Then, the resulting parts can be separated by the
< symbol into several parts representing a sequence of parent elements, by which the styles of the essence take effect. For example:
Media queries in notation
Each part obtained above can be separated by the
@ symbol, which is responsible for the name of the media query, whereby the styles of the essence take effect. For example:
It is possible to specify the names of several media queries, for example:
However, in such cases only the first found name of the media query is used. In this case, it is
This is done for ease of use of the notation, for example, in cases when we specify a common media query for several attributes of a child element, but for some attributes this media query should be different:
(sq200|f20|f14@sm)>.child1@md is parsing like several such lines:
In line 3 we will receive several names of media queries, but only the first name of the media query in this sequence will take effect.
Grouping helps reduce notation entry
Several parameters can be grouped together using the
| between alternate substrings inside brackets.
Instead of this:
You can do this:
That is, these entries are equivalent:
bc00F>input:h bc00F>input:a bg0>input:h bg0>input:a
In the process of applying the MN, there may be situations when you need to escape service characters, for example in this case:
We will not get what we expect, since the dot is a service symbol.
If we want the dot to fall into the parameters of the essence, then we must escape it as follows:
Thus, we get the desired:
Media queries generation
By default, the media query name is generated in CSS as it is, for example:
For the names of media queries in the notation can be set to synonyms.
mnmediasm =query: '(max-width: 991px)'priority: 0;mnmediaxs =query: '(max-width: 767px)'priority: 1;
If in the media query name recognized the abbreviated entry matching the pattern:
then media queries be generated, for example: INPUT:
The parameters of the template of the abbreviated recording of the media query in the notation are optional and some of them can be omitted, for example:
Essences of styles
In MN, the essence of a style is a named atomic abstraction with a set of options on the basis of which styles are generated. This options include:
- attributes of styles;
- ranking priority;
- an array of selectors that will be concatenated to the target selectors;
- an array of names of admixed essences;
- an array of names of essences from which the current essence is inherited;
- associative array of child essences;
- associative array of essences for specific media queries.
Essences can be of two types:
Static essences are set by setting the essence options directly.
Dynamic essences are set by setting of the generating function of essence options.
How style essences are created:
// Статическая эссенция;
It is possible to set/change the attributes of the child elements of the essence, for example, in this way:
The example of how can be declared a style essence:
It works as follows:
You just write in the markup:
The CSS for this markup is automatically generated:
Example 2. How it works with essence contexts:
(Handlers generating styles)
Into functions that you specify to generate essences of styles, are input the parameters extracted during the preliminary parsing of the essence line as a result of matching the string with the sequence of templates:
paramsni || paramsni = '';paramsi = paramsni ? '' : '!important';
PS: see function amirka/utils/route-parse-provider
Generating the essences of styles
You can configure auto-prefix for cross-browser property names of styles to the prefixes map following way:
mnpropertiesStringifyprefixedAttrstransform = true;mnpropertiesStringifyprefixedAttrstransitionDuration = true;mnpropertiesStringifyprefixedAttrspointerEvents = true;mnpropertiesStringifyprefixedAttrsuserSelect = true;mnpropertiesStringifyprefixedAttrsfilter = true;mnpropertiesStringifyprefixedAttrsboxSizing = true;
, but better like that:
You can specify which prefixes should be added like this:
The state - in MN is the part of the notation after the colon (
:), which can correspond to similar pseudo-selectors in terms of CSS.
In MN, we use abbreviated entries. So for a single state name in MN, you can specify multiple arbitrary selectors.
If you specify any other undeclared state, then it is displayed as it is:
You can parameterize states through square brackets:
mnstatesn = ':nth-child' ;
PS: Due to the fact that the parentheses are the service characters MN, necessary for grouping the substrings, square brackets are used instead.
You can write down the pseudo-class of denial without problems in the notation:
You can specify several states in the notation:
In states it is possible to use non-standard pseudo-classes as synonyms:
PS: selectors with non-standard pseudo-classes and browser prefixes for validity are automatically split into separate cascading blocks.
Separator of parent selectors:
For example, the following selector is generated for notation
So we can specify for the current element in the presence of which parent element the
bgF00 essence style will be displayed.
Separator of child selectors:
With child selectors, everything is exactly the same as with parent selectors, only the other way around.
the following selector is generated for notation
To set a specific depth of nesting, we can added a number in front of the selector, for example:
/* bgF00<1.active -> *//* bgF00<2.active -> *//* bgF00<3.active -> */
If you want the essence styles to be active if there is any selector (in particular, the
active class) on the current element:
/* bgF00<0.active -> */
If there is a negative sign, then we will get an affect of the style of essence to the child elements:
/* bgF00<-1.active -> */[/* bgF00<-2.active -> */[
You can ignore the delimiter.
If you want the essence styles to be active if there is any selector is present on the current element (in particular, class "active"), then you can write more succinctly and get the desired output:
/* bgF00.active -> */[
All of the above can also be applied to other selectors with attributes:
/* bgF00>[type=text] -> */[/* bgF00[type=text] -> */[
An example of a more complex selector:
/* bgF00.theme1.active -> */[
Separators imply that you can jointly specify parent and child elements and states in the essence context how many you need:
/* bgF00.active<.md>.anyChild -> */
(Example with container)
Linking selectors with style essences.
For clarity, consider an approximate synthetic example of the implementation of the container from Twitter Bootstrap 3.
This is done manually with CSS:
In order to do the same with MN, you can go different ways depending on your needs.
Several laconic ways:
Example 2. Without the use of predefined default synonyms for media queries:
Example 3. If we want to be able to reuse container styles in other selectors, then we can declare the container as an essence:
Thus, all the power of minimalist notation will be used, for which selectors are automatically generated:
This given example
is an abbreviated form of such a declaration:
In the examples above, the declaration of the essence is based on other more atomic essences of styles.
In this way, we can repeatedly reuse once created style essences in new essences.
Instead, we could declared the essence in the same way as the more atomic essences on which we were based before.
Suppose we do not yet have the atomic essences that we used in the previous examples, and we were too lazy to write them until that moment, or we are guided by some other reasons. Then we can declare the essence of the container in this way:
The MN has the ability to manipulate the priority of styles that allows you to succinctly override the effect of some other CSS rules.