@jsb188/css 1.1.10 → 1.1.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/css/popover.css CHANGED
@@ -1,131 +1,129 @@
1
-
2
1
  /* Pop overs */
3
2
 
4
3
  .popover {
5
- position: fixed;
6
- display: flex;
7
- flex-direction: column;
8
- align-items: flex-start;
4
+ position: fixed;
5
+ display: flex;
6
+ flex-direction: column;
7
+ align-items: flex-start;
9
8
  }
10
9
 
11
10
  .popover .tooltip {
12
- display: inline-block;
13
- /* padding: .58rem .7rem; */
14
- padding: .57rem .68rem;
15
- /* box-shadow: var(--shadow-light); */
16
- box-shadow: var(--shadow);
11
+ display: inline-block;
12
+ padding: 0.58rem 0.64rem;
13
+ /* box-shadow: var(--shadow-light); */
14
+ box-shadow: var(--shadow);
17
15
  }
18
16
 
19
17
  .popover.small .tooltip:not(.w_override) {
20
- max-width: 150px;
18
+ max-width: 150px;
21
19
  }
22
20
 
23
21
  .popover.default .tooltip:not(.w_override) {
24
- max-width: 225px;
22
+ max-width: 200px;
25
23
  }
26
24
 
27
25
  /* Pop over; list */
28
26
 
29
27
  .po_list {
30
- border-radius: 6px;
28
+ border-radius: 6px;
31
29
  }
32
30
 
33
31
  .po_list .inside {
34
- /* padding: 5px; */
35
- padding: 5px;
36
- display: flex; flex-direction: column;
37
- justify-content: flex-start;
38
- align-items: stretch;
32
+ /* padding: 5px; */
33
+ padding: 5px;
34
+ display: flex;
35
+ flex-direction: column;
36
+ justify-content: flex-start;
37
+ align-items: stretch;
39
38
  }
40
39
 
41
40
  .po_list.bg a:hover {
42
- background-color: var(--color-darker-light);
41
+ background-color: var(--color-darker-light);
43
42
  }
44
43
 
45
44
  .po_list .av_item .av.main {
46
- box-shadow: 0 0 10px rgb(var(--color-bg));
45
+ box-shadow: 0 0 10px rgb(var(--color-bg));
47
46
  }
48
47
 
49
48
  /* Pop over; subtitle */
50
49
 
51
50
  .po_subtitle {
52
- position: sticky;
53
- top: 0; left: 0; right: 0;
54
- padding: 5px .4rem 8px;
55
- margin-bottom: .3rem;
56
- }
57
-
58
- .po_subtitle_cover {
59
- position: absolute;
60
- top: -5px; left: 0; right: 0;
61
- height: 5px;
51
+ position: sticky;
52
+ top: 0;
53
+ left: 0;
54
+ right: 0;
55
+ padding: 5px 0.4rem 8px;
56
+ margin-bottom: 0.3rem;
57
+ box-shadow:
58
+ 0 -5px 0 rgb(var(--color-bg)),
59
+ 0 0 7px rgb(var(--color-bg));
62
60
  }
63
61
 
64
62
  /* Pop over; list item */
65
63
 
66
64
  .po_opt .saving_area {
67
- width: 24px;
68
- transform: translateX(-4px);
65
+ width: 24px;
66
+ transform: translateX(-4px);
69
67
  }
70
68
 
71
69
  .po_opt {
72
- padding: 5px 0 5px .4375rem;
73
- border-radius: 5px;
70
+ padding: 5px 0 5px 0.4375rem;
71
+ border-radius: 5px;
74
72
  }
75
73
 
76
74
  .po_opt.default:first-child {
77
- margin-top: 5px;
75
+ margin-top: 5px;
78
76
  }
79
77
 
80
78
  .po_opt.default:last-child {
81
- margin-bottom: 5px;
79
+ margin-bottom: 5px;
82
80
  }
83
81
 
84
82
  /* Pop over; text item */
85
83
 
86
84
  .po_opt.text_item {
87
- padding: 5px .4375rem;
88
- margin-bottom: 0;
85
+ padding: 5px 0.4375rem;
86
+ margin-bottom: 0;
89
87
  }
90
88
 
91
89
  /* Pop over; different presets for list item */
92
90
 
93
91
  .po_opt.av_item {
94
- padding-top: .5rem;
95
- padding-bottom: .5rem;
92
+ padding-top: 0.5rem;
93
+ padding-bottom: 0.5rem;
96
94
  }
97
95
 
98
96
  .po_opt.preset_small {
99
- padding: .5rem 0 .5rem .4375rem;
97
+ padding: 0.5rem 0 0.5rem 0.4375rem;
100
98
  }
101
99
 
102
100
  /* Pop over; list break */
103
101
 
104
102
  .po_list_break {
105
- margin: 4px 0;
106
- border-top: solid 1px var(--color-darker-light);
103
+ margin: 4px 0;
104
+ border-top: solid 1px var(--color-darker-light);
107
105
  }
108
106
 
109
107
  /* Pop over container */
110
108
 
111
109
  .po_container {
112
- /* padding: 4px; */
113
- box-shadow: var(--shadow-light);
110
+ /* padding: 4px; */
111
+ box-shadow: var(--shadow-light);
114
112
  }
115
113
 
116
114
  .po_container .inside {
117
- display: flex;
118
- flex-direction: column;
115
+ display: flex;
116
+ flex-direction: column;
119
117
 
120
- width: 300px;
121
- min-height: 200px;
122
- /* max-height: calc(100vh - 20px); */
123
- max-height: 70vh;
118
+ width: 300px;
119
+ min-height: 150px;
120
+ /* max-height: calc(100vh - 20px); */
121
+ max-height: 70vh;
124
122
  }
125
123
 
126
124
  /* Pop over image */
127
125
 
128
126
  .pu_img {
129
- max-width: 400px;
130
- margin: 10px; /* 10px is also hard coded into the React Component */
127
+ max-width: 400px;
128
+ margin: 10px; /* 10px is also hard coded into the React Component */
131
129
  }
package/package.json CHANGED
@@ -1,24 +1,25 @@
1
1
  {
2
- "name": "@jsb188/css",
3
- "version": "1.1.10",
4
- "description": "Re-usable, base CSS styles for any app (NOTE: Bring your own variables).",
5
- "license": "ISC",
6
- "author": "jsb188",
7
- "type": "module",
8
- "exports": {
9
- "./_global.css": "./css/_global.css",
10
- "./_colors.generated.css": "./css/_colors.generated.css",
11
- "./alert.css": "./css/alert.css",
12
- "./animate.css": "./css/animate.css",
13
- "./form.css": "./css/form.css",
14
- "./layout.css": "./css/layout.css",
15
- "./loading.css": "./css/loading.css",
16
- "./misc.css": "./css/misc.css",
17
- "./modal.css": "./css/modal.css",
18
- "./popover.css": "./css/popover.css"
19
- },
20
- "scripts": {
21
- "gen:responsive-css": "node ./scripts/generateResponsiveCss.js",
22
- "test": "echo \"Error: no test specified\" && exit 1"
23
- }
2
+ "name": "@jsb188/css",
3
+ "version": "1.1.12",
4
+ "description": "Re-usable, base CSS styles for any app (NOTE: Bring your own variables).",
5
+ "license": "ISC",
6
+ "author": "jsb188",
7
+ "type": "module",
8
+ "exports": {
9
+ "./_global.css": "./css/_global.css",
10
+ "./_colors.generated.css": "./css/_colors.generated.css",
11
+ "./alert.css": "./css/alert.css",
12
+ "./animate.css": "./css/animate.css",
13
+ "./form.css": "./css/form.css",
14
+ "./layout.css": "./css/layout.css",
15
+ "./loading.css": "./css/loading.css",
16
+ "./misc.css": "./css/misc.css",
17
+ "./modal.css": "./css/modal.css",
18
+ "./popover.css": "./css/popover.css"
19
+ },
20
+ "scripts": {
21
+ "gen:responsive-css": "node ./scripts/generateResponsiveCss.js",
22
+ "test": "echo \"Error: no test specified\" && exit 1"
23
+ },
24
+ "peerDependencies": {}
24
25
  }
@@ -10,49 +10,56 @@ const responsiveOutputPath = path.join(cssDir, '_responsive.generated.css');
10
10
  const colorsOutputPath = path.join(cssDir, '_colors.generated.css');
11
11
 
12
12
  const responsiveBreakpoints = [
13
- ['landscape', '--responsive-mobile-landscape'],
14
- ['portrait', '--responsive-mobile-portrait'],
15
- ['phone', '--responsive-phone-wide'],
16
- ['narrow', '--responsive-phone-narrow'],
17
- ['tiny', '--responsive-phone-tiny'],
13
+ ['landscape', '--responsive-mobile-landscape'],
14
+ ['portrait', '--responsive-mobile-portrait'],
15
+ ['phone', '--responsive-phone-wide'],
16
+ ['narrow', '--responsive-phone-narrow'],
17
+ ['tiny', '--responsive-phone-tiny'],
18
18
  ];
19
19
 
20
20
  const colorPalettes = [
21
- 'red',
22
- 'orange',
23
- 'brown',
24
- 'amber',
25
- 'yellow',
26
- 'lime',
27
- 'green',
28
- 'emerald',
29
- 'teal',
30
- 'cyan',
31
- 'sky',
32
- 'blue',
33
- 'indigo',
34
- 'violet',
35
- 'purple',
36
- 'fuchsia',
37
- 'pink',
38
- 'rose',
39
- 'slate',
40
- 'zinc',
41
- 'stone',
21
+ 'red',
22
+ 'orange',
23
+ 'brown',
24
+ 'amber',
25
+ 'yellow',
26
+ 'lime',
27
+ 'green',
28
+ 'emerald',
29
+ 'teal',
30
+ 'cyan',
31
+ 'sky',
32
+ 'blue',
33
+ 'indigo',
34
+ 'violet',
35
+ 'purple',
36
+ 'fuchsia',
37
+ 'pink',
38
+ 'rose',
39
+ 'slate',
40
+ 'zinc',
41
+ 'stone',
42
42
  ];
43
43
 
44
44
  const colorShades = [
45
- ['fd', 'fade'],
46
- ['lt', 'light'],
47
- ['md', 'medium'],
48
- ['bd', 'bold'],
49
- ['', 'default'],
45
+ ['fd', 'fade'],
46
+ ['lt', 'light'],
47
+ ['md', 'medium'],
48
+ ['bd', 'bold'],
49
+ ['', 'default'],
50
+ ];
51
+
52
+ const colorAltShades = [
53
+ ['fd', 'fade'],
54
+ ['lt', 'light'],
55
+ ['md', 'medium'],
56
+ ['df', 'default'],
50
57
  ];
51
58
 
52
59
  const colorRuleGroups = [
53
- ['cl', 'color'],
54
- ['bg', 'background-color'],
55
- ['bd', 'border-color'],
60
+ ['cl', 'color'],
61
+ ['bg', 'background-color'],
62
+ ['bd', 'border-color'],
56
63
  ];
57
64
 
58
65
  /*
@@ -60,7 +67,7 @@ Reads the source responsive utility CSS file that will be expanded into
60
67
  breakpoint-scoped utility classes.
61
68
  */
62
69
  async function readSourceCSS() {
63
- return readFile(responsiveSourcePath, 'utf8');
70
+ return readFile(responsiveSourcePath, 'utf8');
64
71
  }
65
72
 
66
73
  /*
@@ -68,15 +75,16 @@ Extracts simple single-selector utility rules from the source CSS file so each
68
75
  selector can be cloned with responsive prefixes.
69
76
  */
70
77
  function parseUtilityRules(sourceCSS) {
71
- const utilityRulePattern = /(^|\n)\s*(\.[A-Za-z0-9_-][A-Za-z0-9_-]*)\s*\{([^}]*)\}/g;
72
-
73
- return Array.from(
74
- sourceCSS.matchAll(utilityRulePattern),
75
- ([, , selector, declarations]) => ({
76
- selector,
77
- declarations: declarations.trim(),
78
- })
79
- );
78
+ const utilityRulePattern =
79
+ /(^|\n)\s*(\.[A-Za-z0-9_-][A-Za-z0-9_-]*)\s*\{([^}]*)\}/g;
80
+
81
+ return Array.from(
82
+ sourceCSS.matchAll(utilityRulePattern),
83
+ ([, , selector, declarations]) => ({
84
+ selector,
85
+ declarations: declarations.trim(),
86
+ }),
87
+ );
80
88
  }
81
89
 
82
90
  /*
@@ -84,45 +92,92 @@ Builds the generated CSS file contents by wrapping cloned utility selectors in
84
92
  their corresponding custom-media breakpoints.
85
93
  */
86
94
  function buildGeneratedResponsiveCSS(rules) {
87
- const sections = responsiveBreakpoints.map(([prefix, mediaName]) => {
88
- const clonedRules = rules.map(({ selector, declarations }) => {
89
- const className = selector.slice(1);
90
-
91
- return ` .${prefix}\\:${className} { ${declarations} }`;
92
- });
93
-
94
- return `@media (${mediaName}) {\n${clonedRules.join('\n')}\n}`;
95
- });
96
-
97
- return [
98
- '/* This file is auto-generated by scripts/generateResponsiveCss.js. */',
99
- '/* Do not edit this file directly. Edit _responsive.css and regenerate. */',
100
- '',
101
- ...sections,
102
- '',
103
- ].join('\n');
95
+ const sections = responsiveBreakpoints.map(([prefix, mediaName]) => {
96
+ const clonedRules = rules.map(({ selector, declarations }) => {
97
+ const className = selector.slice(1);
98
+
99
+ return ` .${prefix}\\:${className} { ${declarations} }`;
100
+ });
101
+
102
+ return `@media (${mediaName}) {\n${clonedRules.join('\n')}\n}`;
103
+ });
104
+
105
+ return [
106
+ '/* This file is auto-generated by scripts/generateResponsiveCss.js. */',
107
+ '/* Do not edit this file directly. Edit _responsive.css and regenerate. */',
108
+ '',
109
+ ...sections,
110
+ '',
111
+ ].join('\n');
104
112
  }
105
113
 
106
114
  /*
107
115
  Builds one palette utility rule for a color, shade, and CSS property group.
108
116
  Default background rules also set a readable foreground color.
109
117
  */
110
- function buildColorRule(rulePrefix, propertyName, palette, classSuffix, tokenSuffix) {
111
- const shadeClassSuffix = classSuffix ? `_${classSuffix}` : '';
112
- const className = `${rulePrefix}_${palette}${shadeClassSuffix}`;
113
- const selectors = [
114
- `.${className}`,
115
- `.${className}_hv:hover`,
116
- ];
117
- const declarations = [
118
- `${propertyName}: var(--color-${palette}-${tokenSuffix}) !important;`,
119
- ];
120
-
121
- if (rulePrefix === 'bg' && tokenSuffix === 'default') {
122
- declarations.push('color: var(--color-solid) !important;');
123
- }
124
-
125
- return `${selectors.join(', ')} { ${declarations.join(' ')} }`;
118
+ function buildColorRule(
119
+ rulePrefix,
120
+ propertyName,
121
+ palette,
122
+ classSuffix,
123
+ tokenSuffix,
124
+ ) {
125
+ const shadeClassSuffix = classSuffix ? `_${classSuffix}` : '';
126
+ const className = `${rulePrefix}_${palette}${shadeClassSuffix}`;
127
+ const selectors = [`.${className}`, `.${className}_hv:hover`];
128
+ const declarations = [
129
+ `${propertyName}: var(--color-${palette}-${tokenSuffix}) !important;`,
130
+ ];
131
+
132
+ if (rulePrefix === 'bg' && tokenSuffix === 'default') {
133
+ declarations.push('color: var(--color-solid) !important;');
134
+ }
135
+
136
+ return `${selectors.join(', ')} { ${declarations.join(' ')} }`;
137
+ }
138
+
139
+ /*
140
+ Builds one alt background utility rule for a color and shade.
141
+ */
142
+ function buildAltBackgroundColorRule(palette, classSuffix, tokenSuffix) {
143
+ const className = `bg_${palette}_alt_${classSuffix}`;
144
+ const selectors = [`.${className}`, `.${className}_hv:hover`];
145
+
146
+ return `${selectors.join(', ')} { background-color: var(--color-${palette}-alt-${tokenSuffix}) !important; }`;
147
+ }
148
+
149
+ /*
150
+ Builds one alt foreground/border utility rule for a color, mapping the bare
151
+ "_alt" suffix to the muted-vivid alt-default token.
152
+ */
153
+ function buildAltColorRule(rulePrefix, propertyName, palette) {
154
+ const className = `${rulePrefix}_${palette}_alt`;
155
+ const selectors = [`.${className}`, `.${className}_hv:hover`];
156
+
157
+ return `${selectors.join(', ')} { ${propertyName}: var(--color-${palette}-alt-default) !important; }`;
158
+ }
159
+
160
+ /*
161
+ Builds one outline utility rule for a palette's default or light token,
162
+ including the equivalent alt token when requested.
163
+ */
164
+ function buildOutlineColorRule(
165
+ palette,
166
+ classSuffix,
167
+ tokenSuffix,
168
+ isAlt = false,
169
+ ) {
170
+ const altClassSuffix = isAlt ? '_alt' : '';
171
+ const shadeClassSuffix = classSuffix ? `_${classSuffix}` : '';
172
+ const altTokenSuffix = isAlt ? '-alt' : '';
173
+ const className = `ol_${palette}${altClassSuffix}${shadeClassSuffix}`;
174
+ const selectors = [
175
+ `.${className}`,
176
+ `.${className}_hv:hover`,
177
+ `.${className}_focus:focus`,
178
+ ];
179
+
180
+ return `${selectors.join(', ')} { outline: 3px solid rgb(var(--color-${palette}${altTokenSuffix}-${tokenSuffix})); outline-offset: -1px; }`;
126
181
  }
127
182
 
128
183
  /*
@@ -130,31 +185,58 @@ Builds the generated color utility CSS file contents from palette, shade, and
130
185
  property rule definitions.
131
186
  */
132
187
  function buildGeneratedColorsCSS() {
133
- const sections = colorRuleGroups.map(([rulePrefix, propertyName]) => {
134
- const rules = colorPalettes.flatMap((palette) => {
135
- return colorShades.map(([classSuffix, tokenSuffix]) => {
136
- return buildColorRule(
137
- rulePrefix,
138
- propertyName,
139
- palette,
140
- classSuffix,
141
- tokenSuffix
142
- );
143
- });
144
- });
145
-
146
- return rules.join('\n');
147
- });
148
-
149
- return [
150
- '/* This file is auto-generated by scripts/generateResponsiveCss.js. */',
151
- '/* Do not edit this file directly. Update the color generator definitions and regenerate. */',
152
- '',
153
- '/* Colors - Palette */',
154
- '',
155
- ...sections,
156
- '',
157
- ].join('\n');
188
+ const sections = colorRuleGroups.map(([rulePrefix, propertyName]) => {
189
+ const rules = colorPalettes.flatMap((palette) => {
190
+ const paletteRules = colorShades.map(([classSuffix, tokenSuffix]) => {
191
+ return buildColorRule(
192
+ rulePrefix,
193
+ propertyName,
194
+ palette,
195
+ classSuffix,
196
+ tokenSuffix,
197
+ );
198
+ });
199
+
200
+ if (rulePrefix === 'bg') {
201
+ return [
202
+ ...paletteRules,
203
+ ...colorAltShades.map(([classSuffix, tokenSuffix]) => {
204
+ return buildAltBackgroundColorRule(
205
+ palette,
206
+ classSuffix,
207
+ tokenSuffix,
208
+ );
209
+ }),
210
+ ];
211
+ }
212
+
213
+ return [
214
+ ...paletteRules,
215
+ buildAltColorRule(rulePrefix, propertyName, palette),
216
+ ];
217
+ });
218
+
219
+ return rules.join('\n');
220
+ });
221
+ const outlineRules = colorPalettes.flatMap((palette) => {
222
+ return [
223
+ buildOutlineColorRule(palette, '', 'default'),
224
+ buildOutlineColorRule(palette, 'lt', 'light'),
225
+ buildOutlineColorRule(palette, '', 'default', true),
226
+ buildOutlineColorRule(palette, 'lt', 'light', true),
227
+ ];
228
+ });
229
+
230
+ return [
231
+ '/* This file is auto-generated by scripts/generateResponsiveCss.js. */',
232
+ '/* Do not edit this file directly. Update the color generator definitions and regenerate. */',
233
+ '',
234
+ '/* Colors - Palette */',
235
+ '',
236
+ ...sections,
237
+ outlineRules.join('\n'),
238
+ '',
239
+ ].join('\n');
158
240
  }
159
241
 
160
242
  /*
@@ -162,8 +244,8 @@ Writes a generated CSS file to the shared CSS package so apps can import it
162
244
  through the existing global stylesheet.
163
245
  */
164
246
  async function writeGeneratedCSS(outputPath, outputCSS) {
165
- await mkdir(cssDir, { recursive: true });
166
- await writeFile(outputPath, outputCSS, 'utf8');
247
+ await mkdir(cssDir, { recursive: true });
248
+ await writeFile(outputPath, outputCSS, 'utf8');
167
249
  }
168
250
 
169
251
  /*
@@ -171,18 +253,22 @@ Generates the shared CSS files that can be derived from compact utility
171
253
  definitions.
172
254
  */
173
255
  async function main() {
174
- const sourceCSS = await readSourceCSS();
175
- const rules = parseUtilityRules(sourceCSS);
176
- const responsiveOutputCSS = buildGeneratedResponsiveCSS(rules);
177
- const colorsOutputCSS = buildGeneratedColorsCSS();
178
-
179
- await Promise.all([
180
- writeGeneratedCSS(responsiveOutputPath, responsiveOutputCSS),
181
- writeGeneratedCSS(colorsOutputPath, colorsOutputCSS),
182
- ]);
183
-
184
- console.log(`Generated ${path.relative(process.cwd(), responsiveOutputPath)} from ${path.relative(process.cwd(), responsiveSourcePath)}.`);
185
- console.log(`Generated ${path.relative(process.cwd(), colorsOutputPath)} from color generator definitions.`);
256
+ const sourceCSS = await readSourceCSS();
257
+ const rules = parseUtilityRules(sourceCSS);
258
+ const responsiveOutputCSS = buildGeneratedResponsiveCSS(rules);
259
+ const colorsOutputCSS = buildGeneratedColorsCSS();
260
+
261
+ await Promise.all([
262
+ writeGeneratedCSS(responsiveOutputPath, responsiveOutputCSS),
263
+ writeGeneratedCSS(colorsOutputPath, colorsOutputCSS),
264
+ ]);
265
+
266
+ console.log(
267
+ `Generated ${path.relative(process.cwd(), responsiveOutputPath)} from ${path.relative(process.cwd(), responsiveSourcePath)}.`,
268
+ );
269
+ console.log(
270
+ `Generated ${path.relative(process.cwd(), colorsOutputPath)} from color generator definitions.`,
271
+ );
186
272
  }
187
273
 
188
274
  await main();