bootstrap-gridkit 0.0.0-stage → 1.0.2

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 ixon
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,142 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
1
+ # bootstrap-gridkit
2
+
3
+ A lightweight and flexible responsive grid toolkit for building structured layouts across modern web applications.
4
+
5
+ `bootstrap-gridkit` provides a collection of responsive layout utilities, grid configurations, and flexible column systems inspired by the Bootstrap grid approach. It helps developers create consistent page layouts, manage responsive breakpoints, and organize content across different screen sizes.
6
+
7
+ Designed for simplicity and flexibility, Bootstrap GridKit offers a reusable foundation for responsive layouts without requiring the entire Bootstrap framework.
8
+
9
+ ## Features
10
+
11
+ - **Responsive Grid System** – Create flexible layouts that adapt to different screen sizes.
12
+ - **Flexible Columns** – Organize content using configurable column structures.
13
+ - **Responsive Breakpoints** – Control layouts across mobile, tablet, and desktop devices.
14
+ - **Customizable Gutters** – Manage spacing between rows and columns.
15
+ - **Container Utilities** – Establish consistent content widths and alignment.
16
+ - **Lightweight Design** – Use grid functionality without importing a complete UI framework.
17
+ - **Framework Independent** – Integrate with React, Next.js, Vue, or standard HTML projects.
18
+ - **Easy Customization** – Extend grid styles to match your application requirements.
19
+
20
+ ## Installation
21
+
22
+ Install using npm:
23
+
24
+ ```bash
25
+ npm install bootstrap-gridkit
26
+ ```
27
+
28
+ Using Yarn:
29
+
30
+ ```bash
31
+ yarn add bootstrap-gridkit
32
+ ```
33
+
34
+ Using pnpm:
35
+
36
+ ```bash
37
+ pnpm add bootstrap-gridkit
38
+ ```
39
+
40
+ ## Usage
41
+
42
+ Import the stylesheet into your application:
43
+
44
+ ```javascript
45
+ import 'bootstrap-gridkit/dist/index.css';
46
+ ```
47
+
48
+ ## Basic Example
49
+
50
+ ```html
51
+ <div class="container">
52
+ <div class="row">
53
+ <div class="col-12 col-md-6">
54
+ <div class="grid-item">Column One</div>
55
+ </div>
56
+
57
+ <div class="col-12 col-md-6">
58
+ <div class="grid-item">Column Two</div>
59
+ </div>
60
+ </div>
61
+ </div>
62
+ ```
63
+
64
+ The example demonstrates a two-column layout on medium and larger screens, with each column occupying the full width on smaller screens.
65
+
66
+ ## Responsive Layout
67
+
68
+ GridKit is designed to support responsive layouts through breakpoint-based column classes.
69
+
70
+ Example layout:
71
+
72
+ ```html
73
+ <div class="container">
74
+ <div class="row">
75
+ <div class="col-12 col-sm-6 col-lg-4">
76
+ Column One
77
+ </div>
78
+
79
+ <div class="col-12 col-sm-6 col-lg-4">
80
+ Column Two
81
+ </div>
82
+
83
+ <div class="col-12 col-sm-12 col-lg-4">
84
+ Column Three
85
+ </div>
86
+ </div>
87
+ </div>
88
+ ```
89
+
90
+ ## Customization
91
+
92
+ Grid styles, gutters, breakpoints, and container widths can be extended to accommodate different design requirements.
93
+
94
+ The toolkit is intended to provide a flexible layout foundation rather than enforce a specific visual design.
95
+
96
+ ## Use Cases
97
+
98
+ - Responsive website layouts
99
+ - Dashboard interfaces
100
+ - Landing pages
101
+ - Admin panels
102
+ - Application content grids
103
+ - Reusable frontend templates
104
+ - Component-based web applications
105
+
106
+ ## Browser Compatibility
107
+
108
+ Designed for modern browsers supporting standard CSS layout features, including Flexbox and CSS media queries.
109
+
110
+ ## Development
111
+
112
+ Clone the repository:
113
+
114
+ ```bash
115
+ git clone <repository-url>
116
+ cd bootstrap-gridkit
117
+ ```
118
+
119
+ Install dependencies:
120
+
121
+ ```bash
122
+ npm install
123
+ ```
124
+
125
+ Build the package:
126
+
127
+ ```bash
128
+ npm run build
129
+ ```
130
+
131
+ ## Contributing
132
+
133
+ Contributions, suggestions, and improvements are welcome.
134
+
135
+ 1. Fork the repository.
136
+ 2. Create a feature branch.
137
+ 3. Implement your changes.
138
+ 4. Submit a pull request with a clear description.
139
+
140
+ ## License
141
+
142
+ MIT License.
package/package.json CHANGED
@@ -1,6 +1,55 @@
1
- {
2
- "name": "bootstrap-gridkit",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
1
+ {
2
+ "name": "bootstrap-gridkit",
3
+ "version": "1.0.2",
4
+ "description": "A lightweight and flexible responsive grid toolkit for building modern web layouts with reusable columns, containers, gutters, and breakpoint utilities.",
5
+ "main": "plugin.js",
6
+ "exports": "./plugin.js",
7
+ "files": [
8
+ "plugin.js",
9
+ "src",
10
+ "README.md",
11
+ "LICENSE"
12
+ ],
13
+ "homepage": "https://ixon.github.io/bootstrap-gridkit/",
14
+ "repository": "https://github.com/ixon/bootstrap-gridkit/",
15
+ "author": "ixon",
16
+ "license": "MIT",
17
+ "keywords": [
18
+ "bootstrap-gridkit",
19
+ "bootstrap-grid",
20
+ "css-grid",
21
+ "responsive-grid",
22
+ "grid-system",
23
+ "css-framework",
24
+ "layout-toolkit",
25
+ "responsive-layout",
26
+ "flexbox",
27
+ "css-utilities",
28
+ "frontend",
29
+ "web-design",
30
+ "responsive-design"
31
+ ],
32
+ "scripts": {
33
+ "lint": "eslint . --ext .js",
34
+ "test": "node --test"
35
+ },
36
+ "dependencies": {
37
+ "animate.css": "^4.1.1",
38
+ "postcss": "^8.4.5",
39
+ "@ixorg/ui-library": "^1.0.1",
40
+ "postcss-js": "^3.0.3",
41
+ "postcss-selector-parser": "^6.0.8"
42
+ },
43
+ "devDependencies": {
44
+ "eslint": "^8.5.0",
45
+ "eslint-config-airbnb-base": "15.0.0",
46
+ "eslint-plugin-import": "^2.25.2",
47
+ "tailwindcss": "^3.0.7"
48
+ },
49
+ "peerDependencies": {
50
+ "tailwindcss": "^3"
51
+ },
52
+ "engines": {
53
+ "node": ">=18"
54
+ }
55
+ }
package/plugin.js ADDED
@@ -0,0 +1,21 @@
1
+ 'use strict';
2
+
3
+ const tailwindPlugin = require('tailwindcss/plugin');
4
+ const { loadCatalog } = require('./src/catalog');
5
+ const { normalizeOptions } = require('./src/config');
6
+ const { buildStyles } = require('./src/styles');
7
+
8
+ function keyframeTailwindPlugin(options = {}) {
9
+ const config = normalizeOptions(options);
10
+
11
+ return tailwindPlugin(({ addBase, addUtilities }) => {
12
+ const styles = buildStyles(loadCatalog(), config);
13
+ addBase(styles.base);
14
+ addUtilities(styles.utilities);
15
+ });
16
+ }
17
+
18
+ keyframeTailwindPlugin.catalog = () => loadCatalog().names.slice();
19
+ keyframeTailwindPlugin.normalizeOptions = normalizeOptions;
20
+
21
+ module.exports = keyframeTailwindPlugin;
package/src/catalog.js ADDED
@@ -0,0 +1,62 @@
1
+ 'use strict';
2
+
3
+ const fs = require('fs');
4
+ const postcss = require('postcss');
5
+ const selectorParser = require('postcss-selector-parser');
6
+
7
+ let cachedCatalog;
8
+
9
+ function animateCssPath() {
10
+ try {
11
+ return require.resolve('animate.css/animate.css');
12
+ } catch (error) {
13
+ const wrapped = new Error('bootstrap-gridkit: unable to resolve animate.css/animate.css');
14
+ wrapped.cause = error;
15
+ throw wrapped;
16
+ }
17
+ }
18
+
19
+ function sourceClasses(selector) {
20
+ const classes = [];
21
+ selectorParser(selectors => selectors.walkClasses(node => classes.push(node.value)))
22
+ .processSync(selector);
23
+ return classes.filter(name => name.startsWith('animate__'));
24
+ }
25
+
26
+ function loadCatalog() {
27
+ if (cachedCatalog) return cachedCatalog;
28
+
29
+ const root = postcss.parse(fs.readFileSync(animateCssPath(), 'utf8'));
30
+ const keyframes = new Map();
31
+ const animations = new Map();
32
+
33
+ root.walkAtRules(/^(?:-webkit-)?keyframes$/, (rule) => {
34
+ if (!keyframes.has(rule.params)) keyframes.set(rule.params, rule.clone());
35
+ });
36
+
37
+ root.walkRules((rule) => {
38
+ const names = sourceClasses(rule.selector)
39
+ .filter(name => name !== 'animate__animated')
40
+ .map(name => name.slice('animate__'.length));
41
+ if (names.length === 0) return;
42
+
43
+ let animationName;
44
+ rule.walkDecls(/^(?:-webkit-)?animation-name$/, declaration => {
45
+ animationName = declaration.value;
46
+ });
47
+ if (!animationName || !keyframes.has(animationName)) return;
48
+
49
+ names.forEach(name => animations.set(name, {
50
+ name,
51
+ keyframeName: animationName,
52
+ declarations: rule.nodes.map(node => node.clone()),
53
+ keyframes: keyframes.get(animationName).clone()
54
+ }));
55
+ });
56
+
57
+ const names = [...animations.keys()].sort();
58
+ cachedCatalog = Object.freeze({ animations, names: Object.freeze(names) });
59
+ return cachedCatalog;
60
+ }
61
+
62
+ module.exports = { loadCatalog, sourceClasses };
package/src/config.js ADDED
@@ -0,0 +1,92 @@
1
+ 'use strict';
2
+
3
+ const DEFAULTS = Object.freeze({
4
+ prefix: 'keyframe',
5
+ animations: '*',
6
+ exclude: [],
7
+ aliases: {},
8
+ duration: '1s',
9
+ delay: '0s',
10
+ iterationCount: '1',
11
+ namespaceKeyframes: true,
12
+ respectReducedMotion: true,
13
+ modifiers: true,
14
+ durations: {
15
+ faster: '500ms',
16
+ fast: '800ms',
17
+ slow: '2s',
18
+ slower: '3s'
19
+ },
20
+ delays: {
21
+ '1s': '1s',
22
+ '2s': '2s',
23
+ '3s': '3s',
24
+ '4s': '4s',
25
+ '5s': '5s'
26
+ },
27
+ repeats: {
28
+ 1: '1',
29
+ 2: '2',
30
+ 3: '3',
31
+ infinite: 'infinite'
32
+ }
33
+ });
34
+
35
+ const isRecord = value => value !== null && typeof value === 'object' && !Array.isArray(value);
36
+
37
+ function assertString(value, path) {
38
+ if (typeof value !== 'string' || value.trim() === '') {
39
+ throw new TypeError(`bootstrap-gridkit: ${path} must be a non-empty string`);
40
+ }
41
+ return value.trim();
42
+ }
43
+
44
+ function stringList(value, path, allowWildcard = false) {
45
+ if (allowWildcard && value === '*') return '*';
46
+ if (!Array.isArray(value)) {
47
+ throw new TypeError(`bootstrap-gridkit: ${path} must be an array${allowWildcard ? " or '*'" : ''}`);
48
+ }
49
+ return [...new Set(value.map((item, index) => assertString(item, `${path}[${index}]`)))];
50
+ }
51
+
52
+ function stringMap(value, path) {
53
+ if (!isRecord(value)) throw new TypeError(`bootstrap-gridkit: ${path} must be an object`);
54
+ return Object.fromEntries(Object.entries(value).map(([key, item]) => [
55
+ assertString(key, `${path} key`),
56
+ assertString(item, `${path}.${key}`)
57
+ ]));
58
+ }
59
+
60
+ function normalizeOptions(options) {
61
+ if (!isRecord(options)) throw new TypeError('bootstrap-gridkit: options must be an object');
62
+
63
+ const config = {
64
+ prefix: assertString(options.prefix ?? DEFAULTS.prefix, 'prefix'),
65
+ animations: stringList(options.animations ?? options.classes ?? DEFAULTS.animations, 'animations', true),
66
+ exclude: stringList(options.exclude ?? DEFAULTS.exclude, 'exclude'),
67
+ aliases: stringMap(options.aliases ?? DEFAULTS.aliases, 'aliases'),
68
+ duration: assertString(options.duration ?? DEFAULTS.duration, 'duration'),
69
+ delay: assertString(options.delay ?? DEFAULTS.delay, 'delay'),
70
+ iterationCount: assertString(options.iterationCount ?? DEFAULTS.iterationCount, 'iterationCount'),
71
+ namespaceKeyframes: options.namespaceKeyframes ?? DEFAULTS.namespaceKeyframes,
72
+ respectReducedMotion: options.respectReducedMotion ?? DEFAULTS.respectReducedMotion,
73
+ modifiers: options.modifiers ?? DEFAULTS.modifiers,
74
+ durations: stringMap(options.durations ?? DEFAULTS.durations, 'durations'),
75
+ delays: stringMap(options.delays ?? DEFAULTS.delays, 'delays'),
76
+ repeats: stringMap(options.repeats ?? DEFAULTS.repeats, 'repeats')
77
+ };
78
+
79
+ ['namespaceKeyframes', 'respectReducedMotion', 'modifiers'].forEach((key) => {
80
+ if (typeof config[key] !== 'boolean') {
81
+ throw new TypeError(`bootstrap-gridkit: ${key} must be a boolean`);
82
+ }
83
+ });
84
+
85
+ if (!/^-?[_a-zA-Z]+[_a-zA-Z0-9-]*$/.test(config.prefix)) {
86
+ throw new TypeError('bootstrap-gridkit: prefix must be a valid CSS class identifier');
87
+ }
88
+
89
+ return Object.freeze(config);
90
+ }
91
+
92
+ module.exports = { DEFAULTS, normalizeOptions };
package/src/motion.js ADDED
@@ -0,0 +1,33 @@
1
+ 'use strict';
2
+
3
+ const postcss = require('postcss');
4
+ const postcssJs = require('postcss-js');
5
+ const postcssAnimateUtils = require('@ixorg/ui-library');
6
+
7
+ function toPostcssOptions(config) {
8
+ return {
9
+ variables: {
10
+ enabled: true,
11
+ selector: ':root',
12
+ prefix: 'keyframe',
13
+ preserveExisting: false,
14
+ values: {
15
+ duration: config.duration,
16
+ delay: config.delay,
17
+ iterationCount: config.iterationCount
18
+ }
19
+ },
20
+ rewrite: false,
21
+ namespace: null,
22
+ webkit: false,
23
+ reducedMotion: false
24
+ };
25
+ }
26
+
27
+ function buildMotionBase(config) {
28
+ const processor = postcss([postcssAnimateUtils(toPostcssOptions(config))]);
29
+ const result = processor.process('', { from: undefined }).sync();
30
+ return postcssJs.objectify(result.root);
31
+ }
32
+
33
+ module.exports = { buildMotionBase, toPostcssOptions };
package/src/styles.js ADDED
@@ -0,0 +1,101 @@
1
+ 'use strict';
2
+
3
+ const postcss = require('postcss');
4
+ const postcssJs = require('postcss-js');
5
+ const { buildMotionBase } = require('./motion');
6
+
7
+ const kebab = value => value.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase();
8
+
9
+ function selectAnimations(catalog, config) {
10
+ const requested = config.animations === '*' ? catalog.names : config.animations;
11
+ const excluded = new Set(config.exclude);
12
+ const unknown = requested.filter(name => !catalog.animations.has(name));
13
+ const badAliases = Object.entries(config.aliases).filter(([, target]) => !catalog.animations.has(target));
14
+
15
+ if (unknown.length || badAliases.length) {
16
+ const invalid = [...unknown, ...badAliases.map(([alias, target]) => `${alias} -> ${target}`)];
17
+ throw new Error(`bootstrap-gridkit: unknown animation(s): ${invalid.join(', ')}`);
18
+ }
19
+
20
+ const selected = requested
21
+ .filter(name => !excluded.has(name))
22
+ .map(name => [name, catalog.animations.get(name)]);
23
+
24
+ Object.entries(config.aliases).forEach(([alias, target]) => {
25
+ if (!excluded.has(alias)) selected.push([alias, catalog.animations.get(target)]);
26
+ });
27
+ return selected;
28
+ }
29
+
30
+ function declarationObject(nodes, keyframeName) {
31
+ return nodes.reduce((result, node) => {
32
+ if (node.type !== 'decl') return result;
33
+ const property = node.prop.replace(/^-(webkit|moz|ms|o)-/, '');
34
+ result[property] = /animation-name$/.test(property) ? keyframeName : node.value;
35
+ return result;
36
+ }, {});
37
+ }
38
+
39
+ function keyframesObject(rule, name) {
40
+ const clone = rule.clone({ name: 'keyframes', params: name });
41
+ const root = postcss.root({ nodes: [clone] });
42
+ return postcssJs.objectify(root);
43
+ }
44
+
45
+ function modifierUtilities(config) {
46
+ if (!config.modifiers) return {};
47
+ const prefix = `.${config.prefix}`;
48
+ const utilities = {
49
+ [`${prefix}-paused`]: { 'animation-play-state': 'paused' },
50
+ [`${prefix}-running`]: { 'animation-play-state': 'running' }
51
+ };
52
+ Object.entries(config.durations).forEach(([token, value]) => {
53
+ utilities[`${prefix}-duration-${token}`] = { '--keyframe-duration': value };
54
+ });
55
+ Object.entries(config.delays).forEach(([token, value]) => {
56
+ utilities[`${prefix}-delay-${token}`] = { '--keyframe-delay': value };
57
+ });
58
+ Object.entries(config.repeats).forEach(([token, value]) => {
59
+ utilities[`${prefix}-repeat-${token}`] = { '--keyframe-iteration-count': value };
60
+ });
61
+ return utilities;
62
+ }
63
+
64
+ function buildStyles(catalog, config) {
65
+ const baseSelector = `.${config.prefix}`;
66
+ const base = buildMotionBase(config);
67
+ const utilities = {
68
+ [baseSelector]: {
69
+ 'animation-duration': 'var(--keyframe-duration)',
70
+ 'animation-delay': 'var(--keyframe-delay)',
71
+ 'animation-iteration-count': 'var(--keyframe-iteration-count)',
72
+ 'animation-fill-mode': 'both'
73
+ },
74
+ ...modifierUtilities(config)
75
+ };
76
+
77
+ selectAnimations(catalog, config).forEach(([publicName, animation]) => {
78
+ const keyframeName = config.namespaceKeyframes
79
+ ? `${config.prefix}-${kebab(publicName)}`
80
+ : animation.keyframeName;
81
+ Object.assign(base, keyframesObject(animation.keyframes, keyframeName));
82
+ utilities[`${baseSelector}.${config.prefix}-${kebab(publicName)}`] = declarationObject(
83
+ animation.declarations,
84
+ keyframeName
85
+ );
86
+ });
87
+
88
+ if (config.respectReducedMotion) {
89
+ base['@media (prefers-reduced-motion: reduce)'] = {
90
+ [baseSelector]: {
91
+ 'animation-duration': '1ms !important',
92
+ 'animation-iteration-count': '1 !important',
93
+ 'transition-duration': '1ms !important'
94
+ }
95
+ };
96
+ }
97
+
98
+ return { base, utilities };
99
+ }
100
+
101
+ module.exports = { buildStyles, kebab, selectAnimations };