diff --git a/package-lock.json b/package-lock.json index 2b943ee..6017c96 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,6 +16,7 @@ "date-fns": "^3.6.0", "jwt-decode": "^4.0.0", "react": "^18.2.0", + "react-brackets": "^0.4.7", "react-dom": "^18.2.0", "react-image-picker-editor": "^1.3.3", "react-paginate": "^8.2.0", @@ -2598,6 +2599,11 @@ } } }, + "node_modules/@emotion/stylis": { + "version": "0.8.5", + "resolved": "https://registry.npmjs.org/@emotion/stylis/-/stylis-0.8.5.tgz", + "integrity": "sha512-h6KtPihKFn3T9fuIrwvXXUOwlx3rfUvfZIcP5a6rh8Y7zjE3O06hT5Ss4S/YI1AYhuZ1kjaE/5EaOOI2NqSylQ==" + }, "node_modules/@emotion/unitless": { "version": "0.8.1", "resolved": "https://registry.npmjs.org/@emotion/unitless/-/unitless-0.8.1.tgz", @@ -4180,104 +4186,6 @@ "url": "https://github.com/sponsors/gregberge" } }, - "node_modules/@testing-library/dom": { - "version": "9.3.3", - "resolved": "https://registry.npmjs.org/@testing-library/dom/-/dom-9.3.3.tgz", - "integrity": "sha512-fB0R+fa3AUqbLHWyxXa2kGVtf1Fe1ZZFr0Zp6AIbIAzXb2mKbEXl+PCQNUOaq5lbTab5tfctfXRNsWXxa2f7Aw==", - "peer": true, - "dependencies": { - "@babel/code-frame": "^7.10.4", - "@babel/runtime": "^7.12.5", - "@types/aria-query": "^5.0.1", - "aria-query": "5.1.3", - "chalk": "^4.1.0", - "dom-accessibility-api": "^0.5.9", - "lz-string": "^1.5.0", - "pretty-format": "^27.0.2" - }, - "engines": { - "node": ">=14" - } - }, - "node_modules/@testing-library/dom/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "peer": true, - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/@testing-library/dom/node_modules/aria-query": { - "version": "5.1.3", - "resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.1.3.tgz", - "integrity": "sha512-R5iJ5lkuHybztUfuOAznmboyjWq8O6sqNqtK7CLOqdydi54VNbORp49mb14KbWgG1QD3JFO9hJdZ+y4KutfdOQ==", - "peer": true, - "dependencies": { - "deep-equal": "^2.0.5" - } - }, - "node_modules/@testing-library/dom/node_modules/chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "peer": true, - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, - "node_modules/@testing-library/dom/node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "peer": true, - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/@testing-library/dom/node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "peer": true - }, - "node_modules/@testing-library/dom/node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "peer": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/@testing-library/dom/node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "peer": true, - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/@testing-library/jest-dom": { "version": "5.17.0", "resolved": "https://registry.npmjs.org/@testing-library/jest-dom/-/jest-dom-5.17.0.tgz", @@ -6773,6 +6681,14 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/camelize": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/camelize/-/camelize-1.0.1.tgz", + "integrity": "sha512-dU+Tx2fsypxTgtLoE36npi3UqcjSSMNYfkqgmoEhtZrraP5VWq0K7FkWVTYa8eMPtnU/G2txVsfdCJTn9uzpuQ==", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/caniuse-api": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/caniuse-api/-/caniuse-api-3.0.0.tgz", @@ -7330,6 +7246,14 @@ "postcss": "^8.4" } }, + "node_modules/css-color-keywords": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/css-color-keywords/-/css-color-keywords-1.0.0.tgz", + "integrity": "sha512-FyyrDHZKEjXDpNJYvVsV960FiqQyXc/LlYmsxl2BcdMb2WPx0OGRVgTg55rPSyLSNMqP52R9r8geSp7apN3Ofg==", + "engines": { + "node": ">=4" + } + }, "node_modules/css-declaration-sorter": { "version": "6.4.1", "resolved": "https://registry.npmjs.org/css-declaration-sorter/-/css-declaration-sorter-6.4.1.tgz", @@ -7520,6 +7444,16 @@ "resolved": "https://registry.npmjs.org/css-select-base-adapter/-/css-select-base-adapter-0.1.1.tgz", "integrity": "sha512-jQVeeRG70QI08vSTwf1jHxp74JoZsr2XSgETae8/xC8ovSnL2WF87GTLO86Sbwdt2lK4Umg4HnnwMO4YF3Ce7w==" }, + "node_modules/css-to-react-native": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/css-to-react-native/-/css-to-react-native-3.2.0.tgz", + "integrity": "sha512-e8RKaLXMOFii+02mOlqwjbD00KSEKqblnpO9e++1aXS1fPQOpS1YoqdVHBqPjHNoxeF2mimzVqawm2KCbEdtHQ==", + "dependencies": { + "camelize": "^1.0.0", + "css-color-keywords": "^1.0.0", + "postcss-value-parser": "^4.0.2" + } + }, "node_modules/css-tree": { "version": "1.0.0-alpha.37", "resolved": "https://registry.npmjs.org/css-tree/-/css-tree-1.0.0-alpha.37.tgz", @@ -13919,6 +13853,11 @@ "node": ">=18" } }, + "node_modules/keycode": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/keycode/-/keycode-2.2.1.tgz", + "integrity": "sha512-Rdgz9Hl9Iv4QKi8b0OlCRQEzp4AgVxyCtz5S/+VIHezDmrDhkp2N2TqBWOLz0/gbeREXOOiI9/4b8BY9uw2vFg==" + }, "node_modules/keyv": { "version": "4.5.4", "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz", @@ -16913,6 +16852,103 @@ "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz", "integrity": "sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==" }, + "node_modules/react-brackets": { + "version": "0.4.7", + "resolved": "https://registry.npmjs.org/react-brackets/-/react-brackets-0.4.7.tgz", + "integrity": "sha512-5NynHxC32gEe9vuLQJvD2JEtHXg2gI0R6MWVD+uSYhQCAlEdwlKbFWNdrP5MIt1buyxrs2F/tr1EIW6+eBCocw==", + "dependencies": { + "react-swipeable-views": "^0.13.9", + "styled-components": "^5.1.1" + }, + "engines": { + "node": ">=10" + }, + "peerDependencies": { + "react": "^17.0.0", + "react-swipeable-views": "^0.13.9", + "styled-components": "^5.1.1" + } + }, + "node_modules/react-brackets/node_modules/@babel/runtime": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.0.0.tgz", + "integrity": "sha512-7hGhzlcmg01CvH1EHdSPVXYX1aJ8KCEyz6I9xYIi/asDtzBPMyMhVibhM/K6g/5qnKBwjZtp10bNZIEFTRW1MA==", + "dependencies": { + "regenerator-runtime": "^0.12.0" + } + }, + "node_modules/react-brackets/node_modules/@emotion/unitless": { + "version": "0.7.5", + "resolved": "https://registry.npmjs.org/@emotion/unitless/-/unitless-0.7.5.tgz", + "integrity": "sha512-OWORNpfjMsSSUBVrRBVGECkhWcULOAJz9ZW8uK9qgxD+87M7jHRcvh/A96XXNhXTLmKcoYSQtBEX7lHMO7YRwg==" + }, + "node_modules/react-brackets/node_modules/react-swipeable-views": { + "version": "0.13.9", + "resolved": "https://registry.npmjs.org/react-swipeable-views/-/react-swipeable-views-0.13.9.tgz", + "integrity": "sha512-WXC2FKYvZ9QdJ31v9LjEJEl1bA7E4AcaloTkbW0uU0dYf5uvv4aOpiyxubvOkVl1a5L2UAHmKSif4TmJ9usrSg==", + "dependencies": { + "@babel/runtime": "7.0.0", + "prop-types": "^15.5.4", + "react-swipeable-views-core": "^0.13.7", + "react-swipeable-views-utils": "^0.13.9", + "warning": "^4.0.1" + }, + "engines": { + "node": ">=6.0.0" + }, + "peerDependencies": { + "react": "^15.3.0 || ^16.0.0" + } + }, + "node_modules/react-brackets/node_modules/regenerator-runtime": { + "version": "0.12.1", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.12.1.tgz", + "integrity": "sha512-odxIc1/vDlo4iZcfXqRYFj0vpXFNoGdKMAUieAlFYO6m/nl5e9KR/beGf41z4a1FI+aQgtjhuaSlDxQ0hmkrHg==" + }, + "node_modules/react-brackets/node_modules/styled-components": { + "version": "5.3.11", + "resolved": "https://registry.npmjs.org/styled-components/-/styled-components-5.3.11.tgz", + "integrity": "sha512-uuzIIfnVkagcVHv9nE0VPlHPSCmXIUGKfJ42LNjxCCTDTL5sgnJ8Z7GZBq0EnLYGln77tPpEpExt2+qa+cZqSw==", + "dependencies": { + "@babel/helper-module-imports": "^7.0.0", + "@babel/traverse": "^7.4.5", + "@emotion/is-prop-valid": "^1.1.0", + "@emotion/stylis": "^0.8.4", + "@emotion/unitless": "^0.7.4", + "babel-plugin-styled-components": ">= 1.12.0", + "css-to-react-native": "^3.0.0", + "hoist-non-react-statics": "^3.0.0", + "shallowequal": "^1.1.0", + "supports-color": "^5.5.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/styled-components" + }, + "peerDependencies": { + "react": ">= 16.8.0", + "react-dom": ">= 16.8.0", + "react-is": ">= 16.8.0" + } + }, + "node_modules/react-brackets/node_modules/styled-components/node_modules/babel-plugin-styled-components": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/babel-plugin-styled-components/-/babel-plugin-styled-components-2.1.4.tgz", + "integrity": "sha512-Xgp9g+A/cG47sUyRwwYxGM4bR/jDRg5N6it/8+HxCnbT5XNKSKDT9xm4oag/osgqjC2It/vH0yXsomOG6k558g==", + "dependencies": { + "@babel/helper-annotate-as-pure": "^7.22.5", + "@babel/helper-module-imports": "^7.22.5", + "@babel/plugin-syntax-jsx": "^7.22.5", + "lodash": "^4.17.21", + "picomatch": "^2.3.1" + }, + "peerDependencies": { + "styled-components": ">= 2" + } + }, "node_modules/react-dev-utils": { "version": "12.0.1", "resolved": "https://registry.npmjs.org/react-dev-utils/-/react-dev-utils-12.0.1.tgz", @@ -17242,6 +17278,89 @@ "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0" } }, + "node_modules/react-swipeable-views-core": { + "version": "0.13.7", + "resolved": "https://registry.npmjs.org/react-swipeable-views-core/-/react-swipeable-views-core-0.13.7.tgz", + "integrity": "sha512-ekn9oDYfBt0oqJSGGwLEhKvn+QaqMGTy//9dURTLf+vp7W5j6GvmKryYdnwJCDITaPFI2hujXV4CH9krhvaE5w==", + "dependencies": { + "@babel/runtime": "7.0.0", + "warning": "^4.0.1" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/react-swipeable-views-core/node_modules/@babel/runtime": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.0.0.tgz", + "integrity": "sha512-7hGhzlcmg01CvH1EHdSPVXYX1aJ8KCEyz6I9xYIi/asDtzBPMyMhVibhM/K6g/5qnKBwjZtp10bNZIEFTRW1MA==", + "dependencies": { + "regenerator-runtime": "^0.12.0" + } + }, + "node_modules/react-swipeable-views-core/node_modules/regenerator-runtime": { + "version": "0.12.1", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.12.1.tgz", + "integrity": "sha512-odxIc1/vDlo4iZcfXqRYFj0vpXFNoGdKMAUieAlFYO6m/nl5e9KR/beGf41z4a1FI+aQgtjhuaSlDxQ0hmkrHg==" + }, + "node_modules/react-swipeable-views-utils": { + "version": "0.13.9", + "resolved": "https://registry.npmjs.org/react-swipeable-views-utils/-/react-swipeable-views-utils-0.13.9.tgz", + "integrity": "sha512-QLGxRKrbJCbWz94vkWLzb1Daaa2Y/TZKmsNKQ6WSNrS+chrlfZ3z9tqZ7YUJlW6pRWp3QZdLSY3UE3cN0TXXmw==", + "dependencies": { + "@babel/runtime": "7.0.0", + "keycode": "^2.1.7", + "prop-types": "^15.6.0", + "react-event-listener": "^0.6.0", + "react-swipeable-views-core": "^0.13.7", + "shallow-equal": "^1.2.1" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/react-swipeable-views-utils/node_modules/@babel/runtime": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.0.0.tgz", + "integrity": "sha512-7hGhzlcmg01CvH1EHdSPVXYX1aJ8KCEyz6I9xYIi/asDtzBPMyMhVibhM/K6g/5qnKBwjZtp10bNZIEFTRW1MA==", + "dependencies": { + "regenerator-runtime": "^0.12.0" + } + }, + "node_modules/react-swipeable-views-utils/node_modules/react-event-listener": { + "version": "0.6.6", + "resolved": "https://registry.npmjs.org/react-event-listener/-/react-event-listener-0.6.6.tgz", + "integrity": "sha512-+hCNqfy7o9wvO6UgjqFmBzARJS7qrNoda0VqzvOuioEpoEXKutiKuv92dSz6kP7rYLmyHPyYNLesi5t/aH1gfw==", + "dependencies": { + "@babel/runtime": "^7.2.0", + "prop-types": "^15.6.0", + "warning": "^4.0.1" + }, + "peerDependencies": { + "react": "^16.3.0" + } + }, + "node_modules/react-swipeable-views-utils/node_modules/react-event-listener/node_modules/@babel/runtime": { + "version": "7.24.5", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.24.5.tgz", + "integrity": "sha512-Nms86NXrsaeU9vbBJKni6gXiEXZ4CVpYVzEjDH9Sb8vmZ3UljyA1GSOJl/6LGPO8EHLuSF9H+IxNXHPX8QHJ4g==", + "dependencies": { + "regenerator-runtime": "^0.14.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/react-swipeable-views-utils/node_modules/react-event-listener/node_modules/regenerator-runtime": { + "version": "0.14.1", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.14.1.tgz", + "integrity": "sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw==" + }, + "node_modules/react-swipeable-views-utils/node_modules/regenerator-runtime": { + "version": "0.12.1", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.12.1.tgz", + "integrity": "sha512-odxIc1/vDlo4iZcfXqRYFj0vpXFNoGdKMAUieAlFYO6m/nl5e9KR/beGf41z4a1FI+aQgtjhuaSlDxQ0hmkrHg==" + }, "node_modules/react-transition-group": { "version": "4.4.5", "resolved": "https://registry.npmjs.org/react-transition-group/-/react-transition-group-4.4.5.tgz", @@ -18212,6 +18331,16 @@ "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==" }, + "node_modules/shallow-equal": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/shallow-equal/-/shallow-equal-1.2.1.tgz", + "integrity": "sha512-S4vJDjHHMBaiZuT9NPb616CSmLf618jawtv3sufLl6ivK8WocjAo58cXwbRV1cgqxH0Qbv+iUt6m05eqEa2IRA==" + }, + "node_modules/shallowequal": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/shallowequal/-/shallowequal-1.1.0.tgz", + "integrity": "sha512-y0m1JoUZSlPAjXVtPPW70aZWfIL/dSP7AFkRnniLCrK/8MDKog3TySTBmckD+RObVxH0v4Tox67+F14PdED2oQ==" + }, "node_modules/shebang-command": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", @@ -19822,19 +19951,6 @@ "is-typedarray": "^1.0.0" } }, - "node_modules/typescript": { - "version": "4.9.5", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", - "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==", - "peer": true, - "bin": { - "tsc": "bin/tsc", - "tsserver": "bin/tsserver" - }, - "engines": { - "node": ">=4.2.0" - } - }, "node_modules/unbox-primitive": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.2.tgz", @@ -20144,6 +20260,14 @@ "makeerror": "1.0.12" } }, + "node_modules/warning": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/warning/-/warning-4.0.3.tgz", + "integrity": "sha512-rpJyN222KWIvHJ/F53XSZv0Zl/accqHR8et1kpaMTD/fLCRxtV8iX8czMzY7sVZupTI3zcUTg8eycS2kNF9l6w==", + "dependencies": { + "loose-envify": "^1.0.0" + } + }, "node_modules/watchpack": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-2.4.0.tgz", diff --git a/package.json b/package.json index 224eea4..258d9af 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "date-fns": "^3.6.0", "jwt-decode": "^4.0.0", "react": "^18.2.0", + "react-brackets": "^0.4.7", "react-dom": "^18.2.0", "react-image-picker-editor": "^1.3.3", "react-paginate": "^8.2.0", diff --git a/src/elements/Ladder/Ladder.js b/src/elements/Ladder/Ladder.js new file mode 100644 index 0000000..08400fd --- /dev/null +++ b/src/elements/Ladder/Ladder.js @@ -0,0 +1,206 @@ +import { useEffect, useState, useRef } from "react" +import { Bracket, Seed, SeedItem, SeedTeam} from 'react-brackets'; +import defeatIcon from '../../resources/defeat.png'; +import victoryIcon from '../../resources/glory.png'; +import robotIcon from '../../resources/robot1.svg'; + +import zoomInIcon from '../../resources/zoom-in.svg'; +import zoomOutIcon from '../../resources/zoom-out.svg'; + + +import './Ladder.scss'; + + +const CustomSeed = ({seed, breakpoint, roundIndex, seedIndex}) => { + const getColor = (seed, index) => { + if (seed.Winner === seed.teams[index]?.BotId) { + return 'green'; + } else if (seed.Winner === seed.teams[1 - index]?.BotId) { + return 'red'; + } else { + return 'gray'; + } + } + const getImage = (seed, index) => { + let icon; + if (seed.Winner === seed.teams[index]?.BotId) { + icon = victoryIcon; + } else if (seed.Winner !== seed.teams[index]?.BotId && seed.Winner !== -1) { + icon = defeatIcon; + } else if (seed.Winner === -1 && seed.teams[index].BotId){ + icon = robotIcon; + } else { + return <>; + } + return icon; + } + + return ( + + +
+ {seed.teams.map((team, index) => ( + +
+
+ {team.UserName|| '...'} +
+
+ {getImage(seed, index)} +
+ {team.BotFile || '...'} +
+
+
+
))} +
+
+
+ ); +} + +const buildRounds = function (json) { + let result = json; + let temp = []; + result.sort((a, b) => (a.Position-b.Position)); + const minPosition = result[0].Position; + const maxPosition = result[result.length - 1].Position; + const heapSize = Math.pow(2, Math.ceil(Math.log2(maxPosition))) - 1; + + for (let i = 0; i < minPosition; i++) { + temp.push({ + id: i, + date: new Date().toDateString(), + teams: [{}, {}], + }); + }; + temp = temp.concat(result); + let tail = heapSize - temp.length; + for (let i = 0; i < tail; i++) { + temp.push({ + id: i + maxPosition + 1, + date: new Date().toDateString(), + teams: [{}, {}], + }); + } + result = temp; + + result = result.map(element => { + if (element.PlayersBots) element.teams = element.PlayersBots; + if (!element.Status) element.Status = "NotReadyToPlay"; + if (!element.Winner) element.Winner = -1; + if (!element.PlayedOutDate) element.PlayedOutDate = "0001-01-01T00:00:00"; + if (!element.Position) element.Position = element.matchId; + return element; + }); + + temp = []; + let cursor = -1; + for (let i = result.length - 1; i >= 0 ; i--) { + if (Number.isInteger(Math.log2(i + 2))) { + temp.push([]); + cursor++; + } + temp[cursor].push(result[i]); + } + result = temp; + + result = result.map((round, index) => { + return { + title: 'Round ' + (index + 1), + seeds: round, + }; + }); + + return result; +} + +const roundClassName = function (title, roundIndex) { + return
{title}
; +} + + +export default function Ladder({status}){ + const [rounds, setRounds] = useState([]); + const [zoom, setZoom] = useState(1); + const [origin, setOrigin] = useState({x: 0, y: 0}); + const divRef = useRef(null); + + let mouseDown = false; + let startX, startY, scrollLeft, scrollTop; + + const move = (e) => { + e.preventDefault(); + if(!mouseDown) { return; } + const x = e.pageX - divRef.offsetLeft; + const y = e.pageY - divRef.offsetTop; + const scrollX = x - startX; + const scrollY = y - startY; + divRef.scrollLeft = scrollLeft - scrollX; + divRef.scrollTop = scrollTop - scrollY; + }; + + const stopDrag = (e) => { + mouseDown = false; + } + + const startDrag = (e) => { + mouseDown = true; + startX = e.pageX - divRef.offsetLeft; + startY = e.pageY - divRef.offsetTop; + scrollLeft = divRef.scrollLeft; + scrollTop = divRef.scrollTop; + } + + useEffect(() => { + divRef.current.addEventListener('mousemove', move, false); + divRef.current.addEventListener('mousedown', startDrag, false); + divRef.current.addEventListener('mouseup', stopDrag, false); + divRef.current.addEventListener('mouseleave', stopDrag, false); + },[divRef]); + + useEffect(() => { + setRounds(buildRounds(status)); + }, [status]); + + const changeZoom = (delta) => { + const div = divRef.current; + const rect = div.getBoundingClientRect(); + div.style.top = `${Math.max(rect.top,0)}px`; + div.style.left = `${Math.max(rect.left,0)}px`; + setOrigin({x: rect.width/2, y: rect.height/2 }); + console.log(rect); + console.log(origin); + setZoom(Math.min(Math.max(zoom + delta * 0.1, 0.1), 2)); + } + + return (<> +
+
+
+
+ +
+
+
+
changeZoom(1)}> + zoom-in +
+
changeZoom(-1)}> + zoom-out +
+
+
+ ) +} \ No newline at end of file diff --git a/src/elements/Ladder/Ladder.scss b/src/elements/Ladder/Ladder.scss new file mode 100644 index 0000000..235b341 --- /dev/null +++ b/src/elements/Ladder/Ladder.scss @@ -0,0 +1,94 @@ +.ladder{ + padding: 10px; + background-color: #1a1a1a; + height: 500px; + width: 500px; + display: grid; + grid-template-rows: 1fr min-content; + .ladder-zoom { + overflow: scroll; + transition: all 0s 0.5s; + .ladder-zoom-container { + height: min-content; + width: min-content; + cursor: grab; + + div { + user-select: none; + } + + .ladder-record { + .user-name { + font-size: 25px; + font-weight: bold; + cursor: pointer; + } + + .bot { + display: flex; + flex-direction: row; + overflow-x: hidden; + img { + width: 35px; + aspect-ratio: 1; + border-radius: 5px; + } + .bot-name { + margin: 0 5px; + } + + div { + font-size: 15px; + } + } + } + } + } + + .zoom-btns { + display: flex; + justify-content: right; + gap: 10px; + margin-top: 20px; + + .zoom-btn { + cursor: pointer; + background-color: #515151; + border-radius: 50%; + transition: all 0.3s; + height: 30px; + padding: 2px; + aspect-ratio: 1; + + &:hover { + background-color: #646464; + } + + img { + object-fit: fill; + width: 100%; + height: 100%; + vertical-align: top; + transition: all 0.5s; + + &:hover { + filter: invert(1); + } + } + } + } +} + +.round-title { + position: sticky; +} + +.origin { + position: absolute; + z-index: 1000000; + height: 5px; + width: 5px; + background-color: #FF0000; + border-radius: 50%; +} + diff --git a/src/elements/Ladder/Temp.js b/src/elements/Ladder/Temp.js new file mode 100644 index 0000000..789cd83 --- /dev/null +++ b/src/elements/Ladder/Temp.js @@ -0,0 +1,32 @@ +import { useState } from "react" +import Ladder from "./Ladder"; + +export default function Temp(){ + const games1 = [{ "data": [ { "botId": [ 8, 5 ], "status": "Playing", "winner": -1, "position": 4, "playedOutDate": "0001-01-01T00:00:00" }, { "botId": [ 7, 1 ], "status": "Playing", "winner": -1, "position": 3, "playedOutDate": "0001-01-01T00:00:00" }, { "botId": [ 9, 2 ], "status": "Playing", "winner": -1, "position": 5, "playedOutDate": "0001-01-01T00:00:00" }, { "botId": [ 6 ], "status": "NotReadyToPlay", "winner": -1, "position": 2, "playedOutDate": "0001-01-01T00:00:00" } ]}, + { "data": [ { "botId": [ 8, 5 ], "status": "Played", "winner": 5, "position": 4, "playedOutDate": "2024-05-23T14:30:16.757158" }, { "botId": [ 7, 1 ], "status": "Playing", "winner": -1, "position": 3, "playedOutDate": "0001-01-01T00:00:00" }, { "botId": [ 9, 2 ], "status": "Played", "winner": 2, "position": 5, "playedOutDate": "2024-05-23T14:30:16.538882" }, { "botId": [ 6 ], "status": "NotReadyToPlay", "winner": -1, "position": 2, "playedOutDate": "0001-01-01T00:00:00" } ]}, + { "data": [ { "botId": [ 8, 5 ], "status": "Played", "winner": 5, "position": 4, "playedOutDate": "2024-05-23T14:30:16.757158" }, { "botId": [ 7, 1 ], "status": "Played", "winner": 7, "position": 3, "playedOutDate": "2024-05-23T14:30:17.4027264" }, { "botId": [ 9, 2 ], "status": "Played", "winner": 2, "position": 5, "playedOutDate": "2024-05-23T14:30:16.538882" }, { "botId": [ 6 ], "status": "NotReadyToPlay", "winner": -1, "position": 2, "playedOutDate": "0001-01-01T00:00:00" } ]}, + { "data": [ { "botId": [ 8, 5 ], "status": "Resolve", "winner": 5, "position": 4, "playedOutDate": "2024-05-23T14:30:16.757158" }, { "botId": [ 7, 1 ], "status": "Resolve", "winner": 7, "position": 3, "playedOutDate": "2024-05-23T14:30:17.4027264" }, { "botId": [ 9, 2 ], "status": "Resolve", "winner": 2, "position": 5, "playedOutDate": "2024-05-23T14:30:16.538882" }, { "botId": [ 6, 2 ], "status": "Playing", "winner": -1, "position": 2, "playedOutDate": "0001-01-01T00:00:00" }, { "botId": [ 5, 7 ], "status": "Playing", "winner": -1, "position": 1, "playedOutDate": "0001-01-01T00:00:00" } ]}, + { "data": [ { "botId": [ 8, 5 ], "status": "Resolve", "winner": 5, "position": 4, "playedOutDate": "2024-05-23T14:30:16.757158" }, { "botId": [ 7, 1 ], "status": "Resolve", "winner": 7, "position": 3, "playedOutDate": "2024-05-23T14:30:17.4027264" }, { "botId": [ 9, 2 ], "status": "Resolve", "winner": 2, "position": 5, "playedOutDate": "2024-05-23T14:30:16.538882" }, { "botId": [ 6, 2 ], "status": "Resolve", "winner": 2, "position": 2, "playedOutDate": "2024-05-23T14:30:46.5770369" }, { "botId": [ 5, 7 ], "status": "Resolve", "winner": 7, "position": 1, "playedOutDate": "2024-05-23T14:30:44.3453841" }, { "botId": [ 2, 7 ], "status": "Playing", "winner": -1, "position": 0, "playedOutDate": "0001-01-01T00:00:00" } ]}, + { "data": [ { "botId": [ 8, 5 ], "status": "Resolve", "winner": 5, "position": 4, "playedOutDate": "2024-05-23T14:30:16.757158" }, { "botId": [ 7, 1 ], "status": "Resolve", "winner": 7, "position": 3, "playedOutDate": "2024-05-23T14:30:17.4027264" }, { "botId": [ 9, 2 ], "status": "Resolve", "winner": 2, "position": 5, "playedOutDate": "2024-05-23T14:30:16.538882" }, { "botId": [ 6, 2 ], "status": "Resolve", "winner": 2, "position": 2, "playedOutDate": "2024-05-23T14:30:46.5770369" }, { "botId": [ 5, 7 ], "status": "Resolve", "winner": 7, "position": 1, "playedOutDate": "2024-05-23T14:30:44.3453841" }, { "botId": [ 2, 7 ], "status": "Played", "winner": 7, "position": 0, "playedOutDate": "2024-05-23T14:31:05.9817403" } ]}]; + + const games = [[{"matchId":1,"PlayersBots":[{"BotId":8,"BotFile":"amongus_bot_2","UserName":"emma_jenkins"},{"BotId":5,"BotFile":"fifa22_bot_1","UserName":"sam_wilson"}],"Status":"Playing","Winner":-1,"Position":4,"PlayedOutDate":"0001-01-01T00:00:00","MatchResult":"NotPlayed"},{"matchId":2,"PlayersBots":[{"BotId":7,"BotFile":"amongus_bot_1","UserName":"david_miller"},{"BotId":1,"BotFile":"quake3_bot_1","UserName":"john_doe"}],"Status":"Playing","Winner":-1,"Position":3,"PlayedOutDate":"0001-01-01T00:00:00","MatchResult":"NotPlayed"},{"matchId":3,"PlayersBots":[{"BotId":9,"BotFile":"minecra","UserName":"ryan_clark"},{"BotId":2,"BotFile":"quake3_bot_2","UserName":"jane_smith"}],"Status":"Playing","Winner":-1,"Position":5,"PlayedOutDate":"0001-01-01T00:00:00","MatchResult":"NotPlayed"},{"matchId":4,"PlayersBots":[{"BotId":6,"BotFile":"fifa22_bot_2","UserName":"olivia_brown"}],"Status":"NotReadyToPlay","Winner":-1,"Position":2,"PlayedOutDate":"0001-01-01T00:00:00","MatchResult":"NotPlayed"}], + [{"matchId":1,"PlayersBots":[{"BotId":8,"BotFile":"amongus_bot_2","UserName":"emma_jenkins"},{"BotId":5,"BotFile":"fifa22_bot_1","UserName":"sam_wilson"}],"Status":"Resolve","Winner":5,"Position":4,"PlayedOutDate":"2024-05-29T14:54:46.2801257","MatchResult":"BotFiled"},{"matchId":2,"PlayersBots":[{"BotId":7,"BotFile":"amongus_bot_1","UserName":"david_miller"},{"BotId":1,"BotFile":"quake3_bot_1","UserName":"john_doe"}],"Status":"Resolve","Winner":7,"Position":3,"PlayedOutDate":"2024-05-29T14:54:45.7084368","MatchResult":"Won"},{"matchId":3,"PlayersBots":[{"BotId":9,"BotFile":"minecra","UserName":"ryan_clark"},{"BotId":2,"BotFile":"quake3_bot_2","UserName":"jane_smith"}],"Status":"Resolve","Winner":2,"Position":5,"PlayedOutDate":"2024-05-29T14:54:44.0480468","MatchResult":"Won"},{"matchId":4,"PlayersBots":[{"BotId":2,"BotFile":"quake3_bot_2","UserName":"jane_smith"},{"BotId":6,"BotFile":"fifa22_bot_2","UserName":"olivia_brown"}],"Status":"Playing","Winner":-1,"Position":2,"PlayedOutDate":"0001-01-01T00:00:00","MatchResult":"NotPlayed"},{"matchId":5,"PlayersBots":[{"BotId":5,"BotFile":"fifa22_bot_1","UserName":"sam_wilson"},{"BotId":7,"BotFile":"amongus_bot_1","UserName":"david_miller"}],"Status":"Playing","Winner":-1,"Position":1,"PlayedOutDate":"0001-01-01T00:00:00","MatchResult":"NotPlayed"}], + [{"matchId":1,"PlayersBots":[{"BotId":8,"BotFile":"amongus_bot_2","UserName":"emma_jenkins"},{"BotId":5,"BotFile":"fifa22_bot_1","UserName":"sam_wilson"}],"Status":"Resolve","Winner":5,"Position":4,"PlayedOutDate":"2024-05-29T14:54:46.2801257","MatchResult":"BotFiled"},{"matchId":2,"PlayersBots":[{"BotId":7,"BotFile":"amongus_bot_1","UserName":"david_miller"},{"BotId":1,"BotFile":"quake3_bot_1","UserName":"john_doe"}],"Status":"Resolve","Winner":7,"Position":3,"PlayedOutDate":"2024-05-29T14:54:45.7084368","MatchResult":"Won"},{"matchId":3,"PlayersBots":[{"BotId":9,"BotFile":"minecra","UserName":"ryan_clark"},{"BotId":2,"BotFile":"quake3_bot_2","UserName":"jane_smith"}],"Status":"Resolve","Winner":2,"Position":5,"PlayedOutDate":"2024-05-29T14:54:44.0480468","MatchResult":"Won"},{"matchId":4,"PlayersBots":[{"BotId":6,"BotFile":"fifa22_bot_2","UserName":"olivia_brown"},{"BotId":2,"BotFile":"quake3_bot_2","UserName":"jane_smith"}],"Status":"Resolve","Winner":2,"Position":2,"PlayedOutDate":"2024-05-29T14:54:53.3744008","MatchResult":"Won"},{"matchId":5,"PlayersBots":[{"BotId":5,"BotFile":"fifa22_bot_1","UserName":"sam_wilson"},{"BotId":7,"BotFile":"amongus_bot_1","UserName":"david_miller"}],"Status":"Resolve","Winner":7,"Position":1,"PlayedOutDate":"2024-05-29T14:54:54.6489749","MatchResult":"BotFiled"},{"matchId":6,"PlayersBots":[{"BotId":2,"BotFile":"quake3_bot_2","UserName":"jane_smith"},{"BotId":7,"BotFile":"amongus_bot_1","UserName":"david_miller"}],"Status":"Playing","Winner":-1,"Position":0,"PlayedOutDate":"0001-01-01T00:00:00","MatchResult":"NotPlayed"}], + [{"matchId":1,"PlayersBots":[{"BotId":8,"BotFile":"amongus_bot_2","UserName":"emma_jenkins"},{"BotId":5,"BotFile":"fifa22_bot_1","UserName":"sam_wilson"}],"Status":"Resolve","Winner":5,"Position":4,"PlayedOutDate":"2024-05-29T14:54:46.2801257","MatchResult":"BotFiled"},{"matchId":2,"PlayersBots":[{"BotId":7,"BotFile":"amongus_bot_1","UserName":"david_miller"},{"BotId":1,"BotFile":"quake3_bot_1","UserName":"john_doe"}],"Status":"Resolve","Winner":7,"Position":3,"PlayedOutDate":"2024-05-29T14:54:45.7084368","MatchResult":"Won"},{"matchId":3,"PlayersBots":[{"BotId":9,"BotFile":"minecra","UserName":"ryan_clark"},{"BotId":2,"BotFile":"quake3_bot_2","UserName":"jane_smith"}],"Status":"Resolve","Winner":2,"Position":5,"PlayedOutDate":"2024-05-29T14:54:44.0480468","MatchResult":"Won"},{"matchId":4,"PlayersBots":[{"BotId":6,"BotFile":"fifa22_bot_2","UserName":"olivia_brown"},{"BotId":2,"BotFile":"quake3_bot_2","UserName":"jane_smith"}],"Status":"Resolve","Winner":2,"Position":2,"PlayedOutDate":"2024-05-29T14:54:53.3744008","MatchResult":"Won"},{"matchId":5,"PlayersBots":[{"BotId":5,"BotFile":"fifa22_bot_1","UserName":"sam_wilson"},{"BotId":7,"BotFile":"amongus_bot_1","UserName":"david_miller"}],"Status":"Resolve","Winner":7,"Position":1,"PlayedOutDate":"2024-05-29T14:54:54.6489749","MatchResult":"BotFiled"},{"matchId":6,"PlayersBots":[{"BotId":2,"BotFile":"quake3_bot_2","UserName":"jane_smith"},{"BotId":7,"BotFile":"amongus_bot_1","UserName":"david_miller"}],"Status":"Resolve","Winner":7,"Position":0,"PlayedOutDate":"2024-05-29T14:55:04.4659877","MatchResult":"Won"}]] + + const [index, setIndex] = useState(0); + const [status, setStatus] = useState(games[index]); + + return (<> + + +

{index}/{games.length}

+ + ) +} \ No newline at end of file diff --git a/src/index.js b/src/index.js index 16b9b21..18f6767 100644 --- a/src/index.js +++ b/src/index.js @@ -31,6 +31,8 @@ import { getListOfTournaments } from './Tournaments/getListOfTournaments'; import UserSettings from './User/Settings/UserSettings'; import AnimatedBackground from "./AnimatedBackground"; +import Temp from "./elements/Ladder/Temp"; + const games = [{name:'Szachy', id:1}, {name:'Warcaby', id:2}, {name:'Scrabble', id:3}, {name:'ChiƄczyk', id:4}, {name:'Go', id:5}] const tournaments = getListOfTournaments(); @@ -119,6 +121,10 @@ const router = createBrowserRouter([ path: "/admin/PlayerTournaments", element: , }, + { + path: "/temp", + element: , + } ]); diff --git a/src/index.scss b/src/index.scss index 63bd81a..12bf950 100644 --- a/src/index.scss +++ b/src/index.scss @@ -67,7 +67,6 @@ button { } div { - text-shadow: 1px 1px 0.1cm #fff; font-size: 45px; } @@ -78,3 +77,30 @@ div { z-index: -1; } +::-webkit-scrollbar { + width: 4px; + height: 4px; + visibility: hidden; + + transition: all 0.5s; + &:hover { + visibility: visible; + } +} + +::-webkit-scrollbar-track { + background: #114002; +} + +::-webkit-scrollbar-thumb { + background: #001804; + border-radius: 4px; + transition: all 0.5s; + &:hover { + background: #016d29; + } +} + +::-webkit-scrollbar-corner { + background-color: transparent ; +} \ No newline at end of file diff --git a/src/resources/defeat.png b/src/resources/defeat.png new file mode 100644 index 0000000..2328cbb Binary files /dev/null and b/src/resources/defeat.png differ diff --git a/src/resources/glory.png b/src/resources/glory.png new file mode 100644 index 0000000..84b0727 Binary files /dev/null and b/src/resources/glory.png differ diff --git a/src/resources/robot1.svg b/src/resources/robot1.svg new file mode 100644 index 0000000..66463e4 --- /dev/null +++ b/src/resources/robot1.svg @@ -0,0 +1,60 @@ + + + \ No newline at end of file diff --git a/src/resources/trophy1.svg b/src/resources/trophy1.svg new file mode 100644 index 0000000..390218e --- /dev/null +++ b/src/resources/trophy1.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/resources/zoom-in.svg b/src/resources/zoom-in.svg new file mode 100644 index 0000000..7df76d2 --- /dev/null +++ b/src/resources/zoom-in.svg @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/src/resources/zoom-out.svg b/src/resources/zoom-out.svg new file mode 100644 index 0000000..45c73df --- /dev/null +++ b/src/resources/zoom-out.svg @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file