From 9c4578c67dad2b647dd20ec90fd4723d443be7e5 Mon Sep 17 00:00:00 2001 From: George Thomas Date: Wed, 22 Nov 2023 14:18:07 +0000 Subject: [PATCH] feat: Support animations This just involves bumping the backend pin and adding a new node type for rendering for the new animation primitive. Signed-off-by: George Thomas --- argocd/base/statefulset.yaml | 2 +- flake.lock | 8 ++--- flake.nix | 2 +- src/components/TreeReactFlow/Types.ts | 6 ++++ src/components/TreeReactFlow/index.tsx | 35 +++++++++++++++++++++ src/primer-api/model/index.ts | 2 ++ src/primer-api/model/primCon.ts | 3 +- src/primer-api/model/primConOneOfFive.ts | 13 ++++++++ src/primer-api/model/primConOneOfFiveTag.ts | 15 +++++++++ 9 files changed, 79 insertions(+), 7 deletions(-) create mode 100644 src/primer-api/model/primConOneOfFive.ts create mode 100644 src/primer-api/model/primConOneOfFiveTag.ts diff --git a/argocd/base/statefulset.yaml b/argocd/base/statefulset.yaml index 6b0d3415..1d6f5727 100644 --- a/argocd/base/statefulset.yaml +++ b/argocd/base/statefulset.yaml @@ -26,7 +26,7 @@ spec: # Note: use the *dev* version of the package here, so that # PRs can deploy `primer-service` container images that have # not yet been merged to `primer` `main`. - image: ghcr.io/hackworthltd/primer-service-dev:git-96236936906694bacf62c52cb718ba73e77c50ee + image: ghcr.io/hackworthltd/primer-service-dev:git-e8e9f14d326e82e0814a79185a1246327abc62f7 ports: - containerPort: 8081 env: diff --git a/flake.lock b/flake.lock index d601fd1b..5e979332 100644 --- a/flake.lock +++ b/flake.lock @@ -1407,17 +1407,17 @@ "pre-commit-hooks-nix": "pre-commit-hooks-nix_4" }, "locked": { - "lastModified": 1700488236, - "narHash": "sha256-Y7bFygT7pKVCY/7r4KA75/XZil3F4a19AxN5UwqARfI=", + "lastModified": 1700649959, + "narHash": "sha256-DDPIT5oP63llnI9vjUi2VSVAOf5a96xW+FuzPzifmZ8=", "owner": "hackworthltd", "repo": "primer", - "rev": "96236936906694bacf62c52cb718ba73e77c50ee", + "rev": "e8e9f14d326e82e0814a79185a1246327abc62f7", "type": "github" }, "original": { "owner": "hackworthltd", "repo": "primer", - "rev": "96236936906694bacf62c52cb718ba73e77c50ee", + "rev": "e8e9f14d326e82e0814a79185a1246327abc62f7", "type": "github" } }, diff --git a/flake.nix b/flake.nix index 57c33cf7..dccd0f34 100644 --- a/flake.nix +++ b/flake.nix @@ -19,7 +19,7 @@ # Note: don't override any of primer's Nix flake inputs, or else # we won't hit its binary cache. - primer.url = github:hackworthltd/primer/96236936906694bacf62c52cb718ba73e77c50ee; + primer.url = github:hackworthltd/primer/e8e9f14d326e82e0814a79185a1246327abc62f7; flake-parts.url = "github:hercules-ci/flake-parts"; }; diff --git a/src/components/TreeReactFlow/Types.ts b/src/components/TreeReactFlow/Types.ts index f548d4b9..0876d875 100644 --- a/src/components/TreeReactFlow/Types.ts +++ b/src/components/TreeReactFlow/Types.ts @@ -124,6 +124,7 @@ export type PrimerNode = { | { type: "primer-typedef-name"; data: PrimerTypeDefNameNodeProps } | { type: "primer-typedef-param"; data: PrimerTypeDefParamNodeProps } | { type: "primer-typedef-cons"; data: PrimerTypeDefConsNodeProps } + | { type: "primer-animation"; data: PrimerAnimationNodeProps } ); export const primerNodeWith = (n: PrimerNode, x: T): PrimerNode => @@ -206,6 +207,11 @@ export type PrimerTypeDefConsNodeProps = { name: GlobalName; }; +/** Properties for an animation node. */ +export type PrimerAnimationNodeProps = { + contents: string; +}; + /** Properties common to every type of node. */ export type PrimerCommonNodeProps = { width: number; diff --git a/src/components/TreeReactFlow/index.tsx b/src/components/TreeReactFlow/index.tsx index 777d5d75..f2500f7c 100644 --- a/src/components/TreeReactFlow/index.tsx +++ b/src/components/TreeReactFlow/index.tsx @@ -51,6 +51,7 @@ import { PrimerTypeDefNameNodeProps, NodeData, Padding, + PrimerAnimationNodeProps, } from "./Types"; import { LayoutParams, layoutTree } from "./layoutTree"; import { @@ -444,6 +445,11 @@ const nodeTypes = { {handle("source", Position.Right)} ), + "primer-animation": ({ + data, + }: { + data: PrimerAnimationNodeProps & PrimerCommonNodeProps; + }) => , }; const edgeTypes = { @@ -586,6 +592,23 @@ const makePrimerNode = async ( case "PrimBody": { const hideLabel = hideLabels; const { fst: flavor, snd: prim } = node.body.contents; + if (prim.tag == "PrimAnimation") { + return [ + { + id, + type: "primer-animation", + data: { contents: prim.contents, ...common }, + zIndex, + }, + (child, isRight) => ({ + type: "primer", + data: { flavor }, + className: flavorEdgeClasses(flavor), + ...edgeCommon(child, isRight), + }), + [], + ]; + } const contents = (() => { switch (prim.tag) { case "PrimInt": @@ -781,6 +804,18 @@ const makeSelectionFromNode = ( }, }, }; + } else if (node.type == "primer-animation") { + return { + tag: "SelectionDef", + contents: { + def: node.data.def, + node: { + nodeType: "BodyNode", + // This will always be an actual number, since these nodes have backend IDs. + meta: Number(node.id), + }, + }, + }; } else { return makeSelectionFromNodeData( node.data.def, diff --git a/src/primer-api/model/index.ts b/src/primer-api/model/index.ts index bcaf4f35..378e5824 100644 --- a/src/primer-api/model/index.ts +++ b/src/primer-api/model/index.ts @@ -64,6 +64,8 @@ export * from './paginatedMeta'; export * from './paginatedSession'; export * from './primCon'; export * from './primConOneOf'; +export * from './primConOneOfFive'; +export * from './primConOneOfFiveTag'; export * from './primConOneOfTag'; export * from './primConOneOfThree'; export * from './primConOneOfThreeTag'; diff --git a/src/primer-api/model/primCon.ts b/src/primer-api/model/primCon.ts index fbc3c3e0..9dfb526b 100644 --- a/src/primer-api/model/primCon.ts +++ b/src/primer-api/model/primCon.ts @@ -7,5 +7,6 @@ */ import type { PrimConOneOf } from './primConOneOf'; import type { PrimConOneOfThree } from './primConOneOfThree'; +import type { PrimConOneOfFive } from './primConOneOfFive'; -export type PrimCon = PrimConOneOf | PrimConOneOfThree; +export type PrimCon = PrimConOneOf | PrimConOneOfThree | PrimConOneOfFive; diff --git a/src/primer-api/model/primConOneOfFive.ts b/src/primer-api/model/primConOneOfFive.ts new file mode 100644 index 00000000..5f645c6f --- /dev/null +++ b/src/primer-api/model/primConOneOfFive.ts @@ -0,0 +1,13 @@ +/** + * Generated by orval v6.19.1 🍺 + * Do not edit manually. + * Primer backend API + * A backend service implementing a pedagogic functional programming language. + * OpenAPI spec version: 0.7 + */ +import type { PrimConOneOfFiveTag } from './primConOneOfFiveTag'; + +export type PrimConOneOfFive = { + contents: string; + tag: PrimConOneOfFiveTag; +}; diff --git a/src/primer-api/model/primConOneOfFiveTag.ts b/src/primer-api/model/primConOneOfFiveTag.ts new file mode 100644 index 00000000..2acb9713 --- /dev/null +++ b/src/primer-api/model/primConOneOfFiveTag.ts @@ -0,0 +1,15 @@ +/** + * Generated by orval v6.19.1 🍺 + * Do not edit manually. + * Primer backend API + * A backend service implementing a pedagogic functional programming language. + * OpenAPI spec version: 0.7 + */ + +export type PrimConOneOfFiveTag = typeof PrimConOneOfFiveTag[keyof typeof PrimConOneOfFiveTag]; + + +// eslint-disable-next-line @typescript-eslint/no-redeclare +export const PrimConOneOfFiveTag = { + PrimAnimation: 'PrimAnimation', +} as const;