-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
2,093 additions
and
208 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
<script lang="ts"> | ||
import { GamezStore } from './store' | ||
import { setContext } from 'svelte'; | ||
import { encodeHashToBase64, type AppAgentClient } from '@holochain/client'; | ||
import { SynStore } from '@holochain-syn/store'; | ||
import type { ProfilesStore } from "@holochain-open-dev/profiles"; | ||
import type { WeClient } from '@lightningrodlabs/we-applet'; | ||
import { SynClient } from '@holochain-syn/core'; | ||
import { getMyDna } from './util'; | ||
import { Board } from './board'; | ||
import '@shoelace-style/shoelace/dist/components/select/select.js'; | ||
import '@shoelace-style/shoelace/dist/components/option/option.js'; | ||
import { cloneDeep } from "lodash"; | ||
export let roleName = "" | ||
export let client : AppAgentClient | ||
export let weClient : WeClient | ||
export let profilesStore : ProfilesStore | ||
export let view | ||
let store: GamezStore = new GamezStore ( | ||
weClient, | ||
profilesStore, | ||
client, | ||
roleName, | ||
); | ||
let synStore: SynStore = store.synStore | ||
setContext('synStore', { | ||
getStore: () => synStore, | ||
}); | ||
setContext('store', { | ||
getStore: () => store, | ||
}); | ||
let inputElement | ||
let gameTypeElement | ||
let disabled = true | ||
$: defsList = store.defsList | ||
</script> | ||
<div class="flex-scrollable-parent"> | ||
<div class="flex-scrollable-container"> | ||
<div class='app'> | ||
|
||
<div class="wrapper" > | ||
|
||
<div class="workspace" style=" display:flex; flex-direction:column;padding:20px;"> | ||
<sl-select | ||
hoist | ||
placeholder="Game Type" | ||
bind:this={gameTypeElement} | ||
on:sl-input={(e)=>disabled = !e.target.value || !inputElement.value} | ||
> | ||
{#if $defsList.status == "complete"} | ||
{#each $defsList.value as def} | ||
<sl-option | ||
value={encodeHashToBase64(def.originalHash)} | ||
> | ||
{def.board.name} | ||
</sl-option> | ||
{/each} | ||
{:else} | ||
loading | ||
{/if} | ||
</sl-select> | ||
<sl-input bind:this={inputElement} | ||
on:sl-input={(e)=>disabled = !e.target.value || !gameTypeElement.value} | ||
placeholder="Game Name" | ||
style="margin-top:5px;" | ||
></sl-input> | ||
<div style="margin-top:10px;display:flex;justify-content:flex-end"> | ||
<sl-button on:click={()=>{ | ||
view.cancel() | ||
}}>Cancel</sl-button> | ||
<sl-button | ||
style="margin-left:10px;" | ||
variant="primary" | ||
disabled={disabled} | ||
on:click={async ()=>{ | ||
try { | ||
const defHashB64 = gameTypeElement.value | ||
const defBoard = Array.from($defsList.value).find(def=>encodeHashToBase64(def.originalHash)==defHashB64) | ||
//const hrlB64 = hrlWithContextToB64(attachToHrlWithContext) | ||
const state = cloneDeep(defBoard.board); | ||
state.name = inputElement.value | ||
const board = await store.boardList.makeBoard(state); | ||
const dnaHash = await getMyDna(roleName, client) | ||
view.resolve({hrl:[dnaHash, board.hash]}) | ||
} catch(e) { | ||
console.log("ERR",e) | ||
view.reject(e) | ||
} | ||
}}>Create</sl-button> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<style> | ||
.app { | ||
margin: 0; | ||
padding-bottom: 10px; | ||
background-size: cover; | ||
display: flex; | ||
flex-direction: column; | ||
min-height: 0; | ||
background-color: #fff; | ||
height: 100vh; | ||
position: relative; | ||
} | ||
:global(:root) { | ||
--resizeable-height: 200px; | ||
--tab-width: 60px; | ||
} | ||
@media (min-width: 640px) { | ||
.app { | ||
max-width: none; | ||
} | ||
} | ||
@-webkit-keyframes spin { | ||
0% { -webkit-transform: rotate(0deg); } | ||
100% { -webkit-transform: rotate(360deg); } | ||
} | ||
@keyframes spin { | ||
0% { transform: rotate(0deg); } | ||
100% { transform: rotate(360deg); } | ||
} | ||
.flex-scrollable-parent { | ||
position: relative; | ||
display: flex; | ||
flex: 1; | ||
} | ||
.flex-scrollable-container { | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
right: 0; | ||
bottom: 0; | ||
} | ||
.wrapper { | ||
position: relative; | ||
z-index: 10; | ||
} | ||
</style> |
Oops, something went wrong.