0.5.4 • Published 2 years ago

@equinor/sparql-graph v0.5.4

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

@equinor/sparql-graph

Example

const dummyNode = 'NewNode';
const colors = ['blue', 'green', 'red', 'yellow', 'purple', 'pink', 'cyan', 'grey'];

const [selection, setSelection] = useState<RdfSelection>(new RdfSelection([], []));

const [patches, setPatches] = useState<Array<RdfPatch>>([]);

const deleteSelection = () => {
	const newPatch = new RdfPatch({ tripleRemovals: selection.rdfTriple, individualRemovals: selection.individuals });
	let newPatches = [...patches, newPatch];
	setPatches(newPatches);
};

const onElementsSelected = (selection: RdfSelection): void => {
	setSelection(selection);
	if (selection.individuals.length > 0) {
		const selectedNode = selection.individuals[0].iri;
		let newPatch: RdfPatch;
		if (selectedNode === dummyNode) {
			const randomColor = colors[Math.floor(Math.random() * colors.length)];
			newPatch = new RdfPatch({ tripleAdditions: [new RdfTriple(selectedNode, 'http://rdf.equinor.com/ui/color', randomColor)] });
		} else {
			newPatch = new RdfPatch({
				tripleAdditions: [
					new RdfTriple(selectedNode, 'NewPredicate', 'NewNode'),
					new RdfTriple('NewNode', 'http://www.w3.org/2000/01/rdf-schema#label', 'New cool node. Tap for random color'),
				],
			});
		}
		let newPatches = [...patches, newPatch];
		setPatches(newPatches);
	}
};

return (
	<div>
		<Button onClick={deleteSelection}> Delete selection </Button>
		<SparqlGraph turtleString={turtleString} layoutName={layoutName} patches={patches} onElementsSelected={onElementsSelected} />
	</div>
);

Props

NameTypeDescription
turtleStringstringData
layoutCola, Cose-Bilkent, DagreLayout name
onElementChanged(selection: RdfSelection) => voidCallback when user (de)selects elements
patchesRdfPatch[]List of changes to facilitate interactivity

Dependabot

DON'T UPDATT MAJOR VERSION:

  • @storybook/preset-create-react-app
  • react-scripts
  • chalk

PR's & releases version

Consistent title names help maintainers organise their projects better 📚

Prefixes:

  • patch: patch,fixes,fix,chore,Bump
  • minor: feat
  • major: major

Example: chore: Update README.md, | fix: Colors for head

For development at the library

Install the latest LTS version of Node.js, and at the same time make sure you are on version 6 of the npm-CLI.

$ node -v && npm -v
v16.14.0
8.31.0

Install Npm

$ npm install --global npm

Install project dependencies

$ npm i

Local development

$ npm run storybook
$ npm run dev # Runs up a local dev version of Storybook - Both good tools to use to quickly see changes along the way.

Code quality

The project is set up with TypeScript, Eslint, Prettier, and the following is run when validating each pull request:

$ npm run checkcode

Testing

We will write unit tests on critical functionality. Tests should be grouped under src/tests/ and named after test file they are testing suffixed by test.tsx

$ npm run test

Construction

$ npm run build:storybook # Builds Storybook for static files, and deploys for Vercel for pull requests and merging for main
$ npm run build:lib # Packs the library (not Storybook) - This step is run before `npm publish` is run
0.5.4

2 years ago

0.5.3

2 years ago

0.5.0

2 years ago

0.5.2

2 years ago

0.5.1

2 years ago

0.3.9

2 years ago

0.4.0

2 years ago

0.2.52

2 years ago

0.2.51

2 years ago

0.2.50

2 years ago

0.2.59

2 years ago

0.2.58

2 years ago

0.2.57

2 years ago

0.2.56

2 years ago

0.2.55

2 years ago

0.2.54

2 years ago

0.2.53

2 years ago

0.3.8

2 years ago

0.3.4

2 years ago

0.2.40

2 years ago

0.2.49

2 years ago

0.2.48

2 years ago

0.2.47

2 years ago

0.2.46

2 years ago

0.2.45

2 years ago

0.2.44

2 years ago

0.2.43

2 years ago

0.2.42

2 years ago

0.2.36

2 years ago

0.2.35

2 years ago

0.2.34

2 years ago

0.2.33

2 years ago

0.2.32

2 years ago

0.2.29

2 years ago

0.2.28

2 years ago

0.2.27

2 years ago

0.2.26

2 years ago

0.2.25

2 years ago

0.2.24

2 years ago

0.2.23

2 years ago

0.2.22

2 years ago

0.2.18

2 years ago

0.2.17

2 years ago

0.2.16

2 years ago

0.2.15

2 years ago

0.2.14

2 years ago

0.2.13

2 years ago

0.2.12

2 years ago

0.2.10

2 years ago

0.2.9

2 years ago

0.2.8

2 years ago

0.2.7

2 years ago

0.2.6

2 years ago

0.2.5

2 years ago

0.2.4

2 years ago

0.2.3

2 years ago

0.2.2

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.1.15

2 years ago