This repository has been archived by the owner on Oct 19, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
feat: rubiks cube sample #3
Merged
Merged
Changes from 4 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
c6ac022
feat: rubiks cube sample initial commit
EdAyers 2e8b0d9
feat: minimal widget example
EdAyers a1cb747
fix: issue where sequence wouldn't refresh
EdAyers ad0fb0f
feat: WidgetMinimal
EdAyers ec56d73
fix: move to latest commit of widget-pr
EdAyers 3601244
fix: lakefiles
EdAyers 191ffb9
chore: rm WidgetsMinimal
Vtec234 6dc8e61
feat: update rubik's demo
Vtec234 dc57928
fix: commonjs bs
Vtec234 f6a01f5
doc: add to readme
EdAyers 94861b2
doc: add a screenshot to readme
EdAyers 61d831e
doc: add mention on root readme and document TypeScript code
EdAyers 0abeda1
fix: workaround for Windows executable
Vtec234 a9b96d9
chore: update to nightly-2022-08-08
Vtec234 dc8c638
Merge branch 'main' into rubiks
Vtec234 2ee411f
doc: fix link
Vtec234 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
build | ||
widget/dist | ||
widget/node_modules | ||
.vscode/ |
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,16 @@ | ||
# Rubiks cube visualiser | ||
|
||
This project is a demo for showing rubiks cubes in the lean infoview. | ||
Inspired by the [rubiks-cube-group](https://github.com/kendfrey/rubiks-cube-group) by Kendal Frey. | ||
|
||
## Building | ||
|
||
In order to install you need [Lean](https://leanprover.github.io/lean4/doc/quickstart.html) and [npm](https://npmjs.com). | ||
You also need to be using VSCode (or a gitpod). | ||
|
||
``` | ||
cd widget | ||
npm i | ||
cd .. | ||
lake build | ||
``` |
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,21 @@ | ||
import Lean | ||
open Lean Elab | ||
|
||
elab (name := includeStr) "include_str " str:str : term => do | ||
let some str := str.isStrLit? | Lean.Elab.throwUnsupportedSyntax | ||
let ctx ← readThe Lean.Core.Context | ||
let srcPath := System.FilePath.mk ctx.fileName | ||
let some srcDir := srcPath.parent | throwError "{srcPath} not in a valid directory" | ||
let path := srcDir / str | ||
Lean.mkStrLit <$> IO.FS.readFile path | ||
|
||
@[widgetSource] | ||
def rubiks : String := include_str "./widget/dist/rubiks.js" | ||
|
||
structure RubiksProps where | ||
seq : Array String := #[] | ||
deriving ToJson, FromJson, Inhabited | ||
|
||
def eg : RubiksProps := {seq := #["U", "L", "D⁻¹", "U⁻¹", "L", "D", "D", "L", "U⁻¹", "R", "D", "F", "F", "D"]} | ||
|
||
#widget rubiks (toJson eg) |
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,23 @@ | ||
import Lake | ||
open System Lake DSL | ||
|
||
def jsTarget (pkgDir : FilePath) : FileTarget := | ||
let jsFile := pkgDir / "widget/dist/rubiks.js" | ||
let srcFiles := inputFileTarget <| pkgDir / "widget/src/rubiks.tsx" | ||
fileTargetWithDep jsFile srcFiles fun _srcFile => do | ||
proc { | ||
cmd := "npm" | ||
args := #["install"] | ||
cwd := some <| pkgDir / "widget" | ||
} | ||
proc { | ||
cmd := "npm" | ||
args := #["run", "build"] | ||
cwd := some <| pkgDir / "widget" | ||
} | ||
|
||
package Rubiks (pkgDir) { | ||
extraDepTarget := jsTarget pkgDir |>.withoutInfo | ||
defaultFacet := PackageFacet.oleans | ||
dependencies := #[ ] | ||
} |
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 @@ | ||
leanprover/lean4:nightly-2022-06-21 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't work on windows, perhaps this would be better:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, the proposed change is good, but we also need this fix in lean for it to work: leanprover/lean4#1257