-
Notifications
You must be signed in to change notification settings - Fork 25
/
encapsulation.js
131 lines (123 loc) · 3.37 KB
/
encapsulation.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
'use strict';
/* eslint-disable quote-props */
const autoreset = require('postcss-autoreset');
const rules = {
inherited: {
'border-collapse': 'separate',
'border-spacing': 0,
'caption-side': 'top',
'color': 'initial',
'cursor': 'auto',
'direction': 'initial',
'empty-cells': 'show',
'font-size-adjust': 'none',
'font-family': 'initial',
'font-size': 'medium',
'font-style': 'normal',
'font-stretch': 'normal',
'font-variant': 'normal',
'font-weight': 'normal',
'font': 'initial',
'letter-spacing': 'normal',
'line-height': 'normal',
'list-style-image': 'none',
'list-style-position': 'outside',
'list-style-type': 'disc',
'list-style': 'initial',
'orphans': 2,
'quotes': 'initial',
'tab-size': 8,
'text-align': 'initial',
'text-align-last': 'auto',
'text-decoration-color': 'initial',
'text-indent': 0,
'text-justify': 'auto',
'text-shadow': 'none',
'text-transform': 'none',
'visibility': 'visible',
'white-space': 'normal',
'widows': 2,
'word-break': 'normal',
'word-spacing': 'normal',
'word-wrap': 'normal'
},
nonInherited: {
'animation': 'none 0s ease 0s 1 normal none running',
'backface-visibility': 'visible',
'background': 'transparent none repeat 0 0 / auto auto padding-box border-box scroll',
'border': 'medium none currentColor',
'border-image': 'none',
'border-radius': '0',
'bottom': 'auto',
'box-shadow': 'none',
'clear': 'none',
'clip': 'auto',
'columns': 'auto',
'column-count': 'auto',
'column-fill': 'balance',
'column-gap': 'normal',
'column-rule': 'medium none currentColor',
'column-span': '1',
'column-width': 'auto',
'content': 'normal',
'counter-increment': 'none',
'counter-reset': 'none',
'float': 'none',
'height': 'auto',
'hyphens': 'none',
'left': 'auto',
'margin': '0',
'max-height': 'none',
'max-width': 'none',
'min-height': '0',
'min-width': '0',
'opacity': '1',
'outline': 'medium none invert',
'overflow': 'visible',
'overflow-x': 'visible',
'overflow-y': 'visible',
'padding': '0',
'page-break-after': 'auto',
'page-break-before': 'auto',
'page-break-inside': 'auto',
'perspective': 'none',
'perspective-origin': '50% 50%',
'position': 'static',
'right': 'auto',
'table-layout': 'auto',
'text-decoration': 'none',
'top': 'auto',
'transform': 'none',
'transform-origin': '50% 50% 0',
'transform-style': 'flat',
'transition': 'none 0s ease 0s',
'unicode-bidi': 'normal',
'vertical-align': 'baseline',
'width': 'auto',
'z-index': 'auto'
}
};
// This applies only to the Component Root
// to stop inheritance and ensure
// styles encapsulation
const resetInherited = autoreset({
reset: rules.inherited,
rulesMatcher(rule) {
const selector = rule.selector;
return (
selector.charAt(0) === '.' &&
/^\.(?:[a-z0-9]*-)?[A-Z](?:[a-zA-Z0-9]+)$/.test(selector)
);
}
});
resetInherited.postcssPlugin = 'autoreset-suitcss-encapsulation-inherited';
// This applies to the Component Root and Descendants
const resetGeneric = autoreset({
reset: rules.nonInherited,
rulesMatcher: 'suit'
});
resetGeneric.postcssPlugin = 'autoreset-suitcss-encapsulation-nonInherited';
module.exports = {
resetInherited,
resetGeneric
};