Skip to content

Commit

Permalink
WIP, finalizing features, found bug
Browse files Browse the repository at this point in the history
  • Loading branch information
sinistersnare committed Sep 25, 2023
1 parent 9d41275 commit 58f2cac
Show file tree
Hide file tree
Showing 11 changed files with 137 additions and 17 deletions.
81 changes: 81 additions & 0 deletions examples/blocks/src/magic/all_layout.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{
"sizes": [1],
"detail": {
"main": {
"type": "tab-area",
"widgets": ["PERSPECTIVE_GENERATED_ID_3"],
"currentIndex": 0
}
},
"mode": "globalFilters",
"viewers": {
"PERSPECTIVE_GENERATED_ID_3": {
"plugin": "Datagrid",
"plugin_config": {
"columns": {},
"editable": false,
"scroll_lock": false
},
"settings": true,
"title": "All Cards",
"group_by": [],
"split_by": [],
"columns": [
"name",
"type",
"manaCost",
"colors",
"colors_1",
"colors_2",
"colors_3",
"colorIdentity",
"colorIdentity_0",
"borderColor",
"availability",
"availability_0",
"finishes",
"finishes_0",
"flavorText",
"frameVersion",
"keywords",
"keywords_0",
"keywords_1",
"keywords_2",
"language",
"layout",
"number",
"power",
"printings",
"printings_0",
"printings_1",
"promoTypes",
"promoTypes_0",
"promoTypes_1",
"promoTypes_2",
"rarity",
"securityStamp",
"setCode",
"subtypes",
"subtypes_0",
"supertypes",
"text",
"toughness",
"types",
"types_0",
"types_1",
"types_2",
"convertedManaCost",
"edhrecRank",
"edhrecSaltiness",
"manaValue"
],
"filter": [],
"sort": [],
"expressions": [],
"aggregates": {},
"master": false,
"table": "deck",
"linked": false
}
}
}
19 changes: 11 additions & 8 deletions examples/blocks/src/magic/build.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
/******************************************************************************
*
* Copyright (c) 2021, the `mtg-perspective` Authors.
*
* This file is part of the `mtg-perspective` library, distributed under the terms of
* the Apache License 2.0. The full license can be found in the LICENSE file.
*
*/
// ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
// ┃ ██████ ██████ ██████ █ █ █ █ █ █▄ ▀███ █ ┃
// ┃ ▄▄▄▄▄█ █▄▄▄▄▄ ▄▄▄▄▄█ ▀▀▀▀▀█▀▀▀▀▀ █ ▀▀▀▀▀█ ████████▌▐███ ███▄ ▀█ █ ▀▀▀▀▀ ┃
// ┃ █▀▀▀▀▀ █▀▀▀▀▀ █▀██▀▀ ▄▄▄▄▄ █ ▄▄▄▄▄█ ▄▄▄▄▄█ ████████▌▐███ █████▄ █ ▄▄▄▄▄ ┃
// ┃ █ ██████ █ ▀█▄ █ ██████ █ ███▌▐███ ███████▄ █ ┃
// ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
// ┃ Copyright (c) 2017, the Perspective Authors. ┃
// ┃ ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ ┃
// ┃ This file is part of the Perspective library, distributed under the terms ┃
// ┃ of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). ┃
// ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛

import perspective from "@finos/perspective";

Expand Down
12 changes: 12 additions & 0 deletions examples/blocks/src/magic/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

body {
display: flex;
flex-direction: column;
background-color: #DADADA;
height: 100%;
margin: 0;
}

#header {
padding: 3px;
}
1 change: 1 addition & 0 deletions examples/blocks/src/magic/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<script type="module" src="/node_modules/@finos/perspective-viewer-d3fc/dist/cdn/perspective-viewer-d3fc.js"></script>
<script type="module" src="/node_modules/@finos/perspective/dist/cdn/perspective.js"></script>
<script type="module" src="./index.js"></script>
<link rel="stylesheet" href="./index.css" />
</head>
<body>
<div id="header">
Expand Down
27 changes: 19 additions & 8 deletions examples/blocks/src/magic/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,27 +68,38 @@ async function createMainTable() {
}

window.addEventListener("load", async () => {
// either "deck" or "all".
let main = createMainTable();
let layout = await (await fetch("./layout.json")).json();
let allLayout = await (await fetch("./all_layout.json")).json();
let deckLayout = await (await fetch("./layout.json")).json();
let decks = await (await fetch("./decks.json")).json();
let names = Object.keys(decks);
for (let name of names) {
const opt = document.createElement("option");
opt.value = opt.textContent = name;
window.deck_selector.appendChild(opt);
}

const allCardsOption = document.createElement("option");
allCardsOption.value = allCardsOption.textContent = "all";
window.deck_selector.appendChild(allCardsOption);

window.deck_selector.addEventListener("change", async () => {
// swap the underlying table in the workspace.
window.workspace.tables.set(
"deck",
getDeckTable(window.deck_selector.value, decks)
);
// window.workspace.innerHTML = "";
let which = window.deck_selector.value;
let newTable;
if (which === "all") {
await window.workspace.restore(allLayout);
newTable = DECKS["__mainLibrary"];
} else {
await window.workspace.restore(deckLayout);
newTable = getDeckTable(window.deck_selector.value, decks);
}
window.workspace.tables.set("deck", newTable);
});
main = await main;
DECKS["__mainLibrary"] = main;
window.workspace.tables.set("deck", getDeckTable(names[0], decks));
await window.workspace.restore(layout);
await window.workspace.restore(deckLayout);

await window.workspace.restore(decks[names[0]]);
});
2 changes: 1 addition & 1 deletion examples/blocks/src/magic/layout.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
"split_by": ["colorIdentity_0"],
"columns": ["count"],
"filter": [["types_0", "!=", "Land"]],
"sort": [["name", "desc"]],
"sort": [],
"expressions": [],
"aggregates": {},
"master": false,
Expand Down
Binary file modified examples/blocks/src/magic/preview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/blocks/src/magic/thumbnail.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions examples/blocks/src/nypd/build.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
// ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
// ┃ ██████ ██████ ██████ █ █ █ █ █ █▄ ▀███ █ ┃
// ┃ ▄▄▄▄▄█ █▄▄▄▄▄ ▄▄▄▄▄█ ▀▀▀▀▀█▀▀▀▀▀ █ ▀▀▀▀▀█ ████████▌▐███ ███▄ ▀█ █ ▀▀▀▀▀ ┃
// ┃ █▀▀▀▀▀ █▀▀▀▀▀ █▀██▀▀ ▄▄▄▄▄ █ ▄▄▄▄▄█ ▄▄▄▄▄█ ████████▌▐███ █████▄ █ ▄▄▄▄▄ ┃
// ┃ █ ██████ █ ▀█▄ █ ██████ █ ███▌▐███ ███████▄ █ ┃
// ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
// ┃ Copyright (c) 2017, the Perspective Authors. ┃
// ┃ ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ ┃
// ┃ This file is part of the Perspective library, distributed under the terms ┃
// ┃ of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). ┃
// ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛

// Gets the updated data from the NYCLU and prepare it for Perspective.

import perspective from "@finos/perspective";
Expand Down
Binary file modified examples/blocks/src/nypd/preview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/blocks/src/nypd/thumbnail.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 58f2cac

Please sign in to comment.