Giter Club home page Giter Club logo

ldkg-ui-diags's Introduction

Rollup React w/ Storybook User Guide

Congrats! You just saved yourself hours of work by bootstrapping this project with Rollup. Let’s get you oriented with what’s here and how to use it.

This setup is meant for developing React component libraries (not apps!) that can be published to NPM. If you’re looking to build a React-based app, you should use create-react-app, razzle, nextjs, gatsby, or react-static.

If you’re new to TypeScript and React, checkout this handy cheatsheet

Commands

Rollup scaffolds your new library inside /src, and also sets up a CRA-based playground for it inside /example.

The recommended workflow is to run Rollup in one terminal:

yarn start # or yarn start

This builds to /es and runs the project in watch mode so any edits you save inside src causes a rebuild to /es.

Then run either Storybook or the example playground:

Storybook

Run inside another terminal:

yarn storybook

This loads the stories from ./stories.

NOTE: Stories should reference the components as if using the library, similar to the example playground. This means importing from the root project directory. This has been aliased in the tsconfig and the storybook webpack config as a helper.

Example

Then run the example inside another:

cd example
yarn install # to install dependencies
yarn start # or yarn start

The default example imports and live reloads whatever is in /es, so if you are seeing an out of date component, make sure Rollup is running in watch mode like we recommend above. No symlinking required, we use aliasing.

To do a one-off build, use yarn build.

To run tests, use yarn test.

Configuration

Code quality is set up for you with prettier, husky, and lint-staged. Adjust the respective fields in package.json accordingly.

Jest

Jest tests are set up to run with yarn test.

Bundle analysis

Calculates the real cost of your library using size-limit with npm run size and visulize it with npm run analyze.

Setup Files

This is the folder structure we set up for you:

/example
  index.html
  index.tsx       # test your component here in a demo app
  package.json
  tsconfig.json
/src
  index.ts       # EDIT THIS
/test
  blah.test.tsx   # EDIT THIS
/stories
  Thing.stories.tsx # EDIT THIS
/.storybook
  main.js
  preview.js
.gitignore
package.json
README.md         # EDIT THIS
tsconfig.json

React Testing Library

We do not set up react-testing-library for you yet, we welcome contributions and documentation on this.

Rollup

We use Rollup as a bundler and generates multiple rollup configs for various module formats and build settings.

TypeScript

tsconfig.json is set up to interpret dom and esnext types, as well as react for jsx. Adjust according to your needs.

Continuous Integration

GitHub Actions

Two actions are added by default:

  • main which installs deps w/ cache, lints, tests, and builds on all pushes against a Node and OS matrix
  • size which comments cost comparison of your library on every pull request using size-limit

Module Formats

ESModule format is supported.

The appropriate paths are configured in package.json and es/index.js accordingly. Please report if any issues are found.

Deploying the Example Playground

The Playground is just a simple CRA app, you can deploy it anywhere you would normally deploy that.

Named Exports

Per Palmer Group guidelines, always use named exports. Code split inside your React app instead of your React library.

Including Styles

There are many ways to ship styles, including with CSS-in-JS. We have no opinion on this, configure how you like.

For vanilla CSS, you can include it at the root directory and add it to the files section in your package.json, so that it can be imported separately by your users and run through their bundler's loader.

Usage with Lerna

When creating a new package with Rollup within a project set up with Lerna, you might encounter a Cannot resolve dependency error when trying to run the example project. To fix that you will need to make changes to the package.json file inside the example directory.

The problem is that due to the nature of how dependencies are installed in Lerna projects, the aliases in the example project's package.json might not point to the right place, as those dependencies might have been installed in the root of your Lerna project.

Change the alias to point to where those packages are actually installed. This depends on the directory structure of your Lerna project, so the actual path might be different from the diff below.

   "alias": {
-    "react": "../node_modules/react",
-    "react-dom": "../node_modules/react-dom"
+    "react": "../../../node_modules/react",
+    "react-dom": "../../../node_modules/react-dom"
   },

An alternative to fixing this problem would be to remove aliases altogether and define the dependencies referenced as aliases as dev dependencies instead. However, that might cause other problems.

ldkg-ui-diags's People

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

ldkg-ui-diags's Issues

Reduce visual noize in shapes diagram

  • Make shape node less intence
    • contour lines in gray color
    • title fill: maybe gray-white gradient
  • Make compartment node colors less intence, then shape node colors
  • Extract rest's title into separate rect's child element in ViewKind
  • Prefer CSS styles for nodes, node elements
    • rects: fill, border, margins, paddings
    • text labels: font, font-size..., background

Compact shapes classes DiagramKind

  • No separate top-level PropertyShape nodes, only NodeShape nodes are top-level
  • All simple-type PropertyShapes (string, int,.. all except IRI) are like UML class properties (in compartments in Class nodes)
  • Arrow types
    • Class inheritance relation (class-to-superclass) -- arrow between NodeShapes based on relation between their targetClass classes
    • Class reference relation (classA-to-classB-by-propertyC) -- arrow between shapes if there is a PropertyShape in class A with sh:nodeKind = sh:IRI and sh:class = iri of class B. Arrow label = propertyC IRI

In should be possible to draw disconnected edges if relation class shema allows it

Subrelation Schema (targeting UsedInDiagramAsXXX classes) could allows disconnected edges (if property cardinality is 0:1) or forbids it (if property cardinality is 1:1).

Ability to draw new disconnected edge

  • disconnected from one node
  • disconnected from all nodes

Ability to edit connected edge and make in disconnected:

  • Disconnect connected edge from one node
  • Disconnect connected edge from all nodes

Same selection tool interaction for diagram nodes and edges

  • Exactly the same selection visual markers for selected Nodes and Edges. Same size, same colour.
  • The same selection markers behavior (or interactivity):
    • Markers should appear after single click on edge, not on hover. Like nodes selection.
    • Selected edge should stay selected untl "click outside" (like node).

Delete nodes and edges by DEL keyboard key

Main delete scenarious:

  • Single selected node or arrow
    • DEL should delete selected node or arrow
  • Parent node with childs
    • selected only parent node OR parent with all childs OR parent with some of childs)
      • DEL should delete parent and ALL it's childs
    • selected only some of childs AND parent not selected
      • DEL should delete only selected childs
  • Multi-elected nodes and/or arrows in any combinations (including parent nodes with childs)
    • DEL should delete selected nodes and/or arrows in any combinations
      • in case of parent nodes see "Parent node with childs"

See working example in Antv X6 DAG

Move hardcoded node and line stencils into configs

  1. Some hardcoded stencils in different places:
  • graphCore.tsx
  • Stencil.tsx
  • yoga.ts, kiwi.ts
  • interactionValidation.ts

Stencils, which should be in test configs in ViewKind/ViewDescr or storybooks only:

  • rm:GeneralCompartmentNodeStencil
  • rm:PropertiesCompartmentNodeStencil
  • rm:PropertyNodeStencil
  • rm:ClassNodeStencil
  • rm:WindTurbineStencil
  • rm:HeaterStencil
  • rm:HouseStencil
  • rm:SubstationStencil
  • rm:GeneratorStencil
  1. For arrow types we need stensils-like mechanics with protoStencil = 'rm:EdgeStencil'. Arrow stencil palette should also use registered arrow types. We should remove hardcoded custom 'lines' and move it into test configs in ViewKind/ViewDescr or storybooks only:
  • rm:AssociationArrowStencil
  • rm:InheritanceArrowStencil
  • rm:Line
  • rm:DoubleLine

Stencils panel usability improvement

Stencils problems

  • Node stencil's labels are too truncated. Its hard to see quickly what is what.
    image
  • Edge stencils didn't have labels at all. We should add it. arrow's labels should be in Russian.

Stencil panel problems

  • Stencils panel's titles should be in Russian.
  • Maybe move node stencils to "Stencils' and drop "Components" to make it more compact.
  • More compact (too much height) node stencils panel (Component panel).
    image
  • Node stencils are layouted in a giant row and truncated (see pict. below). We need some sort of panel layout (like "2 in a row' grid) and "line break" to the next row.
    image
  • Edge stencils panel's background should be the same as in Node stencils panel.

Publishing library

For ease of use, the library should be published as a package to npm.
Additional preliminary steps:

  • add license
  • add project description to readme
  • change project name to something more expressive

Reduce visual noize in Cadrs diagram

  • Too much fallback images.
    • It should appears in case of broken image link only.
    • If image link is not provided, we should not sow fallback image.
  • Too obtrusive arrows. See Ontodia arrow styles
    • Make lines thinner
    • Change line and text color to more faded one (from black to gray 1-2 tones)

Add props types and default values to the react functional components

In some stories we have errors with undefined onSelect if you try to move node. This types of errors should be detected at linting/compiling stage if we have strong typing specifications in the code.

  • Please, add typings and default values to the react functional components.
  • Please, add default empty funct to the onSelect() in GraphEditor's props.

Some code handles text editing

  • On nodes at diagram:
    • strange unintuitive switch between text editing and non-editing
    • text style and size changes and input borders appears while editing text in-place
  • On edges at stensil panel:
    • double-click on edge at stensil panel allows label editing

Some visual examples:

  1. Without editing
    image

  2. Class title editing
    image

  3. Class property editing
    image

Enforce source code formatting and style

  • Configure Prettier styles
    • Line endngs: LF Unix, not Windows CRLF.
    • Quotes: Single-quotes, not doubles
    • Indentation: two spaces, not tabs.
    • kebabKaseVariablesAndFunctions and CamelCaseInterfacesAndTypes
  • Re-format all sources
  • Configure Husky-Prettier precommit hook

History should work for roon nodes, child nodes and edges

Scenarios:

  • Single node add/delete/resize/move/edit_content
  • Single edge add/delete/move/edit_connection/edit_label
  • Multi-select (mix with root nodes, child nodes, edges) delete/move
    GUI Interfaces:
  • Toolbar buttons should
  • Hot-keys sould work (undo: Ctrl+Z, redo: Ctrl+Y)

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.