Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat: column now uses var(--gs-column-width) #3013

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ module.exports = function(grunt) {
dist: {
files: {
'dist/gridstack.css': 'src/gridstack.scss',
'dist/gridstack-extra.css': 'src/gridstack-extra.scss'
}
}
},
Expand All @@ -33,7 +32,6 @@ module.exports = function(grunt) {
},
files: {
'dist/gridstack.min.css': ['dist/gridstack.css'],
'dist/gridstack-extra.min.css': ['dist/gridstack-extra.css']
}
}
},
Expand All @@ -42,7 +40,6 @@ module.exports = function(grunt) {
files: {
'dist/es5/gridstack-poly.js': ['src/gridstack-poly.js'],
'dist/src/gridstack.scss': ['src/gridstack.scss'],
'dist/src/gridstack-extra.scss': ['src/gridstack-extra.scss'],
'dist/angular/README.md': ['angular/README.md'],
'dist/angular/src/gridstack.component.ts': ['angular/projects/lib/src/lib/gridstack.component.ts'],
'dist/angular/src/gridstack-item.component.ts': ['angular/projects/lib/src/lib/gridstack-item.component.ts'],
Expand Down
17 changes: 15 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Join us on Slack: [https://gridstackjs.slack.com](https://join.slack.com/t/grids
- [Extend Library](#extend-library)
- [Extend Engine](#extend-engine)
- [Change grid columns](#change-grid-columns)
- [Custom columns CSS](#custom-columns-css)
- [Custom columns CSS (OLD, not needed with v12+)](#custom-columns-css-old-not-needed-with-v12)
- [Override resizable/draggable options](#override-resizabledraggable-options)
- [Touch devices support](#touch-devices-support)
- [Migrating](#migrating)
Expand All @@ -48,6 +48,7 @@ Join us on Slack: [https://gridstackjs.slack.com](https://join.slack.com/t/grids
- [Migrating to v9](#migrating-to-v9)
- [Migrating to v10](#migrating-to-v10)
- [Migrating to v11](#migrating-to-v11)
- [Migrating to v12](#migrating-to-v12)
- [jQuery Application](#jquery-application)
- [Changes](#changes)
- [Usage Trend](#usage-trend)
Expand Down Expand Up @@ -207,6 +208,8 @@ GridStack makes it very easy if you need [1-12] columns out of the box (default
GridStack.init( {column: N} );
```

NOTE: step 2 is OLD and not needed with v12+ which uses CSS variables instead of classes

2) also include `gridstack-extra.css` if **N < 12** (else custom CSS - see next). Without these, things will not render/work correctly.
```html
<link href="node_modules/gridstack/dist/gridstack.min.css" rel="stylesheet"/>
Expand All @@ -219,7 +222,9 @@ Note: class `.grid-stack-N` will automatically be added and we include `gridstac

See example: [2 grids demo](http://gridstack.github.io/gridstack.js/demo/two.html) with 6 columns

## Custom columns CSS
## Custom columns CSS (OLD, not needed with v12+)

NOTE: step is OLD and not needed with v12+ which uses CSS variables instead of classes

If you need > 12 columns or want to generate the CSS manually you will need to generate CSS rules for `.grid-stack-item[gs-w="X"]` and `.grid-stack-item[gs-x="X"]`.

Expand Down Expand Up @@ -491,6 +496,14 @@ GridStack.renderCB = function(el: HTMLElement, w: GridStackNode) {
4. if no `GridStackWidget` is defined, the helper will now be inserted as is, and NOT original sidepanel item.
5. support DOM gs- attr as well as gridstacknode JSON (see two.html) alternatives.

## Migrating to v12

* column and cell height code has been re-writen to use browser CSS variables, and we no longer need a tons of custom CSS classes!
this fixes a long standing issue where people forget to include the right CSS for non 12 columns layouts, and a big speedup in many cases (many columns, or small cellHeight values).

**Breaking change:**
* `gridstack-extra.min.css` no longer exist, nor is custom column CSS needed. API/options hasn't changed.

# jQuery Application

This is **old and no longer apply to v6+**. You'll need to use v5.1.1 and before
Expand Down
1 change: 0 additions & 1 deletion angular/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ MyComponent CSS

```css
@import "gridstack/dist/gridstack.min.css";
@import "gridstack/dist/gridstack-extra.min.css"; // if you use 2-11 column

.grid-stack {
background: #fafad2;
Expand Down
2 changes: 0 additions & 2 deletions angular/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
],
"styles": [
"node_modules/gridstack/dist/gridstack.min.css",
"node_modules/gridstack/dist/gridstack-extra.min.css",
"projects/demo/src/styles.css"
],
"scripts": []
Expand Down Expand Up @@ -121,7 +120,6 @@
],
"styles": [
"node_modules/gridstack/dist/gridstack.min.css",
"node_modules/gridstack/dist/gridstack-extra.min.css",
"projects/demo/src/styles.css"
],
"scripts": []
Expand Down
2 changes: 1 addition & 1 deletion angular/projects/demo/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export class AppComponent implements OnInit {
// nested grid options
private subOptions: GridStackOptions = {
cellHeight: 50, // should be 50 - top/bottom
column: 'auto', // size to match container. make sure to include gridstack-extra.min.css
column: 'auto', // size to match container
acceptWidgets: true, // will accept .grid-stack-item by default
margin: 5,
};
Expand Down
1 change: 0 additions & 1 deletion demo/column.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
<title>Column grid demo</title>

<link rel="stylesheet" href="demo.css"/>
<link rel="stylesheet" href="../dist/gridstack-extra.css"/>
<script src="../dist/gridstack-all.js"></script>
</head>
<body>
Expand Down
1 change: 0 additions & 1 deletion demo/mobile.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
<title>Simple mobile demo</title>

<link rel="stylesheet" href="demo.css"/>
<link rel="stylesheet" href="../dist/gridstack-extra.css"/>
<script src="../dist/gridstack-all.js"></script>

</head>
Expand Down
1 change: 0 additions & 1 deletion demo/nested.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Nested grids demo</title>
<link rel="stylesheet" href="demo.css"/>
<link rel="stylesheet" href="../dist/gridstack-extra.min.css"/>
<script src="../dist/gridstack-all.js"></script>
</head>
<body>
Expand Down
4 changes: 1 addition & 3 deletions demo/nested_advanced.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Advance Nested grids demo</title>
<link rel="stylesheet" href="demo.css"/>
<link rel="stylesheet" href="../dist/gridstack-extra.min.css"/> <!-- required for [2-11] column of sub-grids -->
<!-- test using CSS rather than minRow -->
<style type="text/css">
.container-fluid > .grid-stack { min-height: 250px}
Expand All @@ -19,7 +18,6 @@ <h1>Advanced Nested grids demo</h1>
<p>Create sub-grids (darker background) on the fly, by dragging items completely over others (nest) vs partially (push) using
the new v7 API <code>GridStackOptions.subGridDynamic=true</code></p>
<p>This will use the new delay drag&drop option <code>DDDragOpt.pause</code> to tell the gesture difference</p>
<p>Note: <code>gridstack-extra.min.css</code> is required for [2-11] column of sub-grids</p>
<a class="btn btn-primary" onClick="addMainWidget()" href="#">Add Widget</a>
<a class="btn btn-primary" onClick="addNewWidget(0)" href="#">Add W Grid0</a>
<a class="btn btn-primary" onClick="addNewWidget(1)" href="#">Add W Grid1</a>
Expand All @@ -41,7 +39,7 @@ <h1>Advanced Nested grids demo</h1>
<script type="text/javascript">
let subOptions = {
cellHeight: 50, // should be 50 - top/bottom
column: 'auto', // size to match container. make sure to include gridstack-extra.min.css
column: 'auto', // size to match container
acceptWidgets: true, // will accept .grid-stack-item by default
margin: 5,
subGridDynamic: true, // make it recursive for all future sub-grids
Expand Down
3 changes: 1 addition & 2 deletions demo/nested_constraint.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Constraint nested grids demo</title>
<link rel="stylesheet" href="demo.css"/>
<link rel="stylesheet" href="../dist/gridstack-extra.min.css"/>
<script src="../dist/gridstack-all.js"></script>
<style type="text/css">
.grid-stack-item.sub .grid-stack-item-content {
Expand Down Expand Up @@ -41,7 +40,7 @@ <h1>Constraint Nested grids demo</h1>
[...sub1, ...sub2].forEach(d => d.content = String(count++));
let subOptions = {
cellHeight: 50,
column: 'auto', // size to match container. make sure to include gridstack-extra.min.css
column: 'auto', // size to match container
itemClass: 'sub', // style sub items differently and use to prevent dragging in/out
acceptWidgets: '.grid-stack-item.sub', // only pink sub items can be inserted
margin: 2,
Expand Down
3 changes: 1 addition & 2 deletions demo/old_nested-jq.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Nested JQuery grids demo (old v5.1.1) which never worked fully</title>
<link rel="stylesheet" href="demo.css"/>
<link rel="stylesheet" href="../dist/gridstack-extra.min.css"/>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/gridstack-jq.js"></script>
<style type="text/css">
/* make nested grids have slightly darker bg */
Expand Down Expand Up @@ -57,7 +56,7 @@ <h1>Nested JQuery grids demo</h1>
[...sub1, ...sub2].forEach(d => d.content = String(count++));
let subOptions = {
cellHeight: 50, // should be 50 - top/bottom
column: 'auto', // size to match container. make sure to include gridstack-extra.min.css
column: 'auto', // size to match container
acceptWidgets: true, // will accept .grid-stack-item by default
margin: 5,
draggable: {
Expand Down
1 change: 0 additions & 1 deletion demo/old_two-jq.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<link rel="stylesheet" href="demo.css"/>
<link rel="stylesheet" href="../dist/gridstack-extra.css"/>

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/gridstack-jq.js"></script>
</head>
Expand Down
1 change: 0 additions & 1 deletion demo/react-hooks-controlled-multiple.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Gridstack.js React integration example</title>
<link rel="stylesheet" href="demo.css" />
<link rel="stylesheet" href="../dist/gridstack-extra.css"/>
<script src="../dist/gridstack-all.js"></script>

<!-- Scripts to use react inside html - DEVELOPMENT FILES -->
Expand Down
1 change: 0 additions & 1 deletion demo/responsive.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
<title>Responsive column</title>

<link rel="stylesheet" href="demo.css"/>
<link rel="stylesheet" href="../dist/gridstack-extra.css"/>
<script src="../dist/gridstack-all.js"></script>
</head>
<body>
Expand Down
1 change: 0 additions & 1 deletion demo/responsive_break.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
<title>Responsive breakpoint</title>

<link rel="stylesheet" href="demo.css"/>
<link rel="stylesheet" href="../dist/gridstack-extra.css"/>
<script src="../dist/gridstack-all.js"></script>
</head>
<body>
Expand Down
1 change: 0 additions & 1 deletion demo/responsive_none.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
<title>Responsive layout:'none'</title>

<link rel="stylesheet" href="demo.css"/>
<link rel="stylesheet" href="../dist/gridstack-extra.css"/>
<script src="../dist/gridstack-all.js"></script>

</head>
Expand Down
1 change: 0 additions & 1 deletion demo/sizeToContent.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
<title>sizeToContent demo</title>

<link rel="stylesheet" href="demo.css"/>
<link rel="stylesheet" href="../dist/gridstack-extra.css"/>
<script src="../dist/gridstack-all.js"></script>
<style type="text/css">
.grid-stack-item-content {
Expand Down
1 change: 0 additions & 1 deletion demo/two.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<link rel="stylesheet" href="demo.css"/>
<link rel="stylesheet" href="../dist/gridstack-extra.css"/>
<style type="text/css">
.with-lines { border: 1px dotted #777}
</style>
Expand Down
5 changes: 3 additions & 2 deletions doc/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Change log
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
**Table of Contents** *generated with [DocToc](http://doctoc.herokuapp.com/)*

- [11.5.0-dev (TBD)](#1150-dev-tbd)
- [12-dev (TBD)](#12-dev-tbd)
- [11.5.1 (2025-03-23)](#1151-2025-03-23)
- [11.5.0 (2025-03-16)](#1150-2025-03-16)
- [11.4.0 (2025-02-27)](#1140-2025-02-27)
Expand Down Expand Up @@ -123,8 +123,9 @@ Change log
- [v0.1.0 (2014-11-18)](#v010-2014-11-18)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->
## 11.5.0-dev (TBD)
## 12-dev (TBD)
* feat: [#2854](https://github.com/gridstack/gridstack.js/pull/2854) Removed dynamic stylesheet and migrated to CSS vars. Thank you [lmartorella](https://github.com/lmartorella)
* feat: [#3013](https://github.com/gridstack/gridstack.js/pull/3013) columns no longer require custom classes nor `gridstack-extra.css` as we now use CSS vars.

## 11.5.1 (2025-03-23)
* revert: [#2981](https://github.com/gridstack/gridstack.js/issues/2981) Locked was incorrectly changed. fixed doc instead
Expand Down
2 changes: 0 additions & 2 deletions doc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -405,8 +405,6 @@ Gets current cell width (grid width / # of columns).

set the number of columns in the grid. Will update existing widgets to conform to new number of columns,
as well as cache the original layout so you can revert back to previous positions without loss.
Requires `gridstack-extra.css` (or minimized version) for [2-11],
else you will need to generate correct CSS (see https://github.com/gridstack/gridstack.js#change-grid-columns)

- `column` - Integer > 0 (default 12)
- `layout` - specify the type of re-layout that will happen (position, size, etc...). Values are: `'list' | 'compact' | 'moveScale' | 'move' | 'scale' | 'none' | ((column: number, oldColumn: number, nodes: GridStackNode[], oldNodes: GridStackNode[]) => void);`
Expand Down
1 change: 0 additions & 1 deletion react/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import {
GridStackRenderProvider,
} from "path/to/lib";
import "gridstack/dist/gridstack.css";
import "gridstack/dist/gridstack-extra.css";
import "path/to/demo.css";

function Text({ content }: { content: string }) {
Expand Down
1 change: 0 additions & 1 deletion react/src/demo/demo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
useGridStackContext,
} from "../../lib";

import "gridstack/dist/gridstack-extra.css";
import "gridstack/dist/gridstack.css";
import "./demo.css";

Expand Down
1 change: 0 additions & 1 deletion react/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'

import 'gridstack/dist/gridstack-extra.css';
import 'gridstack/dist/gridstack.css';

import App from './App.tsx'
Expand Down
1 change: 0 additions & 1 deletion spec/e2e/html/1571_drop_onto_full.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<link rel="stylesheet" href="../../../demo/demo.css"/>
<script src="../../../dist/gridstack-all.js"></script>
<link rel="stylesheet" href="../../../dist/gridstack-extra.css"/>

<style type="text/css">
.grid-stack-item-removing {
Expand Down
1 change: 0 additions & 1 deletion spec/e2e/html/1785_column_many_switch.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
<title>Changing Column a lot</title>

<link rel="stylesheet" href="../../../demo/demo.css"/>
<link rel="stylesheet" href="../../../dist/gridstack-extra.min.css"/>
<script src="../../../dist/gridstack-all.js"></script>

</head>
Expand Down
1 change: 0 additions & 1 deletion spec/e2e/html/2384_update_content.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<head>
<title>Nested grid update content</title>
<link rel="stylesheet" href="../../../demo/demo.css"/>
<link rel="stylesheet" href="../../../dist/gridstack-extra.min.css"/>
<style type="text/css">
.grid-stack {
background: lightgoldenrodyellow;
Expand Down
1 change: 0 additions & 1 deletion spec/e2e/html/2394_save_sub_item_moved.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
<title>#2394 Save sub item moved</title>

<link rel="stylesheet" href="../../../demo/demo.css" />
<link rel="stylesheet" href="../../../dist/gridstack-extra.min.css"/>
<script src="../../../dist/gridstack-all.js"></script>

</head>
Expand Down
1 change: 0 additions & 1 deletion spec/e2e/html/2406_inf_loop_autoPosition_column1.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
<title>Float grid demo</title>

<link rel="stylesheet" href="../../../demo/demo.css" />
<link rel="stylesheet" href="../../../dist/gridstack-extra.css" />
<script src="../../../dist/gridstack-all.js"></script>

</head>
Expand Down
1 change: 0 additions & 1 deletion spec/e2e/html/2453 _recreated_trash.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<link rel="stylesheet" href="../../../demo/demo.css" />
<link rel="stylesheet" href="../../../dist/gridstack-extra.css" />
<script src="../../../dist/gridstack-all.js"></script>
<style type="text/css">
.with-lines { border: 1px dotted #777}
Expand Down
1 change: 0 additions & 1 deletion spec/e2e/html/2576_insert_column_shift_content.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
<title>Column insert bug #2576</title>
<link rel="stylesheet" href="../../../demo/demo.css" />
<script src="../../../dist/gridstack-all.js"></script>
<link rel="stylesheet" href="../../../dist/gridstack-extra.css"/>
</head>

<body>
Expand Down
1 change: 0 additions & 1 deletion spec/e2e/html/2864_nested_resize_reflow.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>2864 nest grid resize</title>
<link rel="stylesheet" href="../../../demo/demo.css"/>
<link rel="stylesheet" href="../../../dist/gridstack-extra.css"/>
<script src="../../../dist/gridstack-all.js"></script>
</head>
<body>
Expand Down
Loading