Skip to content

Commit 44c3013

Browse files
committed
initial commit
0 parents  commit 44c3013

20 files changed

+9854
-0
lines changed

.editorconfig

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 2
6+
end_of_line = lf
7+
charset = utf-8
8+
trim_trailing_whitespace = true
9+
insert_final_newline = true

.github/FUNDING.yml

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
github: chiribuc

.github/ISSUE_TEMPLATE/config.yml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
blank_issues_enabled: false
2+
contact_links:
3+
- name: Ask a Question and installation issues
4+
url: https://github.com/chiribuc/vue3-stack-grid/discussions/new?category=q-a
5+
about: Ask the community for help
6+
- name: Feature Request
7+
url: https://github.com/chiribuc/vue3-stack-grid/discussions/new?category=ideas
8+
about: Share ideas for new features
9+
- name: Bug Report
10+
url: https://github.com/chiribuc/vue3-stack-grid/issues/new
11+
about: Report a reproducable bug

.github/dependabot.yml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
version: 2
2+
3+
updates:
4+
5+
- package-ecosystem: "github-actions"
6+
directory: "/"
7+
schedule:
8+
interval: "weekly"

.github/workflows/prettier.yml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Prettier
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
format:
9+
runs-on: ubuntu-latest
10+
name: Format Files
11+
steps:
12+
- uses: actions/checkout@v4
13+
- uses: actions/setup-node@v4
14+
with:
15+
node-version: 21
16+
- name: Prettier
17+
run: npx prettier --write **/*.js
18+
env:
19+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
20+
21+
- uses: stefanzweifel/git-auto-commit-action@v5
22+
if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
23+
with:
24+
commit_message: "style: format files"

.github/workflows/publish.yml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Publish
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
- uses: actions/setup-node@v4
13+
with:
14+
node-version: 21
15+
registry-url: https://registry.npmjs.org/
16+
- run: npm install
17+
- run: npm publish --access public
18+
env:
19+
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}

.github/workflows/test.yml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
- uses: actions/setup-node@v4
13+
with:
14+
node-version: 21
15+
- run: npm install
16+
- run: npm test
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: "Update Changelog"
2+
3+
on:
4+
release:
5+
types: [released]
6+
7+
jobs:
8+
update:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v4
14+
with:
15+
ref: main
16+
17+
- name: Update Changelog
18+
uses: stefanzweifel/changelog-updater-action@v1
19+
with:
20+
latest-version: ${{ github.event.release.name }}
21+
release-notes: ${{ github.event.release.body }}
22+
23+
- name: Commit updated CHANGELOG
24+
uses: stefanzweifel/git-auto-commit-action@v5
25+
with:
26+
branch: main
27+
commit_message: Update CHANGELOG
28+
file_pattern: CHANGELOG.md

.gitignore

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Dependencies
2+
/node_modules
3+
4+
# Build results
5+
/dist
6+
/build
7+
8+
# Environment variables
9+
.env
10+
.env.local
11+
.env.*.local
12+
13+
# IDE - Editors
14+
.idea
15+
*.sublime-workspace
16+
.vscode
17+
*.swp
18+
*.swo
19+
20+
# OS - System
21+
.DS_Store
22+
Thumbs.db
23+
24+
# Logs
25+
logs
26+
*.log
27+
npm-debug.log*
28+
yarn-debug.log*
29+
yarn-error.log*
30+
31+
# Temporary files
32+
.tmp
33+
.temp
34+
35+
# Vite
36+
.vite/

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## 1.0.0 - 2024-04-08
2+
3+
- initial release

LICENSE.md

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 Robert-Cristian Chiribuc
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.

README.md

+124
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
# StackGrid for Vue 3
2+
3+
StackGrid is a Vue 3 component designed to make it easy and efficient to create dynamic, responsive grid layouts. It automatically arranges items based on the available container width, ensuring a visually appealing presentation on all devices.
4+
5+
![twitter-card](https://github.com/chiribuc/chiribuc/assets/46414598/2b34aca7-678a-495a-b9c3-40ecf43d81ae)
6+
7+
## Demo
8+
See the [demo](https://vue-stack-grid.crobert.dev/) for a live example of StackGrid in action.
9+
10+
## Features
11+
12+
- **Responsive**: Automatically adjusts to the container's width.
13+
- **Customizable**: Offers props for minimum column width, gutter width, and gutter height.
14+
- **Slot Support**: Utilize slots to customize the content of each grid item.
15+
- **Vue 3 Composition API**: Built with Vue 3's Composition API for better performance and readability.
16+
17+
## Installation
18+
19+
To install StackGrid, use npm or yarn:
20+
21+
```
22+
npm i @crob/vue-stack-grid
23+
```
24+
25+
or
26+
27+
```
28+
yarn add @crob/vue-stack-grid
29+
```
30+
31+
## Usage
32+
33+
Import StackGrid into your component and use it in your template. Provide it with the necessary props like `items`, `columnMinWidth`, `gutterWidth`, and `gutterHeight`. Use the slot `item` to customize how each item in the grid should be displayed.
34+
35+
```vue
36+
<template>
37+
<StackGrid :items="items" :column-min-width="100" :gutter-width="10" :gutter-height="10">
38+
<template #item="{ item }">
39+
<div>{{ item }}</div>
40+
</template>
41+
</StackGrid>
42+
</template>
43+
44+
<script setup>
45+
import StackGrid from '@crob/vue-stack-grid';
46+
const items = [...]; // your items here
47+
</script>
48+
```
49+
50+
## Props
51+
52+
- **items** (required): An array of items to display in the grid.
53+
- **columnMinWidth** (required): The minimum width of each column in pixels.
54+
- **gutterWidth**: The horizontal gap between columns in pixels. Default is `0`.
55+
- **gutterHeight**: The vertical gap between rows in pixels. Default is `0`.
56+
57+
## Events
58+
59+
### `updated:reflow`
60+
61+
The `updated:reflow` event is emitted after the grid layout has been recalculated. This can occur in response to various triggers, such as a window resize or manual invocation of the reflow process. This event provides a way for parent components to react to changes in the grid layout, enabling additional custom behavior or UI updates based on the new layout state.
62+
63+
#### Listening to the Event
64+
65+
To listen to the `updated:reflow` event, attach an event listener to the `<StackGrid>` component in your template. You can then define a method within your component to handle the event.
66+
67+
```vue
68+
<template>
69+
<StackGrid @updated:reflow="handleReflowEvent"></StackGrid>
70+
</template>
71+
72+
<script setup>
73+
import { defineComponent } from 'vue';
74+
import StackGrid from '@crob/vue-stack-grid';
75+
76+
const handleReflowEvent = () => {
77+
console.log('Grid layout was updated.');
78+
// Additional logic to handle the grid update...
79+
};
80+
</script>
81+
```
82+
83+
84+
## Methods
85+
86+
### `reflow`
87+
88+
Triggers a reflow of the grid layout. This can be useful if you've dynamically changed the items or their sizes and need to re-calculate the layout of the grid.
89+
To use this method, you'll need to get a reference to the StackGrid component instance in your parent component. Here's an example of how to do this with Vue 3's Composition API:
90+
91+
```vue
92+
<template>
93+
<StackGrid ref="stackGridRef" :items="items" :columnMinWidth="100" :gutterWidth="10" :gutterHeight="10">
94+
<template #item="{ item }">
95+
<div>{{ item }}</div>
96+
</template>
97+
</StackGrid>
98+
<button @click="reflowGrid">Reflow Grid</button>
99+
</template>
100+
101+
<script setup>
102+
import { ref } from 'vue';
103+
import StackGrid from '@crob/vue-stack-grid';
104+
105+
const stackGridRef = ref();
106+
const items = ref([...]); // Your items here
107+
108+
function reflowGrid() {
109+
if (stackGridRef.value) {
110+
stackGridRef.value.reflow();
111+
}
112+
}
113+
</script>
114+
```
115+
116+
This section demonstrates how to access and call the `reflow` method exposed by the StackGrid component.
117+
118+
## Contributing
119+
120+
Contributions are welcome! If you have an idea or suggestion, please feel free to fork the repository, make your changes, and submit a pull request.
121+
122+
## License
123+
124+
This project is licensed under the MIT License - see the LICENSE file for details.

babel.config.json

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"presets": [
3+
["@babel/preset-env", {
4+
"targets": {
5+
"node": "current"
6+
}
7+
}]
8+
]
9+
}

jest.config.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module.exports = {
2+
testEnvironment: 'jsdom',
3+
moduleFileExtensions: ['js', 'json', 'vue'],
4+
testEnvironmentOptions: {
5+
customExportConditions: ["node", "node-addons"],
6+
},
7+
transform: {
8+
'^.+\\.vue$': '@vue/vue3-jest',
9+
'^.+\\.js$': 'babel-jest'
10+
},
11+
transformIgnorePatterns: ['<rootDir>/node_modules/']
12+
};

0 commit comments

Comments
 (0)