dabeng / react-orgchart

It's a simple and direct organization chart plugin. Anytime you want a tree-like chart, you can turn to OrgChart.
MIT License
128 stars 109 forks source link

Nexjs & Error importing CSS files within node_modules #72

Open medkrimi opened 1 year ago

medkrimi commented 1 year ago

Description Error importing CSS files within node_modules and compatibility with Nextjs app.

Reproduce

  1. Have a running Nextjs app.
  2. yarn add @dabeng/react-orgchart
  3. Add Organization chart to an empty page
    
    //

import OrganizationChart from "@dabeng/react-orgchart" import React from "react"

const DnDChart = () => { const ds = { id: "n1", name: "Lao Lao", title: "general manager", children: [ {id: "n2", name: "Bo Miao", title: "department manager"}, { id: "n3", name: "Su Miao", title: "department manager", children: [ {id: "n4", name: "Tie Hua", title: "senior engineer"}, { id: "n5", name: "Hei Hei", title: "senior engineer", children: [ {id: "n6", name: "Dan Dan", title: "engineer"}, {id: "n7", name: "Xiang Xiang", title: "engineer"} ] }, {id: "n8", name: "Pang Pang", title: "senior engineer"} ] }, {id: "n9", name: "Hong Miao", title: "department manager"}, { id: "n10", name: "Chun Miao", title: "department manager", children: [{id: "n11", name: "Yue Yue", title: "senior engineer"}] } ] }

return }

export default DnDChart



**Error**
<img width="784" alt="image" src="https://user-images.githubusercontent.com/701700/218502794-6ba5a642-40f9-4935-a5b3-ce202af4e49f.png">

**Cause**
With Next.js importing CSS files within node_modules cannot be supported because we cannot know the correct behavior:
- Should the file be consumed as Global CSS or CSS Modules?
- If Global, in what order does the file need to be injected?
- If Modules, what are the emitted class names? As-is, camel-case, snake case?
- Etc.

More details: https://nextjs.org/docs/messages/css-npm
nsi319 commented 1 year ago

Any fixes?