Giter VIP home page Giter VIP logo

reactivebase's Introduction

Coverage Status

Note: This library is not supported anymore. Please use the latest version of reactivesearch

Data components for building reactive UIs

The UI component library that powers Reactive Maps and Reactive Search.

How to Run

Installation

npm install
npm test

Run Examples

npm run storybook
open localhost:9009

Test Coverage

npm run coverage

Lint

npm run lint

reactivebase's People

Contributors

dhruvdutt avatar divyanshu013 avatar farhan687 avatar harsanyizoli avatar kaushik94 avatar metagrover avatar siddharthlatest avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

reactivebase's Issues

Replace sensorId with id

We can replace sensorId prop with either id or componentId.

Benefits from doing so:

  • lesser ambiguity as to what sensors are.
  • sensorId is applied to all components, irrespective of whether they are sensor or actuator components.
  • since the library name is no longer on the lines of sensor.js, we won't emphasize the concept out loud. Although it's a nice way to think about UIs and we will continue that as we build out more components.

NestedList component behavior

  • remove multipleSelect prop
  • remove includeSelectAll prop
  • remove defaultQuery prop
  • sortBy prop should accept only one of ("count", "asc", "desc") string values.
  • size prop validation: should accept numeric values between [1, 1000].
  • defaultSelected prop should be validated as an Array.
  • setting showCount prop to false should disable count from view.

ReactiveList component behavior

  • Fix height for ResultList when no results and when size is <5. (check prop changes)
  • size prop is not changing dynamically in storybook.
  • Streams results even when no filter is selected.
  • When ReactiveList hits the end of the results, the animation spinner should not appear.
  • ReactiveList's scroll should be reset when the query changes.

Debug ToggleButton Query

ResultList shows results even when no sensor filters are applied. This can be replicated by selecting one of the filters, and then unselecting it.

ResultList component behavior

  • validate from prop to be a Number >= 0.
  • validate size prop to be a Number >= 1.
  • validate sortBy prop to only accept either asc or desc values.
  • When stream is true, use css class rbc-stream-active. When false, use class rbc-stream-inactive.
  • When sortOptions prop is enabled, a rbc-sortoptions-active class will be set. When not, a rbc-sortoptions-inactive class will be set.

This is something we have talked once, but it makes sense for keeping a consistent CSS styles API as well as applying theming effects on.

  • Wrap the array of HTML elements returned by the onData function inside a div with a rbc-list-item class.

standardize selectAll prop in all applicable components.

Components to implement this in:

  • SingleList
  • MultiList
  • SingleDropdownList
  • MultiDropdownList

prop name should be selectAllLabel.

Additionally, in MultiList and MultiDropdownList, the "Select All" option should generate tags and / or checkboxes (where applicable) for all the list items.

The tag logic should replace tags if # tags > 5 with a "Clear All" tag instead.

SingleDropdownList component behavior

  • size prop should be validated to be between [1, 1000].
  • sortBy prop should be validated to be one of ("asc", "desc", "count") string values.
  • showCount prop should work.
  • no item should be selected by default.
  • placeholder prop should be implemented similar to MultiDropdownList component.
  • size and sortBy props should re-render the component in storybook playground mode.
  • When count is set, show rbc-count-active. When set to false, show rbc-count-inactive in the top level element.

Behavior of DataSearch component

  • DataSearch component should support title prop.
  • DataSearch component should not have a depends prop.
  • autocomplete prop which decides whether autocomplete is applied, defaults to true.
  • appbaseField should take either a String or an Object Array of valid fields (order not relevant).
<DataSearch 
    appbaseField={["field 1", "field 2", .. , "field n"]}
... />
  • Use regular fonts for displaying input text, no italics and placeholder style should be consistent with other components (i.e. no bold).
  • Bring outer style consistency with TextField component.

ResultList -> ReactiveList

Component rename from ResultList to ReactiveList. Similarly, PaginatedResultList will be renamed to PaginatedReactiveList.

MultiList component behavior

  • Standardize "Select All" using selectAllLabel prop. When selecting all, all the list items should be checkbox selected.
  • When count is set, show rbc-count-active. When set to false, show rbc-count-inactive in the top level element.
  • Replace searchPlaceholder prop with placeholder.
  • When list size > 5, replace the individual filter labels with a Clear All filter label.
  • Validate size prop to accept values in the range [0, 1000].
  • Validate sortBy prop to accept one of ("count", "asc", "desc") values.
  • size and sortBy props should re-render the component in storybook's playground.

use stories from npm package instead of local repo context

Replace this line in all stories:

import { ReactiveBase, DatePicker, ResultList } from '../app.js';

with a npm package. Additionally, we can configure the npm package in a way that dev branch uses the dev branch of github for the source and master branch uses the master branch of github.

behaviors in NestedList component

  • Ability to unselect (close) a nested option
  • Scroll behavior should only be applied on the list items, currently title is scrolled as well
  • Support static (i.e. local) search of items like we do in SingleList.
  • NestedList component should show updates when storybook props change.

PaginatedResultList component behavior

  • need to support sortOptions prop. When it is enabled, a rbc-sortoptions-active class will be set. When not, a rbc-sortoptions-inactive class will be set.
  • requestOnScroll prop should not be exposed to the user. It should be set to false internally.
  • componentStyle prop should be added for adding styles to the top-level component element.
  • from prop validation: should be a Number >= 0.
  • size prop validation: should be Number >= 1.
  • When user does not specify the onData callback, a default UI similar to the one in ResultList component should appear. We should add a story for this.

ToggleButton behavior quirks

  • Add a prop multiSelect which defaults to true for switch between multiple select and single select modes.
  • Show case as user inputs in the data[i].label prop field. Currently all options are shown in uppercase.
  • CSS: change class names from title-true and title-false to rbc-title-active and rbc-title-inactive.
  • CSS: add a new class state for multiSelect prop with rbc-multiselect-active and rbc-multiselect-inactive.
  • CSS: btn class in button element should be rbc namespaced.
  • CSS logic: there should be a class for button state, like btn-active. Currently, this is done with classes named as blue-grey, light-blue -> this is bad for both usability as well as when extending the components.

Create a <div> ReactiveElement actuator component

Props

  • componentId
  • title
  • react
  • placeholder
  • onData

Styles

rbc-reactiveelement
rbc-title-active / rbc-title-inactive
rbc-placeholder-active / rbc-placeholder-inactive

Compatible with light and dark themes.

Create a NumberBox component

A NumberBox UI widget is useful for travel search experience websites like Kayak, as well as in an e-commerce setting for deciding quantities of an item in the cart.

Number box use on kayak.com

Props Spec

componentId String
id of the component, referenced inside an actuator query.
appbaseField String
sets the DB field to be mapped with the UI component view.
title String [optional]
sets the title of the the component.
data Object
sets the label and associated start and end values.
labelPosition String [optional]
sets the label position, available options are "left", "right", "top", "bottom". Defaults to "left".
defaultSelected Number [optional]
sets the initial value of the NumberBox. Defaults to the start value in the data object.

CSS Styles API Spec

State Classes

  • rbc-title-active / rbc-title-inactive depending on if the title prop is set.
  • rbc-label-left / rbc-label-top / rbc-label-bottom / rbc-label-right depending on the labelPosition prop's value.

The component will use a term query behind the scenes to do an exact match on the selected value.

MultiDropdownList component behavior

  • size prop should be validated to be between [1, 1000].
  • Replace searchPlaceholder prop with placeholder.
  • sortBy prop should be validated to be one of ("asc", "desc", "count") string values.
  • showCount prop should work.
  • size and sortBy props should re-render the component in storybook playground mode.
  • When count is set, show rbc-count-active. When set to false, show rbc-count-inactive in the top level element.

Add PoweredBy component

A powered by component allows adding a powered by appbase.io logo. Examples of the images to be displayed below.

Example Dark Image

Example Light Image

Revamp data query format in sensor / actuator

The current query is passed as a prop called actuate in the actuator components. It takes in the sensor along with the operator and customQuery spec.


We will revamp the data query format to be sensor specific. Each sensor defines its own query format via the customQuery and executeQuery props.

Example Usage:

<SingleList
  ..
  customQuery={this.customQuery}
  executeQuery={true}
/>

customQuery is an optional prop for overriding the default query that the component comes with. It takes a function with one argument value that contains the sensor's current input state.

executeQuery is a boolean prop that is set by default to true. When set to false, the query is not executed when the sensor value updates.


In the actuator component, we will have a react prop which takes a dependency Object of all the sensors it depends on.

The dependency object is formed by boolean clauses: and, or, not as key values which can either have component(s) or a nested boolean clause as their value.

Example#1:

react={{
  "and": "citySensor"
}}

Example#2:

react={{
  "and": ["citySensor", "searchSensor"]
}}

Example#3:

react={{
  "and": {
    "or": "geoBoundsSensor",
    "and": "citySensor"
  }
}}

Example#4:

react={{
  "or": {
     "and": ["citySensor", "dataSensor"],
     "not": "searchSensor"
  }
}}

In theory, we can allow any level of nesting using conjunctions. This tree when parsed, should match cleanly to the boolean query in Elasticsearch Query DSL except the filter clause.

Implement PaginatedResultList component

ResultList shows list items with an infinite scroll. PaginatedResultList can allow showing items by page and can have additional props related to page properties.

RangeSlider component behavior

  • Replace startThreshold, endThreshold with a threshold object.
  • threshold prop should be validated for accepting only numeric values in it's start and end keys, and end >= start.

Showing sort options in the UI for ResultList

Showing sort options in the UI for ResultList component. We support three options:

  1. default (sort by relevance)
  2. asc (sort by ascending order of the appbaseField prop)
  3. desc (sort by descending order of the appbaseField prop)

Replace depends with actuate

depends prop can be replaced with actuate. What we are really saying here is that an actuator component's view should update when any of the underlying sensor component changes their state(s).

Benefits I see:

  • actuate is a fresh word with the right meaning and it also helps that it relates to the word actuator.
  • Depends or dependency has an associated meaning in the context of compiler / library dependencies.

Image

Create a NestedList component

A NestedList component can be useful for displaying a hierarchy of elements.

  • Need a prop spec,
  • Clear implementation obstacles,
  • Add a story,
  • Add to docs.

Example of a Nested List from material-ui.com:

SingleList component behavior

  • Standardize "Select All" using selectAllLabel prop. When selecting all, all the list items should be checkbox selected.
  • When count is set, show rbc-count-active. When set to false, show rbc-count-inactive in the top level element.
  • Replace searchPlaceholder prop with placeholder.
  • Validate size prop to accept values in the range [0, 1000].
  • Validate sortBy prop to accept one of ("count", "asc", "desc") values.
  • size and sortBy props should re-render the component in storybook's playground.

Missing props in storybook playground

Now that we have had a good set of changes in the props for individual components, we should make all the props available in the playground story for each component.

DataSearch component behavior

  • Remove the sensorInputId prop and its related codebase.
  • Component style should be consistent b/w when autocomplete is enabled and disabled.

RangeSlider freeze issue

RangeSlider's histogram query / UI freezes when the total range is in few thousands. Ideally, the range should be able to vary up to several hundreds of thousands without freezing.

ButtonGroup in `multi` mode uses a must clause

When multiple options are selected, ButtonGroup composes them under a must query, i.e. intersecting all the options. It should instead be using a should clause under the parent must clause that combines different sensor conditions.

A query from reactivemaps example with the meetupblast dataset.

{
   "query":{
      "bool":{
         "should":[
            {
               "bool":{
                  "must":[
                     {
                        "Term":{
                           "group.group_city.raw":"San Francisco"
                        }
                     },
                     [
                        {
                           "range":{
                              "guests":{
                                 "gte":0,
                                 "lte":2,
                                 "boost":2
                              }
                           }
                        },
                        {
                           "range":{
                              "guests":{
                                 "gte":2,
                                 "lte":4,
                                 "boost":2
                              }
                           }
                        },
                        {
                           "range":{
                              "guests":{
                                 "gte":4,
                                 "lte":6,
                                 "boost":2
                              }
                           }
                        }
                     ]
                  ]
               }
            }
         ],
         "minimum_should_match":1
      }
   },
   "size":100,
   "from":0
}

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.