-
Notifications
You must be signed in to change notification settings - Fork 368
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: add diagram + components + packages
- Loading branch information
Showing
7 changed files
with
1,414 additions
and
5 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
23 changes: 23 additions & 0 deletions
23
website/src/components/InteractiveDiagrams/Timeboost/CentralizedAuction/Circle.jsx
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 React from 'react'; | ||
import { useSpring, animated } from '@react-spring/web'; | ||
|
||
export function Circle({ cx = 1170, cy = 490, r = 10, fill = '#c60' }) { | ||
const props = useSpring({ | ||
from: { opacity: 0.3 }, | ||
to: { opacity: 1 }, | ||
config: { duration: 800 }, | ||
loop: { reverse: true }, | ||
}); | ||
|
||
return ( | ||
<animated.circle | ||
cx={cx} | ||
cy={cy} | ||
r={r} | ||
fill={fill} | ||
style={props} | ||
data-cell-id="tykxDlpcZX9cg9i9ZL_u-31" | ||
pointerEvents="all" | ||
/> | ||
); | ||
} |
119 changes: 119 additions & 0 deletions
119
website/src/components/InteractiveDiagrams/Timeboost/CentralizedAuction/Modal.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,119 @@ | ||
import React, { useState } from 'react'; | ||
import { useTransition, animated } from '@react-spring/web'; | ||
import styled from 'styled-components'; | ||
import * as Dialog from '@radix-ui/react-dialog'; | ||
import { createPortal } from 'react-dom'; | ||
import { Circle } from './Circle'; | ||
|
||
export function Modal({ cx = 1170, cy = 490 }) { | ||
const [isOpen, setIsOpen] = useState(false); | ||
|
||
const handleDialogChange = (isOpen: boolean) => setIsOpen(isOpen); | ||
|
||
const transition = useTransition(isOpen, { | ||
from: { | ||
scale: 0, | ||
opacity: 0, | ||
}, | ||
enter: { | ||
scale: 1, | ||
opacity: 1, | ||
}, | ||
leave: { | ||
scale: 0, | ||
opacity: 0, | ||
}, | ||
}); | ||
|
||
return ( | ||
<> | ||
<g onClick={() => setIsOpen(true)} style={{ cursor: 'pointer' }}> | ||
<Circle cx={cx} cy={cy} r={10} fill="#569AFF" /> | ||
</g> | ||
{typeof document !== 'undefined' && | ||
createPortal( | ||
<Dialog.Root open={isOpen} onOpenChange={handleDialogChange}> | ||
<Dialog.Portal forceMount> | ||
{transition((style, isOpen) => ( | ||
<> | ||
{isOpen ? <OverlayBackground style={{ opacity: style.opacity }} /> : null} | ||
{isOpen ? ( | ||
<Content forceMount style={style}> | ||
<DialogHeader> | ||
<CloseButton> | ||
<svg | ||
width="32" | ||
height="32" | ||
viewBox="0 0 32 32" | ||
fill="none" | ||
xmlns="http://www.w3.org/2000/svg" | ||
> | ||
<path | ||
d="M15.9574 14.1689L8.59651 6.75098L6.73232 8.59598L14.1313 16.071L6.71338 23.4129L8.5964 25.2769L15.9574 17.8779L23.3943 25.2769L25.2392 23.4129L17.8213 16.071L25.2202 8.59598L23.3752 6.75098L15.9574 14.1689Z" | ||
fill="currentColor" | ||
/> | ||
</svg> | ||
</CloseButton> | ||
</DialogHeader> | ||
<Title>How to call the sequencer</Title> | ||
<DialogBody>Call the contract's function: bla bla bla</DialogBody> | ||
</Content> | ||
) : null} | ||
</> | ||
))} | ||
</Dialog.Portal> | ||
</Dialog.Root>, | ||
document.body, | ||
)} | ||
</> | ||
); | ||
} | ||
|
||
const OverlayBackground = styled(animated(Dialog.Overlay))` | ||
width: 100vw; | ||
height: 100vh; | ||
background-color: rgba(0, 0, 0, 0.5); | ||
pointer-events: all; | ||
position: fixed; | ||
inset: 0; | ||
z-index: 9999; | ||
`; | ||
|
||
const Content = styled(animated(Dialog.Content))` | ||
position: fixed; | ||
top: 50%; | ||
left: 50%; | ||
transform: translate(-50%, -50%); | ||
width: 30vw; | ||
height: 40vh; | ||
background-color: #213147; | ||
border-radius: 4px; | ||
padding: 24px 24px 32px; | ||
z-index: 10000; | ||
`; | ||
|
||
const DialogHeader = styled.header` | ||
display: flex; | ||
justify-content: flex-end; | ||
margin-bottom: 16px; | ||
`; | ||
|
||
const DialogBody = styled.body` | ||
display: flex; | ||
justify-content: center; | ||
margin-bottom: 6px; | ||
`; | ||
|
||
const CloseButton = styled(Dialog.Close)` | ||
background-color: transparent; | ||
border: none; | ||
position: absolute; | ||
top: 16px; | ||
right: 16px; | ||
cursor: pointer; | ||
color: #9dcced; | ||
`; | ||
|
||
const Title = styled(Dialog.Title)` | ||
font-size: 20px; | ||
`; |
894 changes: 894 additions & 0 deletions
894
website/src/components/InteractiveDiagrams/Timeboost/CentralizedAuction/index.jsx
Large diffs are not rendered by default.
Oops, something went wrong.
56 changes: 56 additions & 0 deletions
56
website/src/components/InteractiveDiagrams/Timeboost/CentralizedAuction/styles.module.css
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,56 @@ | ||
.hover-frame { | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
width: 100%; | ||
height: 100%; | ||
background-color: rgba(0, 0, 0, 0.5); /* Semi-transparent background */ | ||
display: none; /* Hidden by default */ | ||
justify-content: center; | ||
align-items: center; | ||
color: white; | ||
font-size: 1.5rem; | ||
z-index: 10; /* Ensure it appears on top */ | ||
text-align: center; /* Center text horizontally */ | ||
} | ||
|
||
.hover-frame.visible { | ||
display: flex; /* Show the frame when visible */ | ||
color: white; | ||
font-size: 1.5rem; | ||
} | ||
|
||
.diagramContainer { | ||
width: 100%; | ||
height: auto; | ||
position: relative; | ||
} | ||
|
||
.hoverOverlay { | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
width: 100%; | ||
height: 100%; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
background-color: rgba(0, 0, 0, 0.5); | ||
color: white; | ||
font-size: 1.5rem; | ||
pointer-events: none; | ||
} | ||
|
||
.hovered path, | ||
.hovered rect { | ||
fill: #ff0000; | ||
transition: fill 0.3s ease; | ||
} | ||
|
||
.flowChartContainer { | ||
width: 100%; | ||
max-width: 1200px; | ||
margin: 0 auto; | ||
overflow-x: auto; | ||
padding: 1rem; | ||
} |
Oops, something went wrong.