Skip to content

Commit

Permalink
add better flow demo
Browse files Browse the repository at this point in the history
  • Loading branch information
EvanBacon committed Aug 23, 2024
1 parent 71e1035 commit 4d6bf53
Show file tree
Hide file tree
Showing 4 changed files with 367 additions and 225 deletions.
5 changes: 3 additions & 2 deletions components/flow/flow-node.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { memo, ReactNode } from "react";
import { Handle, NodeProps, Position, Node } from "@xyflow/react";
import { FiCloud } from "react-icons/fi";

import { Route } from "lucide-react";

export type TurboNodeData = {
title: string;
Expand All @@ -13,7 +14,7 @@ export default memo(({ data }: NodeProps<Node<TurboNodeData>>) => {
<>
<div className="cloud gradient">
<div>
<FiCloud />
<Route width={16} />
</div>
</div>
<div className="wrapper gradient">
Expand Down
353 changes: 176 additions & 177 deletions components/flow/flow.css
Original file line number Diff line number Diff line change
@@ -1,178 +1,177 @@
.react-flow {
--bg-color: rgb(17, 17, 17);
--text-color: rgb(243, 244, 246);
--node-border-radius: 10px;
--node-box-shadow: 10px 0 15px rgba(42, 138, 246, 0.3),
-10px 0 15px rgba(233, 42, 103, 0.3);
background-color: var(--bg-color);
color: var(--text-color);
}

.react-flow__node-turbo {
border-radius: var(--node-border-radius);
display: flex;
height: 70px;
min-width: 150px;
font-family: 'Fira Mono', Monospace;
font-weight: 500;
letter-spacing: -0.2px;
box-shadow: var(--node-box-shadow);
}

.react-flow__node-turbo .wrapper {
overflow: hidden;
display: flex;
padding: 2px;
position: relative;
border-radius: var(--node-border-radius);
flex-grow: 1;
}

.gradient:before {
content: '';
position: absolute;
padding-bottom: calc(100% * 1.41421356237);
width: calc(100% * 1.41421356237);
background: conic-gradient(
from -160deg at 50% 50%,
#e92a67 0deg,
#a853ba 120deg,
#2a8af6 240deg,
#e92a67 360deg
);
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
border-radius: 100%;
}

.react-flow__node-turbo.selected .wrapper.gradient:before {
content: '';
background: conic-gradient(
from -160deg at 50% 50%,
#e92a67 0deg,
#a853ba 120deg,
#2a8af6 240deg,
rgba(42, 138, 246, 0) 360deg
);
animation: spinner 4s linear infinite;
transform: translate(-50%, -50%) rotate(0deg);
z-index: -1;
}

@keyframes spinner {
100% {
transform: translate(-50%, -50%) rotate(-360deg);
}
}

.react-flow__node-turbo .inner {
background: var(--bg-color);
padding: 16px 20px;
border-radius: var(--node-border-radius);
display: flex;
flex-direction: column;
justify-content: center;
flex-grow: 1;
position: relative;
}

.react-flow__node-turbo .icon {
margin-right: 8px;
}

.react-flow__node-turbo .body {
display: flex;
}

.react-flow__node-turbo .title {
font-size: 16px;
margin-bottom: 2px;
line-height: 1;
}

.react-flow__node-turbo .subline {
font-size: 12px;
color: #777;
}

.react-flow__node-turbo .cloud {
border-radius: 100%;
width: 30px;
height: 30px;
right: 0;
position: absolute;
top: 0;
transform: translate(50%, -50%);
display: flex;
transform-origin: center center;
padding: 2px;
overflow: hidden;
box-shadow: var(--node-box-shadow);
z-index: 1;
}

.react-flow__node-turbo .cloud div {
background-color: var(--bg-color);
flex-grow: 1;
border-radius: 100%;
display: flex;
justify-content: center;
align-items: center;
position: relative;
}

.react-flow__handle {
opacity: 0;
}

.react-flow__handle.source {
right: -10px;
}

.react-flow__handle.target {
left: -10px;
}

.react-flow__node:focus {
outline: none;
}

.react-flow__edge .react-flow__edge-path {
stroke: url(#edge-gradient);
stroke-width: 2;
stroke-opacity: 0.75;
}

.react-flow__controls button {
background-color: var(--bg-color);
color: var(--text-color);
border: 1px solid #95679e;
border-bottom: none;
}

.react-flow__controls button:hover {
background-color: rgb(37, 37, 37);
}

.react-flow__controls button:first-child {
border-radius: 5px 5px 0 0;
}

.react-flow__controls button:last-child {
border-bottom: 1px solid #95679e;
border-radius: 0 0 5px 5px;
}

.react-flow__controls button path {
fill: var(--text-color);
}

.react-flow__attribution {
background: rgba(200, 200, 200, 0.2);
}

.react-flow__attribution a {
color: #95679e;
}

--bg-color: #f9f9f9;
--text-color: rgb(17, 17, 17);
--node-border-radius: 10px;
--node-box-shadow: 10px 0 15px rgba(7, 47, 53, 0.127),
-10px 0 15px rgba(32, 34, 33, 0.034);
background-color: var(--bg-color);
color: var(--text-color);
}

.react-flow__node-turbo {
border-radius: var(--node-border-radius);
display: flex;
height: 70px;
min-width: 150px;
font-family: "Fira Mono", Monospace;
font-weight: 500;
letter-spacing: -0.2px;
box-shadow: var(--node-box-shadow);
}

.react-flow__node-turbo .wrapper {
overflow: hidden;
display: flex;
padding: 2px;
position: relative;
border-radius: var(--node-border-radius);
flex-grow: 1;
}

.gradient:before {
content: "";
position: absolute;
padding-bottom: calc(100% * 1.41421356237);
width: calc(100% * 1.41421356237);
background: conic-gradient(
from -160deg at 50% 50%,
#9394a0 0deg,
#222431 120deg,
#9394a0 240deg,
#000000 360deg
);
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
border-radius: 100%;
}

.react-flow__node-turbo.selected .wrapper.gradient:before {
content: "";
background: conic-gradient(
from -160deg at 50% 50%,
#000000 0deg,
#222431 120deg,
#9394a0 240deg,
rgba(42, 138, 246, 0) 360deg
);
animation: spinner 4s linear infinite;
transform: translate(-50%, -50%) rotate(0deg);
z-index: -1;
}

@keyframes spinner {
100% {
transform: translate(-50%, -50%) rotate(-360deg);
}
}

.react-flow__node-turbo .inner {
background: var(--bg-color);
padding: 16px 20px;
border-radius: var(--node-border-radius);
display: flex;
flex-direction: column;
justify-content: center;
flex-grow: 1;
position: relative;
}

.react-flow__node-turbo .icon {
margin-right: 8px;
}

.react-flow__node-turbo .body {
display: flex;
}

.react-flow__node-turbo .title {
font-size: 16px;
margin-bottom: 2px;
line-height: 1;
}

.react-flow__node-turbo .subline {
font-size: 12px;
color: #777;
}

.react-flow__node-turbo .cloud {
border-radius: 100%;
width: 30px;
height: 30px;
right: 0;
position: absolute;
top: 0;
transform: translate(50%, -50%);
display: flex;
transform-origin: center center;
padding: 2px;
overflow: hidden;
box-shadow: var(--node-box-shadow);
z-index: 1;
}

.react-flow__node-turbo .cloud div {
background-color: var(--bg-color);
flex-grow: 1;
border-radius: 100%;
display: flex;
justify-content: center;
align-items: center;
position: relative;
}

.react-flow__handle {
opacity: 0;
}

.react-flow__handle.source {
right: -10px;
}

.react-flow__handle.target {
left: -10px;
}

.react-flow__node:focus {
outline: none;
}

.react-flow__edge .react-flow__edge-path {
stroke: url(#edge-gradient);
stroke-width: 2;
stroke-opacity: 0.75;
}

.react-flow__controls button {
background-color: var(--bg-color);
color: var(--text-color);
border: 1px solid #5939d7;
border-bottom: none;
}

.react-flow__controls button:hover {
background-color: rgb(37, 37, 37);
}

.react-flow__controls button:first-child {
border-radius: 5px 5px 0 0;
}

.react-flow__controls button:last-child {
border-bottom: 1px solid #5939d7;
border-radius: 0 0 5px 5px;
}

.react-flow__controls button path {
fill: var(--text-color);
}

.react-flow__attribution {
background: rgba(255, 255, 255, 0.2);
}

.react-flow__attribution a {
color: #5939d7;
}
Loading

0 comments on commit 4d6bf53

Please sign in to comment.