theowenyoung / gatsby-theme-primer-wiki

A Gatsby Theme for Wiki/Docs/Knowledge Base, which using Primer style as the UI theme, can work well with Foam or Obsibian or just markdown files.
https://demo-wiki.owenyoung.com/
MIT License
119 stars 18 forks source link

RFC: Consider adding note colouring to graphView #58

Open tychota opened 2 years ago

tychota commented 2 years ago

Motivation

When organizing note, we can have semantic kind of node.

Eg some note about "Book", some about "Thought", etc...

Allowing the user to see the colors make it easier to find the information on the graph

image

(You can see in the previous image that foam on vscode already support node coloring since https://github.com/foambubble/foam/pull/438.)

{
  "foam.graph.style": {
    "node": {
      "concept": "#3b82f6",
      "technology": "#8b5cf6",
      "kaizen discovery report": "#f43f5e",
      "tag": "#14b8a6"
    }
  }
 }

User explanation

---
title: CPU Bound
type: concept
tags:
  - Concept
---
module.exports = {
  plugins: [
    {
      resolve: "gatsby-theme-primer-wiki",
      options: {
+       "customGraphStyle": {"concept: "#3b82f6"}
      },
    },
  ]
}

Technical explanation

image

The above example code is:

() => {
  const localNotes: Note[] = CONCEPT_DATA.map((o, i) => ({
    ...o,
    type: ['JS Lib', 'Visualization'].includes(o.title) ? 'tag' : 'note',
  }))

  const noteGraphNote = localNotes.find((o) => o.title === 'Note Graph')
  noteGraphNote.nodeStyle = {
    regular: '#E94780',
  }
  const graphModel = new NoteGraphModel(localNotes)

  const tagStyle: NodeStyle = {
    regular: '#64BB00',
    lessened: 'rgba(101, 189, 0, 0.6)',
    highlighted: 'green',
  }

  const localStyle = {
    node: {
      /** Set different style for nodes with `tag` type */
      tag: tagStyle,
    },
  }
  return (
    <div>
      <GraphView
        graphModel={graphModel}
        style={localStyle}
        onGraphViewInit={(view) => {
          if (noteGraphNote) {
            view.setSelectedNodes([noteGraphNote.id])
          }
        }}
      ></GraphView>
    </div>
  )
}

Why not do this

Unresolved question

module.exports = {
  plugins: [
    {
      resolve: "gatsby-theme-primer-wiki",
      options: {
+       "customGraphStyle": {"concept: {"dark": "#5eead4", "light": "#0f766e"}}
      },
    },
  ]
}
tychota commented 2 years ago

Hi @theowenyoung, have you been able to look at the RFC yet ? Let me know if you are interested.