Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
ceee128
#92 init
bennobuilder Jan 3, 2025
8166bed
#92 added github banner
bennobuilder Jan 4, 2025
a399520
#92 wip base setup
bennobuilder Jan 5, 2025
eff97a2
#92 fixed typos
bennobuilder Jan 5, 2025
7acc410
#92 wip interaction mode
bennobuilder Jan 6, 2025
821d8c9
#92 wip
bennobuilder Jan 9, 2025
e3732b8
#92 added range option to getWidgetRegions
bennobuilder Jan 9, 2025
d4c026a
#92 added FAQ section
bennobuilder Jan 9, 2025
12c3af0
#92 fixed typo
bennobuilder Jan 9, 2025
fa0d13b
#92 wip
bennobuilder Jan 9, 2025
ec7c9bd
#92 wip
bennobuilder Jan 10, 2025
bd92292
#92 simple reshuffle animation
bennobuilder Jan 11, 2025
b498c09
#92 fixed typo
bennobuilder Jan 11, 2025
60e336a
#92 added performance preset/example
bennobuilder Jan 11, 2025
6b46149
#92 fixed typos
bennobuilder Jan 11, 2025
8458977
#92 fixed typo
bennobuilder Jan 11, 2025
cb496a1
#92 dirty select
bennobuilder Jan 11, 2025
3b01d9c
#92 fixed use effect deps
bennobuilder Jan 11, 2025
8e2ad70
#92 fixed typo
bennobuilder Jan 12, 2025
51376a6
#92 wip
bennobuilder Jan 12, 2025
fd87839
#92 wip layoutMode Absolute and Grid?
bennobuilder Jan 12, 2025
adc4c59
#92 updated todo
bennobuilder Jan 12, 2025
3a58aec
#92 rearrange grid base setup
bennobuilder Jan 12, 2025
11282cd
#92 started working on grid class..
bennobuilder Jan 12, 2025
f82a58b
#92 wip findRegion in grid class
bennobuilder Jan 13, 2025
5a51af8
#92 added very basic arrange startegy to moveRegion method
bennobuilder Jan 13, 2025
6e28cf6
#92 fixed typos
bennobuilder Jan 13, 2025
aec44d9
#92 moved everything to Grid class (dirty)
bennobuilder Jan 13, 2025
795e3e0
#92 wip flow rules
bennobuilder Jan 13, 2025
30f7739
#92 updated grid.md
bennobuilder Jan 13, 2025
c5a42d4
#92 updated grid.md
bennobuilder Jan 14, 2025
d33a814
#92 wip
bennobuilder Jan 15, 2025
4a07694
#92 wip
bennobuilder Jan 15, 2025
e16708f
#92 fixed cascadeMove and made it somewhat work in a very basic manner
bennobuilder Jan 16, 2025
5c28438
#92 wip
bennobuilder Jan 16, 2025
3411c68
#92 wip
bennobuilder Jan 16, 2025
3a80a63
Merge branch 'develop' into 92-create-basic-widget-grid-library
bennobuilder Jan 17, 2025
a0b6e74
#92 clean install
bennobuilder Jan 17, 2025
ce66633
#92 TWithInit?
bennobuilder Jan 17, 2025
2e948f5
#92 fixed typo
bennobuilder Jan 17, 2025
668caef
#92 fixed typo
bennobuilder Jan 17, 2025
51a532f
#92 fixed areRegionsAdjacent
bennobuilder Jan 17, 2025
68a4877
#92 renamed width and height to cols and rows
bennobuilder Jan 17, 2025
12a1020
#92 fixed typos
bennobuilder Jan 18, 2025
a7220f7
#92 fixed typos
bennobuilder Jan 18, 2025
252c0ca
#92 isRegionOutOfBounds
bennobuilder Jan 18, 2025
c627bbb
#92 wip
bennobuilder Jan 19, 2025
15cf1ac
#92 wip back to functional programming
bennobuilder Jan 19, 2025
b9ea81d
#92 wip
bennobuilder Jan 19, 2025
2dc7d29
#92 wip
bennobuilder Jan 19, 2025
7e69cc4
#92 pushRegions function
bennobuilder Jan 20, 2025
4d90184
#92 wip
bennobuilder Jan 20, 2025
d74a8d1
#92 wip
bennobuilder Jan 20, 2025
9b4d565
#92 removed grid class
bennobuilder Jan 21, 2025
27abe48
#92 move timeout
bennobuilder Jan 21, 2025
759907e
#92 fixed cascadeMove
bennobuilder Jan 21, 2025
d8bbf88
#92 fixed typo
bennobuilder Jan 21, 2025
e4f14ba
#92 updated README
bennobuilder Jan 21, 2025
b8a3569
#92 updated readme
bennobuilder Jan 21, 2025
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
8 changes: 4 additions & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
// File nesting in explorer
"explorer.fileNesting.enabled": true,
"explorer.fileNesting.patterns": {
"*.ts": "${capture}.js, ${capture}.test.ts",
"*.js": "${capture}.js.map, ${capture}.min.js, ${capture}.d.ts, ${capture}.test.js",
"*.jsx": "${capture}.js",
"*.tsx": "${capture}.ts, ${capture}.stories.tsx",
"*.ts": "${capture}.js, ${capture}.test.ts, ${capture}.md",
"*.js": "${capture}.js.map, ${capture}.min.js, ${capture}.d.ts, ${capture}.test.js, ${capture}.md",
"*.jsx": "${capture}.js, ${capture}.md",
"*.tsx": "${capture}.ts, ${capture}.stories.tsx, ${capture}.md",
".npmrc": ".nvmrc, .yarnrc.yml",
".gitignore": ".eslintignore, .prettierignore, .dockerignore",
"README.md": "CONTRIBUTING.md, CODE_OF_CONDUCT.md",
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ A collection of open source libraries maintained by [builder.group](https://buil
| [validatenv](https://github.com/builder-group/community/blob/develop/packages/validatenv) | Type-safe, straightforward, and lightweight library for validating environment variables using existing validation libraries like Zod, Valibot, and Yup. | [`validatenv`](https://www.npmjs.com/package/validatenv) |
| [validation-adapter](https://github.com/builder-group/community/blob/develop/packages/validation-adapter) | Universal validation adapter that integrates various validation libraries like Zod, Valibot, and Yup | [`validation-adapter`](https://www.npmjs.com/package/validation-adapter) |
| [validation-adapters](https://github.com/builder-group/community/blob/develop/packages/validation-adapters) | Pre-made validation adapters for the validation-adapter library, including adapters for Zod and Valibot | [`validation-adapters`](https://www.npmjs.com/package/validation-adapters) |
| [widget-grid](https://github.com/builder-group/community/blob/develop/packages/widget-grid) | Framework agnostic library for creating and manipulating widget grids | [`widget-grid`](https://www.npmjs.com/package/widget-grid) |
| [xml-tokenizer](https://github.com/builder-group/community/blob/develop/packages/xml-tokenizer) | Straightforward and typesafe XML tokenizer that streams tokens through a callback mechanism | [`xml-tokenizer`](https://www.npmjs.com/package/xml-tokenizer) |

### 📚 Examples
Expand Down Expand Up @@ -109,3 +110,9 @@ createState({
We currently use the "wrapper pattern" because it ensures better TypeScript type inference. Each wrapper function modifies the state's type in a specific sequence, which is harder to achieve reliably with a feature array.

We're [actively exploring solutions](https://github.com/builder-group/community/blob/develop/packages/feature-state/src/_experimental) to support both patterns, combining the type safety of the wrapper pattern with the simplicity of declarative APIs. Contributions and ideas are always welcome :)

### Why do feature-based libraries use Objects instead of Classes?

This [Medium post](https://medium.com/@markmiro/thoughts-on-choosing-between-plain-js-objects-and-classes-6422af8aaad5) explains the key differences well.

In short, we use objects because they are more flexible and allow for the kind of extensibility we need. Achieving this level of extensibility with classes isn't feasible for our use case, so using objects was the better choice.
24 changes: 24 additions & 0 deletions examples/widget-grid/react/basic/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
50 changes: 50 additions & 0 deletions examples/widget-grid/react/basic/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# React + TypeScript + Vite

This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.

Currently, two official plugins are available:

- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh

## Expanding the ESLint configuration

If you are developing a production application, we recommend updating the configuration to enable type aware lint rules:

- Configure the top-level `parserOptions` property like this:

```js
export default tseslint.config({
languageOptions: {
// other options...
parserOptions: {
project: ['./tsconfig.node.json', './tsconfig.app.json'],
tsconfigRootDir: import.meta.dirname
}
}
});
```

- Replace `tseslint.configs.recommended` to `tseslint.configs.recommendedTypeChecked` or `tseslint.configs.strictTypeChecked`
- Optionally add `...tseslint.configs.stylisticTypeChecked`
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and update the config:

```js
// eslint.config.js
import react from 'eslint-plugin-react';

export default tseslint.config({
// Set the react version
settings: { react: { version: '18.3' } },
plugins: {
// Add the react plugin
react
},
rules: {
// other rules...
// Enable its recommended rules
...react.configs.recommended.rules,
...react.configs['jsx-runtime'].rules
}
});
```
25 changes: 25 additions & 0 deletions examples/widget-grid/react/basic/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import js from '@eslint/js';
import reactHooks from 'eslint-plugin-react-hooks';
import reactRefresh from 'eslint-plugin-react-refresh';
import globals from 'globals';
import tseslint from 'typescript-eslint';

export default tseslint.config(
{ ignores: ['dist'] },
{
extends: [js.configs.recommended, ...tseslint.configs.recommended],
files: ['**/*.{ts,tsx}'],
languageOptions: {
ecmaVersion: 2020,
globals: globals.browser
},
plugins: {
'react-hooks': reactHooks,
'react-refresh': reactRefresh
},
rules: {
...reactHooks.configs.recommended.rules,
'react-refresh/only-export-components': ['warn', { allowConstantExport: true }]
}
}
);
13 changes: 13 additions & 0 deletions examples/widget-grid/react/basic/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + React + TS</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
32 changes: 32 additions & 0 deletions examples/widget-grid/react/basic/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "basic",
"version": "0.0.0",
"private": true,
"type": "module",
"scripts": {
"build": "tsc -b && vite build",
"dev": "vite",
"lint": "eslint .",
"preview": "vite preview"
},
"dependencies": {
"feature-react": "workspace:*",
"feature-state": "workspace:*",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"widget-grid": "workspace:*"
},
"devDependencies": {
"@eslint/js": "^9.17.0",
"@types/react": "^18.3.18",
"@types/react-dom": "^18.3.5",
"@vitejs/plugin-react": "^4.3.4",
"eslint": "^9.17.0",
"eslint-plugin-react-hooks": "^5.0.0",
"eslint-plugin-react-refresh": "^0.4.16",
"globals": "^15.14.0",
"typescript": "~5.6.2",
"typescript-eslint": "^8.18.2",
"vite": "^6.0.5"
}
}
1 change: 1 addition & 0 deletions examples/widget-grid/react/basic/public/vite.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
63 changes: 63 additions & 0 deletions examples/widget-grid/react/basic/src/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { withGlobalBind } from 'feature-react/state';
import React, { useState } from 'react';
import { WidgetGrid } from './components';
import './index.css';
import { TWidgetGridPresetKey, widgetGridPresets } from './widget-grid';

const App: React.FC = () => {
const [currentWidgetGridPresetKey, setWidgetGridPresetKey] =
useState<TWidgetGridPresetKey>('playground');

const preset = React.useMemo(
() => withGlobalBind('__widgetGrid', widgetGridPresets[currentWidgetGridPresetKey]),
[currentWidgetGridPresetKey]
);

return (
<div style={{ width: '100%', height: '100vh', backgroundColor: 'blue', padding: '48px' }}>
<div style={{ marginBottom: '20px' }}>
<select
value={currentWidgetGridPresetKey}
onChange={(e) => setWidgetGridPresetKey(e.target.value as TWidgetGridPresetKey)}
style={{ marginRight: '10px' }}
>
<option value="playground">Playground</option>
<option value="performance">Performance Test</option>
</select>

{preset.actions.map((action, index) => (
<button
key={index}
onClick={() => action.action(preset.grid as any)}

Check failure on line 31 in examples/widget-grid/react/basic/src/App.tsx

View workflow job for this annotation

GitHub Actions / 🧪 Lint and Build (ubuntu-latest, lts/*, latest)

Unexpected any. Specify a different type
style={{ marginRight: '10px' }}
>
{action.label}
</button>
))}
</div>

<WidgetGrid
widgetGrid={preset.grid as any}

Check failure on line 40 in examples/widget-grid/react/basic/src/App.tsx

View workflow job for this annotation

GitHub Actions / 🧪 Lint and Build (ubuntu-latest, lts/*, latest)

Unexpected any. Specify a different type
renderItem={(item) => {
return (
<div
style={{
backgroundColor: 'red',
width: '100%',
height: '100%',
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
border: '1px solid black'
}}
>
{item.id}
</div>
);
}}
/>
</div>
);
};

export default App;
Loading
Loading