You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To eliminate the need for different places for breakpoints and only maintain a single source of truth for those, this `node_module` extracts the breakpoints defined in the currently used drupal themes breakpoint file and generates grouped `customProperties` and a separate `js` object with all necessary parameters.
9
+
To eliminate the need for different places for breakpoints and only maintain a single source of truth for those, this `node_module` extracts the breakpoints defined in the currently used Drupal themes breakpoint file and generates grouped `customProperties` and a separate `js` object with all necessary parameters.
10
10
11
-
If the draft `@custom-media` (See: https://www.w3.org/TR/mediaqueries-5/#at-ruledef-custom-media) or PostCSS (See: https://github.com/postcss/postcss) Custom-media (See: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-custom-media) plugin is already used, media queries can be written with `customProperties`. So any declaration of media queries within stylesheets is omitted and maintainability is increased.
11
+
If the draft [`@custom-media`](https://www.w3.org/TR/mediaqueries-5/#at-ruledef-custom-media) or [PostCSS](https://github.com/postcss/postcss)with [Custom-Media](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-custom-media) plugin is already used, media queries can be written with `customProperties`. So any declaration of media queries within stylesheets is omitted and maintainability is increased.
12
12
13
13
## Installation
14
14
@@ -17,27 +17,41 @@ Install as a `devDependency` with `yarn` or `npm` like:
In your themes root folder, besides your already defined breakpoints file from drupal, add a `.breakpoints.yml` configuration file. The following properties are mandatory:
25
+
In your themes root folder, besides your already defined breakpoints file from Drupal, add a `breakpoints.config.yml` configuration file. The following properties are mandatory:
26
26
27
27
```js
28
-
/**
29
-
* @type{object}
30
-
* @property{object}paths - Relativ to the themes root folder ...
31
-
* @property{string}paths.breakpoints - ...path to drupals breakpoint file
32
-
* @property{string}paths.css - ...path to your final css file
33
-
* @property{string}paths.js - ...path to your final js file
34
-
* @property{string}themeName - Drupals custom theme name
35
-
* @property{string}extractTo
36
-
* @property{boolean}js - (default true), should generate js file?
37
-
* @property{boolean}css - (default true), should generate css file?
38
-
*/
28
+
// ./lib/types.d.ts
29
+
exportinterfaceUserConfig {
30
+
drupal: {
31
+
path: string,
32
+
themeName: string,
33
+
};
34
+
js?: {
35
+
enabled?: boolean,
36
+
path?: string,
37
+
es6?:"commonjs"|"module",
38
+
};
39
+
css?: {
40
+
enabled?: boolean,
41
+
path?: string,
42
+
element?: string,
43
+
};
44
+
options?: {
45
+
mediaQuery?: boolean,
46
+
resolution?: boolean,
47
+
minWidth?: boolean,
48
+
maxWidth?: boolean,
49
+
};
50
+
}
39
51
```
40
52
53
+
You could validate your configuration files with the help of [JSON Schema Store](https://www.schemastore.org/json) and e.g [Visual Studio Code](https://code.visualstudio.com/)[YAML Extension](https://marketplace.visualstudio.com/items?itemName=redhat.vscode-yaml).
54
+
41
55
## Usage
42
56
43
57
Just run `yarn drupal-breakpoints-css start` or `npm run drupal-breakpoints-css start`. Thats it :)
@@ -71,34 +85,34 @@ theme_name.lg:
71
85
```
72
86
73
87
```css
74
-
/* Generated css file */
75
-
html {
76
-
--ThemeName-small-query: "only screen and (max-width: 47.9375rem)";
88
+
/* Generated CSS file */
89
+
:root {
90
+
--ThemeName-small-mediaQuery: "only screen and (max-width: 47.9375rem)";
77
91
--ThemeName-small-resolution: "2x";
78
92
--ThemeName-small-maxWidth: "47.9375rem";
79
-
--ThemeName-medium-query: "only screen and (min-width: 48rem) and (max-width: 63.9375rem)";
93
+
--ThemeName-medium-mediaQuery: "only screen and (min-width: 48rem) and (max-width: 63.9375rem)";
80
94
--ThemeName-medium-resolution: "2x";
81
95
--ThemeName-medium-minWidth: "48rem";
82
96
--ThemeName-medium-maxWidth: "63.9375rem";
83
-
--ThemeName-Group-large-query: "only screen and (min-width: 64rem) and (max-width: 89.9375rem)";
97
+
--ThemeName-Group-large-mediaQuery: "only screen and (min-width: 64rem) and (max-width: 89.9375rem)";
84
98
--ThemeName-Group-large-resolution: "2x";
85
99
--ThemeName-Group-large-minWidth: "64rem";
86
100
--ThemeName-Group-large-maxWidth: "89.9375rem";
87
101
}
88
102
```
89
103
90
104
```js
91
-
// Generated js file
105
+
// Generated JS file
92
106
constBREAKPOINTS= {
93
-
"ThemeName-small-query":"only screen and (max-width: 47.9375rem)",
107
+
"ThemeName-small-mediaQuery":"only screen and (max-width: 47.9375rem)",
94
108
"ThemeName-small-resolution":"2x",
95
109
"ThemeName-small-maxWidth":"47.9375rem",
96
-
"ThemeName-medium-query":
110
+
"ThemeName-medium-mediaQuery":
97
111
"only screen and (min-width: 48rem) and (max-width: 63.9375rem)",
98
112
"ThemeName-medium-resolution":"2x",
99
113
"ThemeName-medium-minWidth":"48rem",
100
114
"ThemeName-medium-maxWidth":"63.9375rem",
101
-
"ThemeName-Group-large-query":
115
+
"ThemeName-Group-large-mediaQuery":
102
116
"only screen and (min-width: 64rem) and (max-width: 89.9375rem)",
103
117
"ThemeName-Group-large-resolution":"2x",
104
118
"ThemeName-Group-large-minWidth":"64rem",
@@ -109,7 +123,7 @@ export default BREAKPOINTS;
109
123
110
124
## Acknowledgements
111
125
112
-
This **Script** uses open source software and would not have been possible without the excellent work of the [Drupal](https://www.drupal.org), [Eslint](https://babeljs.io/team), [Prettier](https://unifiedjs.com/community/member/) and [debug-js](https://github.com/debug-js/debug) teams! Thanks a lot!
126
+
This **Script** uses open source software and would not have been possible without the excellent work of the [Drupal](https://www.drupal.org), [Eslint](https://babeljs.io/team), [deepmerge](https://github.com/TehShrike/deepmerge) and [Prettier](https://unifiedjs.com/community/member/) teams! Thanks a lot!
0 commit comments