Giter Site home page Giter Site logo

know-flow-react's Introduction

know-flow-react

React library for building modular linked data-centric UIs

NPM JavaScript Style Guide

Install

npm install --save know-flow-react

Usage

import React from "react";
import {ComponentBuilder, Attribute, Engine} from "know-flow-react";
import {newEngine as newComunicaEngine} from '@comunica/actor-init-sparql';

import 'bootstrap/dist/css/bootstrap.min.css';
import { Container, Row, Col, Card } from "react-bootstrap";

let options = {
    prefixes: {
        'rdf': 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
        'rdfs': 'http://www.w3.org/2000/01/rdf-schema#',
        'wd': 'http://www.wikidata.org/entity/',
        'wdt': 'http://www.wikidata.org/prop/direct/',
        'schema': 'http://schema.org/'
    }
};

let kf = new ComponentBuilder(options);

const PlanetInfo = kf.pack('PlanetInfo', (props: any) => (
  <Card>
    <Card.Img variant="top">
      <Attribute name="src"><kf.Value path='wdt:P18'/></Attribute>
    </Card.Img>
    <Card.Body>
      <Card.Title><kf.Value path='rdfs:label' lang='it'/></Card.Title>
      <Card.Text><kf.Value path='schema:description' lang='it'/></Card.Text>
    </Card.Body>
  </Card>
));

const TestComponent:React.FC = (props: any) => (
  <Engine engine={newComunicaEngine()}
      queryContext={{sources: [{ type: 'sparql', value: 'https://query.wikidata.org/sparql' }]}}>
    <kf.Input bindings='wd:Q3504248'>
      <Container>
        <Row>
          <Col><h1><kf.Value path='rdfs:label' lang='it'/></h1></Col>
        </Row>
        <kf.ForEach path='^wdt:P31'>
          <Row>
            <Col><PlanetInfo/></Col>
          </Row>
        </kf.ForEach>
      </Container>
    </kf.Input>
  </Engine>
);

export default TestComponent;

License

MIT © miguel76

know-flow-react's People

Contributors

miguel76 avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.