Skip to content

Commit

Permalink
Added test project for Theme Builder
Browse files Browse the repository at this point in the history
  • Loading branch information
BernieSumption committed Apr 23, 2024
1 parent 3e48a62 commit fb41f98
Show file tree
Hide file tree
Showing 13 changed files with 236 additions and 19 deletions.
11 changes: 11 additions & 0 deletions delete-package-lock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env node
const fs = require('fs');
const path = require('path');

const del = (file) => {
if (fs.existsSync(file)) {
fs.rmSync(file);
}
}
del('./package-lock.json');
del(path.join(__dirname, 'package-lock.json'));
9 changes: 5 additions & 4 deletions src/angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
"e2e": "ng e2e",
"postinstall": "node ../../delete-package-lock.js"
},
"dependencies": {
"@angular/animations": "14.0.4",
Expand All @@ -17,9 +18,9 @@
"@angular/platform-browser": "14.0.4",
"@angular/platform-browser-dynamic": "14.0.4",
"@angular/router": "14.0.4",
"ag-grid-angular": "31.2.1",
"ag-grid-community": "31.2.1",
"ag-grid-enterprise": "31.2.1",
"ag-grid-angular": "latest",
"ag-grid-community": "latest",
"ag-grid-enterprise": "latest",
"rxjs": "7.5.1",
"tslib": "^2.3.1",
"zone.js": "0.11.4"
Expand Down
9 changes: 5 additions & 4 deletions src/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"@testing-library/jest-dom": "^5.7.0",
"@testing-library/react": "^10.0.4",
"@testing-library/user-event": "^10.2.4",
"ag-grid-community": "31.2.1",
"ag-grid-enterprise": "31.2.1",
"ag-grid-react": "31.2.1",
"ag-grid-community": "latest",
"ag-grid-enterprise": "latest",
"ag-grid-react": "latest",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-scripts": "3.4.1",
Expand All @@ -16,7 +16,8 @@
"start": "PORT=8080 NODE_OPTIONS=--openssl-legacy-provider react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
"eject": "react-scripts eject",
"postinstall": "node ../../delete-package-lock.js"
},
"eslintConfig": {
"extends": "react-app"
Expand Down
1 change: 1 addition & 0 deletions src/theme-builder/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
styles-compiled.*
9 changes: 9 additions & 0 deletions src/theme-builder/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# ag-Grid Sass Styling API Example

<p>This project demonstrates the Sass styling API using the Sass command line tool to compile Sass to CSS.</p>

## Usage

- Run `npm install && npm start`
- The project should automatically open in your browser. If it does not, look at the console messages to find the URL.
- Open `styles.scss`. There are optional sections that you can try uncommenting to try different features of the API.
14 changes: 14 additions & 0 deletions src/theme-builder/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"private": true,
"scripts": {
"start": "live-server src --mount=/node_modules:node_modules",
"postinstall": "node ../../delete-package-lock.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"ag-grid-community": "latest",
"ag-grid-enterprise": "latest",
"live-server": "^1.2.2"
}
}
15 changes: 15 additions & 0 deletions src/theme-builder/src/ag-grid-theme-builder.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

/*
This project is for testing the exported CSS of the AG Grid Theme Builder.
Export a CSS file from the Theme Builder and replace the content of this file with it.
*/


body::before {
display: block;
font-size: 40px;
max-width: 800px;
margin: 50px;
content: "To test a Theme Builder export, replace the content of the file ag-grid-theme-builder.css with the CSS exported from the Theme Builder";
}
77 changes: 77 additions & 0 deletions src/theme-builder/src/grid.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@

// create cols, one for each letter
var columnDefs = [{
headerName: 'Country',
field: 'country',
enableRowGroup: true,
filter: true,
width: 200,
rowDrag: true
}].concat('ABCDEFG'.split('').map(letter => ({ field: letter })));

columnDefs[0].checkboxSelection = true;

// create 100 rows, and fill with random numbers
var rowData = [];
var countries = ['United Kingdom', 'Ireland', 'United States', 'India', 'Brazil', 'China', 'Russia'];

for (var i = 0; i < 100; i++) {
var item = {};

item.country = countries[i % countries.length];

for (var j = 1; j < columnDefs.length; j++) {
var colDef = columnDefs[j];
item[colDef.field] = Math.floor(Math.random() * 100000);
}

rowData.push(item);
}

var gridOptions = {
// we do not hide the menu icons, so easier to see any style changes that impact the icons
suppressMenuHide: true,

defaultColDef: {
// make all cols more narrow
width: 100,
filter: 'number',
sortable: true,
resizable: true
},
enableCharts: true,
animateRows: true,
// enable these, so they can be demonstrated
enableRangeSelection: true,
rowDragManaged: true,
rowGroupPanelShow: 'always',
pivotPanelShow: 'always',
pivotColumnGroupTotals: 'before',
pivotRowTotals: 'before',
sideBar: {
toolPanels: [
{
id: 'columns',
labelDefault: 'Columns',
labelKey: 'columns',
iconKey: 'columns',
toolPanel: 'agColumnsToolPanel'
},
{
id: 'filters',
labelDefault: 'Filters',
labelKey: 'filters',
iconKey: 'filter',
toolPanel: 'agFiltersToolPanel'
}
],
defaultToolPanel: 'filters'
},

columnDefs: columnDefs,
rowData: rowData,
enableFillHandle: true,
rowSelection: 'multiple'
};

new agGrid.Grid(document.querySelector('#myGrid'), gridOptions);
35 changes: 35 additions & 0 deletions src/theme-builder/src/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="ag-grid-theme-builder.css">
<script>
function setDarkMode(on) {
if (on) {
document.body.classList.add("dark");
document.getElementById("myGrid").className = "ag-theme-custom-dark";
} else {
document.body.classList.remove("dark");
document.getElementById("myGrid").className = "ag-theme-custom";
}
}
</script>
<style>
html,
body {
margin: 0;
padding: 0;
height: 100%;
}

#myGrid {
height: 100%;
}
</style>
</head>
<body>
<div id="myGrid"></div>
<script src="https://unpkg.com/ag-grid-community/dist/ag-grid-community.min.noStyle.js"></script>
<script src="https://unpkg.com/ag-grid-enterprise/dist/ag-grid-enterprise.min.noStyle.js"></script>
<script src="grid.js"></script>
</body>
</html>
50 changes: 50 additions & 0 deletions src/theme-builder/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// config/webpack.dev.js
const HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
mode: 'none',
entry: './grid.js',
devtool: 'eval-cheap-module-source-map',

output: {
filename: 'bundle.js'
},

module: {
rules: [
{
test: /\.ts$/,
loader: 'ts-loader'
},
{
test: /\.html$/,
loader: 'html-loader'
},
{
test: /\.scss$/,
use: [
'style-loader',
{
loader: 'css-loader',
options: {
sourceMap: true
}
},
'resolve-url-loader',
{
loader: 'sass-loader',
options: {
sourceMap: true
}
}
]
},
]
},

plugins: [
new HtmlWebpackPlugin({
template: 'index.html'
})
]
};
7 changes: 4 additions & 3 deletions src/vanilla-webpack/package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{
"private": true,
"scripts": {
"start": "webpack-dev-server --open"
"start": "webpack-dev-server --open",
"postinstall": "node ../../delete-package-lock.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"ag-grid-community": "31.2.1",
"ag-grid-enterprise": "31.2.1",
"ag-grid-community": "latest",
"ag-grid-enterprise": "latest",
"@fortawesome/fontawesome-free": "5.15.4",
"sass": "1.45.2",
"sass-loader": "12.4.0",
Expand Down
9 changes: 5 additions & 4 deletions src/vanilla/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@
"start": "npm run sass:build; npm-run-all --parallel sass:watch serve",
"sass:build": "sass --load-path node_modules src/styles.scss:src/styles-compiled.css",
"sass:watch": "npm run sass:build -- --watch",
"serve": "live-server src --mount=/node_modules:node_modules"
"serve": "live-server src --mount=/node_modules:node_modules",
"postinstall": "node ../../delete-package-lock.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"@fortawesome/fontawesome-free": "^6.1.1",
"ag-grid-community": "31.2.1",
"@ag-grid-community/styles": "31.2.1",
"ag-grid-enterprise": "31.2.1",
"ag-grid-community": "latest",
"@ag-grid-community/styles": "latest",
"ag-grid-enterprise": "latest",
"live-server": "^1.2.2",
"npm-run-all": "^4.1.5",
"sass": "^1.51.0"
Expand Down
9 changes: 5 additions & 4 deletions src/vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
"scripts": {
"start": "vue-cli-service serve --open --port 8080",
"serve": "vue-cli-service serve",
"build": "vue-cli-service build"
"build": "vue-cli-service build",
"postinstall": "node ../../delete-package-lock.js"
},
"dependencies": {
"ag-grid-community": "31.2.1",
"ag-grid-enterprise": "31.2.1",
"ag-grid-vue": "31.2.1",
"ag-grid-community": "latest",
"ag-grid-enterprise": "latest",
"ag-grid-vue": "latest",
"core-js": "3.17.3",
"vue": "2.6.14",
"vue-property-decorator": "^8.4.2"
Expand Down

0 comments on commit fb41f98

Please sign in to comment.