-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #215 from gridaco/debug-mode
Debug Mode
- Loading branch information
Showing
26 changed files
with
1,658 additions
and
170 deletions.
There are no files selected for viewing
2 changes: 2 additions & 0 deletions
2
editor-packages/editor-devtools/components/visualization/index.ts
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 |
---|---|---|
@@ -1 +1,3 @@ | ||
export * from "./json-visualization"; | ||
export * from "./node-visualization"; | ||
export * as visualize_node from "./node-visualization"; |
1 change: 1 addition & 0 deletions
1
editor-packages/editor-devtools/components/visualization/json-visualization/index.ts
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 @@ | ||
export * from "./json-tree"; |
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
133 changes: 133 additions & 0 deletions
133
editor-packages/editor-devtools/components/visualization/node-visualization/control.tsx
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,133 @@ | ||
import React, { useState } from "react"; | ||
import styled from "@emotion/styled"; | ||
import { GearIcon, Cross1Icon } from "@radix-ui/react-icons"; | ||
import { IconToggleButton } from "@code-editor/ui"; | ||
|
||
type Props = { | ||
layout: string; | ||
orientation: string; | ||
linkType: string; | ||
stepPercent: number; | ||
setLayout: (layout: string) => void; | ||
setOrientation: (orientation: string) => void; | ||
setLinkType: (linkType: string) => void; | ||
setStepPercent: (percent: number) => void; | ||
}; | ||
|
||
export default function LinkControls({ | ||
layout, | ||
orientation, | ||
linkType, | ||
stepPercent, | ||
setLayout, | ||
setOrientation, | ||
setLinkType, | ||
setStepPercent, | ||
}: Props) { | ||
const [isExpanded, setIsExpanded] = useState(false); | ||
|
||
return ( | ||
<ControlContainer data-expanded={isExpanded}> | ||
<div | ||
className="controls" | ||
style={{ | ||
display: isExpanded ? undefined : "none", | ||
}} | ||
> | ||
<div className="control"> | ||
<label>layout</label> | ||
<select | ||
onClick={(e) => e.stopPropagation()} | ||
onChange={(e) => setLayout(e.target.value)} | ||
value={layout} | ||
> | ||
<option value="cartesian">cartesian</option> | ||
<option value="polar">polar</option> | ||
</select> | ||
</div> | ||
<div className="control"> | ||
<label>orientation</label> | ||
<select | ||
onClick={(e) => e.stopPropagation()} | ||
onChange={(e) => setOrientation(e.target.value)} | ||
value={orientation} | ||
disabled={layout === "polar"} | ||
> | ||
<option value="vertical">vertical</option> | ||
<option value="horizontal">horizontal</option> | ||
</select> | ||
</div> | ||
<div className="control"> | ||
<label>link</label> | ||
<select | ||
onClick={(e) => e.stopPropagation()} | ||
onChange={(e) => setLinkType(e.target.value)} | ||
value={linkType} | ||
> | ||
<option value="diagonal">diagonal</option> | ||
<option value="step">step</option> | ||
<option value="curve">curve</option> | ||
<option value="line">line</option> | ||
</select> | ||
</div> | ||
{linkType === "step" && layout !== "polar" && ( | ||
<div className="control"> | ||
<label>step</label> | ||
<input | ||
onClick={(e) => e.stopPropagation()} | ||
type="range" | ||
min={0} | ||
max={1} | ||
step={0.1} | ||
onChange={(e) => setStepPercent(Number(e.target.value))} | ||
value={stepPercent} | ||
disabled={linkType !== "step" || layout === "polar"} | ||
/> | ||
</div> | ||
)} | ||
</div> | ||
<div style={{ marginLeft: 16 }}> | ||
<IconToggleButton | ||
on={<Cross1Icon />} | ||
off={<GearIcon />} | ||
onChange={setIsExpanded} | ||
/> | ||
</div> | ||
</ControlContainer> | ||
); | ||
} | ||
|
||
const ControlContainer = styled.div` | ||
position: absolute; | ||
top: 16px; | ||
right: 16px; | ||
display: flex; | ||
padding: 16px; | ||
border-radius: 4px; | ||
border: 1px solid rgba(255, 255, 255, 0.1); | ||
background-color: rgba(0, 0, 0, 0.5); | ||
backdrop-filter: blur(16px); | ||
font-size: 10px; | ||
color: white; | ||
&[data-expanded="false"] { | ||
border: none; | ||
background-color: transparent; | ||
} | ||
.controls { | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
gap: 8px; | ||
} | ||
.control { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: flex-start; | ||
gap: 4px; | ||
} | ||
`; |
58 changes: 58 additions & 0 deletions
58
...ackages/editor-devtools/components/visualization/node-visualization/get-link-component.ts
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,58 @@ | ||
import { ComponentType } from "react"; | ||
import { | ||
LinkHorizontal, | ||
LinkVertical, | ||
LinkRadial, | ||
LinkHorizontalStep, | ||
LinkVerticalStep, | ||
LinkRadialStep, | ||
LinkHorizontalCurve, | ||
LinkVerticalCurve, | ||
LinkRadialCurve, | ||
LinkHorizontalLine, | ||
LinkVerticalLine, | ||
LinkRadialLine, | ||
} from "@visx/shape"; | ||
|
||
export default function getLinkComponent({ | ||
layout, | ||
linkType, | ||
orientation, | ||
}: { | ||
layout: string; | ||
linkType: string; | ||
orientation: string; | ||
}): ComponentType<any> { | ||
let LinkComponent: ComponentType<any>; | ||
|
||
if (layout === "polar") { | ||
if (linkType === "step") { | ||
LinkComponent = LinkRadialStep; | ||
} else if (linkType === "curve") { | ||
LinkComponent = LinkRadialCurve; | ||
} else if (linkType === "line") { | ||
LinkComponent = LinkRadialLine; | ||
} else { | ||
LinkComponent = LinkRadial; | ||
} | ||
} else if (orientation === "vertical") { | ||
if (linkType === "step") { | ||
LinkComponent = LinkVerticalStep; | ||
} else if (linkType === "curve") { | ||
LinkComponent = LinkVerticalCurve; | ||
} else if (linkType === "line") { | ||
LinkComponent = LinkVerticalLine; | ||
} else { | ||
LinkComponent = LinkVertical; | ||
} | ||
} else if (linkType === "step") { | ||
LinkComponent = LinkHorizontalStep; | ||
} else if (linkType === "curve") { | ||
LinkComponent = LinkHorizontalCurve; | ||
} else if (linkType === "line") { | ||
LinkComponent = LinkHorizontalLine; | ||
} else { | ||
LinkComponent = LinkHorizontal; | ||
} | ||
return LinkComponent; | ||
} |
Oops, something went wrong.
5c4ed5a
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.
Successfully deployed to the following URLs:
code – ./
code-grida.vercel.app
designto-codes.vercel.app
code-git-main-grida.vercel.app
code.grida.co
figma.codes
designto.codes