npx create-react-app nom-de-ton-application-sans-majuscules
cd nom-de-ton-application-sans-majuscules
npm install beautiful-skill-tree
npm start
Dans ton App.js tu mets
<code>import { SkillTreeGroup, SkillTree, SkillProvider, SkillType, SkillGroupDataType } from 'beautiful-skill-tree';
const data: SkillType[] = [
{
id: 'hello-world',
title: 'Hello world',
tooltip: {
content: 'This node is the top most level, and will be unlocked, and ready to be clicked.',
},
children: [
{
id: 'hello-sun',
title: 'Hello Sun',
tooltip: {
content: 'This is a parent of the top node, and will locked while the parent isn’t in a selected state.',
},
children: [],
},
{
id: 'hello-stars',
title: 'Hello Stars',
tooltip: {
content: 'This is the child of ‘Hello World and the sibling of ‘Hello Sun’. Notice how the app takes care of the layout automatically? That’s why this is called Beautiful Skill Tree and not just ‘Skill Tree’. (Also the npm namespace had already been taken for the latter so (flick hair emoji).',
},
children: [],
},
],
},
];
function App() {
return (
<div className="App">
<div className="App-header">
<SkillProvider>
<SkillTreeGroup>
{({ skillCount }: SkillGroupDataType) => {
return <SkillTree treeId="first-tree" title="Skill Tree" data={data} />
}}
</SkillTreeGroup>
</SkillProvider>
</div>
</div>
);
}</code>
Pour modifier ton arborescence il faut jouer avec le tableau data.
Le noeud principal est tout en haut. Tu peux donner la prop "children" à chaque noeud, qui est un autre tableau contenant d'autres noeuds, tout simplement.
Après je pense qu'il vaut mieux faire ton arbre dans un objet JSON à part et l'importer; si t'as beaucoup de branches ça risque de rendre ton code galère à lire.

Message édité le 09 octobre 2019 à 22:27:03 par [Carabistouille