feat: implement todo and resource button (#6055)

* feat: implement todo and resource button

* feat: add hover color
pull/6099/head
Arik Chakma 5 months ago committed by GitHub
parent 24f9e0c6ce
commit 9154a57eb9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      .astro/settings.json
  2. 17
      src/components/EditorRoadmap/EditorRoadmapRenderer.css
  3. 30
      src/components/EditorRoadmap/EditorRoadmapRenderer.tsx

@ -3,6 +3,6 @@
"enabled": false "enabled": false
}, },
"_variables": { "_variables": {
"lastUpdateCheck": 1719080230711 "lastUpdateCheck": 1720119515249
} }
} }

@ -7,21 +7,24 @@ svg text tspan {
svg > g[data-type='topic'], svg > g[data-type='topic'],
svg > g[data-type='subtopic'], svg > g[data-type='subtopic'],
svg g[data-type='link-item'], svg g[data-type='link-item'],
svg > g[data-type='button'] { svg > g[data-type='button'],
svg > g[data-type='resourceButton'],
svg > g[data-type='todo-checkbox'],
svg > g[data-type='todo'] {
cursor: pointer; cursor: pointer;
} }
svg > g[data-type='topic']:hover > rect { svg > g[data-type='topic']:hover > rect {
fill: #d6d700; fill: var(--hover-color);
} }
svg > g[data-type='subtopic']:hover > rect { svg > g[data-type='subtopic']:hover > rect {
fill: #f3c950; fill: var(--hover-color);
} }
svg > g[data-type='button']:hover { svg g[data-type='button']:hover,
opacity: 0.8; svg g[data-type='link-item']:hover,
} svg g[data-type='resourceButton']:hover,
svg g[data-type='link-item']:hover { svg g[data-type='todo-checkbox']:hover {
opacity: 0.8; opacity: 0.8;
} }

@ -45,7 +45,15 @@ function getNodeDetails(svgElement: SVGElement): RoadmapNodeDetails | null {
return { nodeId, nodeType, targetGroup, title }; return { nodeId, nodeType, targetGroup, title };
} }
const allowedNodeTypes = ['topic', 'subtopic', 'button', 'link-item']; const allowedNodeTypes = [
'topic',
'subtopic',
'button',
'link-item',
'resourceButton',
'todo',
'todo-checkbox',
];
export function EditorRoadmapRenderer(props: RoadmapRendererProps) { export function EditorRoadmapRenderer(props: RoadmapRendererProps) {
const { resourceId, nodes = [], edges = [] } = props; const { resourceId, nodes = [], edges = [] } = props;
@ -90,7 +98,11 @@ export function EditorRoadmapRenderer(props: RoadmapRendererProps) {
return; return;
} }
if (nodeType === 'button' || nodeType === 'link-item') { if (
nodeType === 'button' ||
nodeType === 'link-item' ||
nodeType === 'resourceButton'
) {
const link = targetGroup?.dataset?.link || ''; const link = targetGroup?.dataset?.link || '';
const isExternalLink = link.startsWith('http'); const isExternalLink = link.startsWith('http');
if (isExternalLink) { if (isExternalLink) {
@ -104,6 +116,20 @@ export function EditorRoadmapRenderer(props: RoadmapRendererProps) {
const isCurrentStatusLearning = targetGroup?.classList.contains('learning'); const isCurrentStatusLearning = targetGroup?.classList.contains('learning');
const isCurrentStatusSkipped = targetGroup?.classList.contains('skipped'); const isCurrentStatusSkipped = targetGroup?.classList.contains('skipped');
if (nodeType === 'todo-checkbox') {
e.preventDefault();
if (!isLoggedIn()) {
showLoginPopup();
return;
}
const newStatus = targetGroup?.classList.contains('done')
? 'pending'
: 'done';
updateTopicStatus(nodeId, newStatus);
return;
}
if (e.shiftKey) { if (e.shiftKey) {
e.preventDefault(); e.preventDefault();
if (!isLoggedIn()) { if (!isLoggedIn()) {

Loading…
Cancel
Save