Skip to content
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

Feat/ag grid #2973

Merged
merged 22 commits into from
Feb 17, 2023
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
3e34d25
fix: path to the ag-grid mixins
rustem-nasyrov Jan 27, 2023
5a94022
refactor: move to the styles to the styles folder; remove index.js
rustem-nasyrov Jan 27, 2023
ffa4436
feat: use vite and rollup to build styles
rustem-nasyrov Jan 27, 2023
8fa55e4
feat: install latest ag-grid package
rustem-nasyrov Jan 30, 2023
1e6795c
fix: replace deprecated sass function with css variables
rustem-nasyrov Jan 30, 2023
d3d2718
feat: partially migrate to the new api
rustem-nasyrov Jan 31, 2023
a495356
fix: remove redundant colors, fix striped modifier
rustem-nasyrov Feb 7, 2023
7b65c43
Merge branch 'develop' into feat/ag-grid
rustem-nasyrov Feb 7, 2023
7f5bb83
Merge branch 'develop' into feat/ag-grid
rustem-nasyrov Feb 8, 2023
5e78639
feat: add hoverable colors; refactor: remove comments
rustem-nasyrov Feb 8, 2023
7d71d94
fix: restored header height and fixed font-size
rustem-nasyrov Feb 8, 2023
25aff07
feat: add SCSS variables, refactor to the new variables
rustem-nasyrov Feb 13, 2023
4dd5d8a
feat: migrate from vite to the rollup
rustem-nasyrov Feb 13, 2023
c8b51c1
feat: add demo examples
rustem-nasyrov Feb 14, 2023
108f51a
refactor: remove old scss
rustem-nasyrov Feb 14, 2023
eddb019
feat: update docs examples
rustem-nasyrov Feb 15, 2023
2492ba4
Merge branch 'develop' into feat/ag-grid
rustem-nasyrov Feb 15, 2023
fe967c7
Merge branch 'develop' into pr/rustem-nasyrov/2973
m0ksem Feb 16, 2023
6fa3168
fix: ag-grid docs
m0ksem Feb 16, 2023
bbc0b3a
feat(ag-grid-theme): improve exports in package.json
m0ksem Feb 16, 2023
077699c
feat: add stylesheets import example update translations
rustem-nasyrov Feb 17, 2023
efcf7d8
Merge branch 'develop' into feat/ag-grid
rustem-nasyrov Feb 17, 2023
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
2 changes: 2 additions & 0 deletions packages/ag-grid-theme/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
demo.html
rollup.config.js
170 changes: 170 additions & 0 deletions packages/ag-grid-theme/demo.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>@vuestic/ag-grid-theme</title>
<!-- Include the JS for AG Grid -->
<script src="https://cdn.jsdelivr.net/npm/ag-grid-community/dist/ag-grid-community.min.noStyle.js"></script>
<link rel="stylesheet" href="dist/ag-theme-vuestic.css">
<style>
details {
border: 1px solid;
padding: 0.5rem;
margin-bottom: 1rem;
}

details summary,
details label {
font-family: sans-serif;
}

details form {
margin-left: 0.5rem;
}
</style>
</head>
<body>
<details>
<summary>Filters</summary>
<form id="filtersForm">
<label><input type="checkbox" name="filter" id="filter" value="filter" /> Filterable</label>
<br />
<label><input type="checkbox" name="floatingFilter" id="floatingFilter" value="floatingFilter" /> Floating filters</label>
<br />
<label><input type="checkbox" name="sortable" value="sortable" /> Sortable</label>
</form>
</details>
<details>
<summary>Styles</summary>
<form id="stylesForm">
<label><input type="checkbox" value="striped" name="striped"/> Striped</label>
<br />
<label><input type="checkbox" value="hoverable" name="hoverable"/> Hoverable</label>
</form>
</details>

<!-- Ag grid root div -->
<div id="grid" class="ag-theme-vuestic" style="height: 50vh;"></div>

<script type="text/javascript">
const getColumnDefs = () => [
{ field: 'athlete' },
{ field: 'age' },
{ field: 'country' },
{ field: 'year' },
{ field: 'date' },
{ field: 'sport' },
{ field: 'gold' },
{ field: 'silver' },
{ field: 'bronze' },
{ field: 'total' },
];

// Grid Options are properties passed to the grid
const gridOptions = {
// each entry here represents one column
columnDefs: getColumnDefs(),
// default col def properties get applied to all columns
defaultColDef: {
filter: false,
floatingFilter: false,
sortable: false,
},
// allow rows to be selected
rowSelection: 'multiple',
// have rows animate to new positions when sorted
animateRows: true,
};

// get div to host the grid
const eGridDiv = document.getElementById('grid');
// new grid instance, passing in the hosting DIV and Grid Options
const agGridInstance = new agGrid.Grid(eGridDiv, gridOptions);

const filterCheckboxEl = document.getElementById('filter');
const floatingFilterEl = document.getElementById('floatingFilter');

const onColumnOptionClick = (event) => {
const optionName = event.target.value;
const currentColumnDefs = agGridInstance.gridOptions.columnDefs;
const columnDefs = getColumnDefs();

columnDefs.forEach((columnDef, idx) => {
columnDef[optionName] = typeof currentColumnDefs[idx][optionName] !== 'undefined'
? !currentColumnDefs[idx][optionName]
: true;

if (!columnDef.filter && optionName === 'floatingFilter') {
columnDef.filter = columnDef.floatingFilter;
}

if (!columnDef.floatingFilter && optionName === 'filter') {
columnDef.floatingFilter = columnDef.filter;
}
});

if (optionName === 'floatingFilter') {
filterCheckboxEl.checked = columnDefs[0].floatingFilter;
}

if (optionName === 'filter') {
floatingFilterEl.checked = columnDefs[0].filter;
}

agGridInstance.gridOptions.api.setColumnDefs(columnDefs);
agGridInstance.gridOptions.api.refreshHeader();
}

const onStylesChange = (event) => {
eGridDiv.classList.toggle(`ag-theme-vuestic--${event.target.value}`)
}

const addEvents = (elements, cb, eventName) => {
elements.forEach(element => element.addEventListener(eventName, cb));
}

const removeEvents = (elements, cb, eventName) => {
elements.forEach(element => element.removeEventListener(eventName, cb));
}

window.addEventListener('DOMContentLoaded', () => {
// Filters and misc form
addEvents(
document.querySelectorAll('#filtersForm input[type="checkbox"], #miscForm input[type="checkbox"]'),
onColumnOptionClick,
'change'
);

// Styles form
addEvents(
document.querySelectorAll('#stylesForm input[type="checkbox"]'),
onStylesChange,
'change',
);
});

window.addEventListener('beforeunload', () => {
// Filters form
removeEvents(
document.querySelectorAll('#filtersForm input[type="checkbox"], #miscForm input[type="checkbox"]'),
onColumnOptionClick,
'change',
);

// Styles form
removeEvents(
document.querySelectorAll('#stylesForm input[type="checkbox"]'),
onStylesChange,
'change',
);
});

fetch('https://www.ag-grid.com/example-assets/olympic-winners.json')
.then(response => response.json())
.then(data => {
// load fetched data into grid
gridOptions.api.setRowData(data);
});
</script>
</body>
</html>
9 changes: 0 additions & 9 deletions packages/ag-grid-theme/index.scss

This file was deleted.

25 changes: 19 additions & 6 deletions packages/ag-grid-theme/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,36 @@
"description": "Custom theme with Vuestic UI styles for AG Grid Vue 3.",
"homepage": "https://vuestic.dev",
"repository": "https://github.com/epicmaxco/vuestic-ui",
"main": "src/index.js",
"license": "MIT",
"scripts": {},
"type": "module",
"scripts": {
"build": "rollup --config rollup.config.js --bundleConfigAsCjs"
},
"dependencies": {
"@ag-grid-community/core": "^28.1.1",
"@ag-grid-community/vue3": "^28.1.1",
"@ag-grid-community/client-side-row-model": "^28.1.1"
"@ag-grid-community/client-side-row-model": "^29.0.0",
"@ag-grid-community/core": "^29.0.0",
"@ag-grid-community/styles": "^29.0.0",
"@ag-grid-community/vue3": "^29.0.0"
},
"peerDependencies": {
"vuestic-ui": "^1.3.0"
},
"devDependencies": {
"sass": "^1.57.1",
"rollup": "^3.15.0",
"rollup-plugin-scss": "^4.0.0"
},
"keywords": [
"vuestic",
"ag grid",
"grid",
"theme",
"vue3",
"vue"
]
],
"main": "dist/ag-theme-vuestic.css",
"exports": {
".": "./dist/ag-theme-vuestic.css",
"./scss": "./src/styles/index.scss"
}
}
24 changes: 24 additions & 0 deletions packages/ag-grid-theme/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { resolve } from 'path';
import { existsSync, mkdirSync, writeFileSync } from 'fs'

import scss from 'rollup-plugin-scss'

export default {
input: resolve(__dirname, 'src/styles/index.scss'),
plugins: [
scss({
name: 'ag-theme-vuestic',
fileName: 'ag-theme-vuestic.css',
sass: require('sass'),
failOnError: true,
outputStyle: 'compressed',
output: (styles) => {
if (!existsSync('./dist')) {
mkdirSync('./dist')
}

writeFileSync('./dist/ag-theme-vuestic.css', styles)
}
})
],
}
Loading