Skip to content

Commit

Permalink
Merge branch 'titoBouzout-16'
Browse files Browse the repository at this point in the history
  • Loading branch information
krausest committed Oct 24, 2024
2 parents 1243b79 + 97a86ed commit 9631d73
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 28 deletions.
5 changes: 4 additions & 1 deletion frameworks/keyed/pota/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
<head>
<meta charset="utf-8" />
<title>Pota</title>
<link href="/css/currentStyle.css" rel="stylesheet" />
<link
href="/css/currentStyle.css"
rel="stylesheet"
/>
</head>
<body>
<div id="main"></div>
Expand Down
19 changes: 17 additions & 2 deletions frameworks/keyed/pota/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "js-framework-benchmark-pota",
"version": "1.0.4",
"version": "1.0.5",
"type": "module",
"main": "dist/main.js",
"js-framework-benchmark": {
Expand All @@ -20,13 +20,28 @@
"url": "https://github.com/krausest/js-framework-benchmark.git"
},
"dependencies": {
"pota": "^0.14.132"
"pota": "^0.16.156"
},
"devDependencies": {
"@babel/core": "7.25.2",
"@rollup/plugin-babel": "6.0.4",
"@rollup/plugin-node-resolve": "15.2.3",
"@rollup/plugin-terser": "0.4.4",
"rollup": "4.21.2"
},
"prettier": {
"printWidth": 70,
"useTabs": true,
"semi": false,
"singleQuote": true,
"quoteProps": "as-needed",
"jsxSingleQuote": false,
"trailingComma": "all",
"bracketSpacing": true,
"bracketSameLine": false,
"arrowParens": "avoid",
"proseWrap": "never",
"endOfLine": "lf",
"singleAttributePerLine": true
}
}
20 changes: 10 additions & 10 deletions frameworks/keyed/pota/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
import { babel } from "@rollup/plugin-babel";
import { nodeResolve } from "@rollup/plugin-node-resolve";
import terser from "@rollup/plugin-terser";
import { babel } from '@rollup/plugin-babel'
import { nodeResolve } from '@rollup/plugin-node-resolve'
import terser from '@rollup/plugin-terser'

const isProduction = process.env.BUILD === "production";
const isProduction = process.env.BUILD === 'production'

/** @type {import('rollup').RollupOptions} */
export default {
input: "./src/main.jsx",
input: './src/main.jsx',
plugins: [
nodeResolve(),
babel({
babelHelpers: "bundled",
presets: [["pota/babel-preset"]],
babelHelpers: 'bundled',
presets: [['pota/babel-preset']],
}),
isProduction && terser(),
],
output: [
{
format: "es",
format: 'es',
sourcemap: false,
file: "./dist/main.js",
file: './dist/main.js',
},
],
};
}
34 changes: 19 additions & 15 deletions frameworks/keyed/pota/src/main.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { render, signal, batch } from 'pota'
import { render, signal } from 'pota'
import { For } from 'pota/web'

import { useSelector } from 'pota/plugin/useSelector'
Expand Down Expand Up @@ -68,9 +68,7 @@ function buildData(count) {
let data = new Array(count)
for (let i = 0; i < count; i++) {
const [label, setLabel, updateLabel] = signal(
`${adjectives[_random(adjectives.length)]} ${
colours[_random(colours.length)]
} ${nouns[_random(nouns.length)]}`,
`${adjectives[_random(adjectives.length)]} ${colours[_random(colours.length)]} ${nouns[_random(nouns.length)]}`,
)
data[i] = {
id: idCounter++,
Expand All @@ -97,16 +95,19 @@ const Button = ({ id, text, fn }) => (
const App = () => {
const [data, setData, updateData] = signal([]),
[selected, setSelected] = signal(null),
run = () => setData(buildData(1000)),
run = () => {
setData(buildData(1000))
},
runLots = () => {
setData(buildData(10000))
},
add = () => updateData(d => [...d, ...buildData(1000)]),
update = () =>
batch(() => {
for (let i = 0, d = data(), len = d.length; i < len; i += 10)
d[i].updateLabel(l => l + ' !!!')
}),
add = () => {
updateData(d => [...d, ...buildData(1000)])
},
update = () => {
for (let i = 0, d = data(), len = d.length; i < len; i += 10)
d[i].updateLabel(l => l + ' !!!')
},
swapRows = () => {
const d = data().slice()
if (d.length > 998) {
Expand All @@ -116,13 +117,16 @@ const App = () => {
setData(d)
}
},
clear = () => setData([]),
remove = id =>
clear = () => {
setData([])
},
remove = id => {
updateData(d => {
const idx = d.findIndex(datum => datum.id === id)
d.splice(idx, 1)
return [...d]
}),
})
},
isSelected = useSelector(selected)

return (
Expand Down Expand Up @@ -186,7 +190,7 @@ const App = () => {
const { id, label } = row

return (
<tr class:danger={isSelected(id)}>
<tr class={{ danger: isSelected(id) }}>
<td
class="col-md-1"
textContent={id}
Expand Down

0 comments on commit 9631d73

Please sign in to comment.