mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-06 03:20:13 +08:00
refactor: styles of nodes and edges
This commit is contained in:
1 parent
9ddfcd2a86
commit
1be4f73e7e
1 file changed
+58
-12
@@ -13,10 +13,10 @@ const toast = useToast()
|
|||||||
const svgWidth = ref(window.innerWidth)
|
const svgWidth = ref(window.innerWidth)
|
||||||
const svgHeight = ref(window.innerHeight)
|
const svgHeight = ref(window.innerHeight)
|
||||||
|
|
||||||
const marginX = 100
|
const marginX = 120
|
||||||
const marginY = 100
|
const marginY = 120
|
||||||
|
|
||||||
const nodeWidth = 150
|
const nodeWidth = 160
|
||||||
const nodeHeight = 50
|
const nodeHeight = 50
|
||||||
|
|
||||||
type Node = {
|
type Node = {
|
||||||
@@ -127,6 +127,20 @@ const curvedPath = computed(() => {
|
|||||||
return `M${source.x},${source.y}A${dr},${dr} 0 0,${sweep} ${target.x},${target.y}`
|
return `M${source.x},${source.y}A${dr},${dr} 0 0,${sweep} ${target.x},${target.y}`
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const nodeStyle = computed(() => {
|
||||||
|
return (node: Node) => {
|
||||||
|
if (node.completed) return 'completed'
|
||||||
|
if (node.unlocked) return 'unlocked'
|
||||||
|
return 'locked'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const edgeStyle = computed(() => {
|
||||||
|
return (edge: Edge) => {
|
||||||
|
return edge.target.unlocked ? 'unlocked' : 'locked'
|
||||||
|
}
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -158,10 +172,7 @@ const curvedPath = computed(() => {
|
|||||||
>
|
>
|
||||||
<path
|
<path
|
||||||
:d="curvedPath(edge.source, edge.target)"
|
:d="curvedPath(edge.source, edge.target)"
|
||||||
:stroke="edge.target.unlocked ? '#ADADB5' : '#454552'"
|
:class="['edge', edgeStyle(edge)]"
|
||||||
:stroke-dasharray="edge.target.unlocked ? 'none' : '5,5'"
|
|
||||||
stroke-width="3"
|
|
||||||
fill="none"
|
|
||||||
/>
|
/>
|
||||||
</g>
|
</g>
|
||||||
<g
|
<g
|
||||||
@@ -176,17 +187,15 @@ const curvedPath = computed(() => {
|
|||||||
:height="nodeHeight"
|
:height="nodeHeight"
|
||||||
rx="10"
|
rx="10"
|
||||||
ry="10"
|
ry="10"
|
||||||
:fill="
|
:class="['node', nodeStyle(node)]"
|
||||||
node.completed ? '#00bb00' : node.unlocked ? '#ADADB5' : '#505050'
|
|
||||||
"
|
|
||||||
/>
|
/>
|
||||||
<text
|
<text
|
||||||
:x="node.x"
|
:x="node.x"
|
||||||
:y="node.y"
|
:y="node.y"
|
||||||
text-anchor="middle"
|
text-anchor="middle"
|
||||||
alignment-baseline="middle"
|
alignment-baseline="middle"
|
||||||
fill="white"
|
:class="['node-text', nodeStyle(node)]"
|
||||||
font-size="16"
|
font-size="18"
|
||||||
>
|
>
|
||||||
{{ node.title }}
|
{{ node.title }}
|
||||||
</text>
|
</text>
|
||||||
@@ -200,4 +209,41 @@ const curvedPath = computed(() => {
|
|||||||
svg {
|
svg {
|
||||||
overflow: visible;
|
overflow: visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.node {
|
||||||
|
&.completed {
|
||||||
|
fill: #6cf76c;
|
||||||
|
}
|
||||||
|
&.unlocked {
|
||||||
|
fill: #8c8c92;
|
||||||
|
}
|
||||||
|
&.locked {
|
||||||
|
fill: #505050;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.node-text {
|
||||||
|
&.completed {
|
||||||
|
fill: #1d1d1d;
|
||||||
|
}
|
||||||
|
&.unlocked {
|
||||||
|
fill: #ffffff;
|
||||||
|
}
|
||||||
|
&.locked {
|
||||||
|
fill: #a0a0a0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.edge {
|
||||||
|
stroke-width: 3;
|
||||||
|
fill: none;
|
||||||
|
&.unlocked {
|
||||||
|
stroke: #adadb5;
|
||||||
|
stroke-dasharray: none;
|
||||||
|
}
|
||||||
|
&.locked {
|
||||||
|
stroke: #454552;
|
||||||
|
stroke-dasharray: 5, 5;
|
||||||
|
}
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
Reference in new issue
Block a user