-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[twisty] Add the
<twizzle-link>
element.
- Loading branch information
Showing
10 changed files
with
134 additions
and
18 deletions.
There are no files selected for viewing
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,28 @@ | ||
import { CSSSource } from "../ManagedCustomElement"; | ||
|
||
export const twizzleLinkCSS = new CSSSource(` | ||
.wrapper { | ||
background: rgb(255, 245, 235); | ||
display: grid; | ||
grid-template-columns: 1fr; | ||
border: 1px solid rgba(0, 0, 0, 0.25); | ||
} | ||
.setup-alg, twisty-alg-viewer { | ||
padding: 0.5em 1em; | ||
} | ||
.heading { | ||
background: rgba(255, 230, 210, 1); | ||
font-weight: bold; | ||
padding: 0.25em 0.5em; | ||
} | ||
twisty-player { | ||
width: 100%; | ||
} | ||
twisty-player + .heading { | ||
padding-top: 0.5em; | ||
} | ||
`); |
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,46 @@ | ||
import { TwistyPlayer } from "../.."; | ||
import { Alg } from "../../../alg"; | ||
import { ManagedCustomElement } from "../ManagedCustomElement"; | ||
import { customElementsShim } from "../node-custom-element-shims"; | ||
import { TwistyAlgViewer } from "../TwistyAlgViewer"; | ||
import { twizzleLinkCSS } from "./TwizzleLink.css"; | ||
import { getConfigFromURL } from "./url-params"; | ||
|
||
export class TwizzleLink extends ManagedCustomElement { | ||
twistyPlayer: TwistyPlayer | null = null; | ||
a: HTMLAnchorElement | null = null; | ||
constructor() { | ||
super({ mode: "open" }); | ||
} | ||
connectedCallback() { | ||
this.addCSS(twizzleLinkCSS); | ||
this.a = this.querySelector("a"); | ||
if (this.a) { | ||
const config = getConfigFromURL("", this.a.href); | ||
this.twistyPlayer = this.addElement(new TwistyPlayer(config)); | ||
|
||
if (config.experimentalSetupAlg) { | ||
this.addHeading("Setup"); | ||
|
||
const setupAlgDiv = this.addElement(document.createElement("div")); | ||
setupAlgDiv.classList.add("setup-alg"); | ||
setupAlgDiv.textContent = new Alg( | ||
config.experimentalSetupAlg, | ||
).toString(); | ||
} | ||
this.addHeading("Moves"); | ||
const twistyAlgViewer = this.addElement( | ||
new TwistyAlgViewer({ twistyPlayer: this.twistyPlayer }), | ||
); | ||
twistyAlgViewer.part.add("twisty-alg-viewer"); | ||
} | ||
} | ||
|
||
addHeading(text: string): void { | ||
const headingDiv = this.addElement(document.createElement("div")); | ||
headingDiv.classList.add("heading"); | ||
headingDiv.textContent = text; | ||
} | ||
} | ||
|
||
customElementsShim.define("twizzle-link", TwizzleLink); |
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 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 @@ | ||
import "../../../../cubing/twisty"; |
31 changes: 31 additions & 0 deletions
31
src/sites/experiments.cubing.net/cubing.js/twisty/twizzle-link.html
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,31 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf8" /> | ||
<title>Twizzle Link | twisty.js</title> | ||
<link href="./inline.css" rel="stylesheet" type="text/css" /> | ||
<script src="./twisty.js" href="./twisty.ts" type="module"></script> | ||
<style> | ||
twizzle-link { | ||
margin: 1em; | ||
font-family: Ubuntu; | ||
} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
<div class="content"> | ||
<twizzle-link> | ||
<a | ||
href="https://alpha.twizzle.net/edit/?alg=R+U+R%27+U%27+R%27+F+R2+U%27+R%27+U%27+R+U+R%27+F%27&stickering=PLL" | ||
>https://alpha.twizzle.net/edit/?alg=R+U+R%27+U%27+R%27+F+R2+U%27+R%27+U%27+R+U+R%27+F%27&stickering=PLL</a | ||
> | ||
</twizzle-link> | ||
<twizzle-link> | ||
<a | ||
href="https://alpha.twizzle.net/edit/?alg=y+x%27+%2F%2F+inspection%0AU+R2+U%27+F%27+L+F%27+U%27+L%27+%2F%2F+XX-Cross+%2B+EO%0AU%27+R+U+R%27+%2F%2F+3rd+slot%0AR%27+U+R+U2%27+R%27+U+R+%2F%2F+4th+slot%0AU+R%27+U%27+R+U%27+R%27+U2+R+%2F%2F+OLL+%2F+ZBLL%0AU+%2F%2F+AUF%0A%0A%2F%2F+from+http%3A%2F%2Fcubesolv.es%2Fsolve%2F5757&setup-alg=F+U2+L2+B2+F%27+U+L2+U+R2+D2+L%27+B+L2+B%27+R2+U2" | ||
></a> | ||
</twizzle-link> | ||
</div> | ||
</body> | ||
</html> |