Giter Site home page Giter Site logo

visual-stack's Introduction

CJ Affiliate Visual Stack

Build Status

This package includes a set of React components with a consistent visual style that can be consumed in other React applications. The components are unbiased and generally stateless, composed primarily of visual styles rather than functionality.

Installation

$ npm install --save @cjdev/visual-stack bootstrap-loader bootstrap-sass

Usage

This package includes both a set of components and a global stylesheet composed of global styles. To include the global styles, require the @cjdev/visual-stack/lib/global module, or add it as a webpack entry point or similar.

The individual components are provided under the @cjdev/visual-stack/lib/components/ path. It may be worthwhile to add a shorter alias for this require path to keep imports short.

Example

import React from 'react';
import ReactDOM from 'react-dom';

import '@cjdev/visual-stack/lib/global';

import { Button } from '@cjdev/visual-stack/lib/components/Button';
import { Panel, Body } from '@cjdev/visual-stack/lib/components/Panel';

ReactDOM.render(
  <Panel>
    <Body>
      <h1>Hello, world!</h1>
      <Button type="primary" onClick={() => console.log('clicked!')}>Click Me</Button>
    </Body>
  </Panel>,
  document.getElementById('application')
);

Version 1.0 Breaking Changes

Various components have been updated to increase their functionality, however upgrading to 1.0 will break existing layout and usage of certain components.

Components

SideNav
  • Link Names must now be wrapped in <span> tags to give them the correct styling
  • SideNavIcon can now take an extra prop 'letter', which will create an Icon with the letter passed into it
import { SideNav, Link as SideNavLink, LinkGroup, SideNavIcon } from '@cjdev/visual-stack-redux/lib/components/SideNav';

ReactDOM.render(
    <SideNav>
        <LinkGroup label="Something" icon={<SideNavIcon type="square" />} >
            <SideNavLink>
                <WhateverRoutingWrapperYouWantToUse>
                    <SideNavIcon type="circle" />
                    <span>Link Name</span> // Link Names need to be wrapped in a span to
                                           // give it the correct styling
                </WhateverRoutingWrapperYouWantToUse>
            </SideNavLink>
            <SideNavLink>
                <WhateverRoutingWrapperYouWantToUse>
                    <span>Link Name</span> // If no Icon is given, the default will be the
                                           // first letter of the link name will be used to
                                           // make an icon
                </WhateverRoutingWrapperYouWantToUse>
            </SideNavLink>
        </LinkGroup>
        <SideNavLink>
            <WhateverRoutingWrapperYouWantToUse>
                <SideNavIcon type="circle" />
                <span>Link Name</span>
            </WhateverRoutingWrapperYouWantToUse>
        </SideNavLink>
    </SideNav>
)
Application Layout
  • Now has a redux component, which should be used if with the Redux SideNav. This will allow for your page container to resize correctly when the SideNav is collapsed.
// example code below is for use of the redux Applcation Layout (default export),
// which is the suggested use if redux SideNav is also used
import Layout from '@cjdev/visual-stack-redux/lib/layouts/ApplicationLayout';
import { SideNav } from '@cjdev/visual-stack-redux/lib/components/SideNav';

const AppLayout = ({children}) =>
    <Layout
        topNav={<TopNav appName="My Awesome App" logo={<CJLogo/>} />}
        sideNav={<SideNav></SideNav>}
        >
        {children}
    </Layout>

Contributing

See the CONTRIBUTING.md file.

Publishing

To publish, you must have lerna installed globally npm install lerna -g

Publish steps:

  • Update CHANGELOG.md with notes and version number
  • Push/merge into master
  • lerna publish

visual-stack's People

Contributors

nicolasfont avatar nedda avatar lexi-lambda avatar dependabot[bot] avatar fhwrdh avatar joshhidley avatar afarcilla avatar khoberg avatar dchongatcjdotcom avatar fiddlerwoaroof avatar kadinvanvalin avatar jeffrocan avatar huoshengdi avatar zhuochengyu avatar murradha avatar emartinezcj avatar finalfantasia avatar anthonybrice avatar evilches-cj avatar lennongrinta avatar mkflagstad avatar markw avatar tylerhekman avatar danchong avatar emmulator avatar nestoralonso avatar jackmarx avatar mirceaned avatar chrisalbright avatar nsluss avatar

Stargazers

Erik Porroa avatar Forrest Akin avatar  avatar  avatar Alec Reeves avatar  avatar  avatar  avatar Jamie Isaacs avatar Kevin Ramsunder avatar Sam avatar aigene avatar  avatar Stu Penrose avatar  avatar

Watchers

 avatar  avatar Bill Adams avatar  avatar  avatar James Cloos avatar Hitesh Lad avatar  avatar  avatar  avatar Jeegar Shah avatar  avatar  avatar  avatar Vivek Sachdeva avatar Michael Adlai Arnold avatar Cezar avatar  avatar  avatar  avatar Jeremy Simpson avatar Mark B avatar  avatar  avatar

visual-stack's Issues

Make sidenav bar mobile responsive

Current implementation of SideNav is tablet friendly, but not mobile friendly.
The collapse SideNav should be a small icon, and no full length sidebar.

New Application Layout

Create an applicate layout which incorporates the Sliding Panel as well as Side Nav and Page Content.
Please look to insights or developer portal for reference.

Restyle Nav

Updating styling for SideNav using the 8pt grid system.
Updating the transition timing so its a bit more spunky.
Make the side nav thinner, and the logo a bit more square

Warnings about invalid props on dom elements

When using visualstack (v2.5.3) + react 16, I get this warning message in the console every time I load a page with a sidebar:

[Error] Warning: React does not recognize the `sideNavState` prop on a DOM element. If you intentionally want it to appear in the DOM as a custom attribute, spell it as lowercase `sidenavstate` instead. If you accidentally passed it from a parent component, remove it from the DOM element.
    in a (created by SideNavP)
    in li (created by SideNavP)
    in ul (created by SideNavP)
    in SideNavP (created by MediaQuery)
    in MediaQuery (created by SideNav)
    in SideNav (created by InternalSideNav)
    in InternalSideNav (created by Connect(InternalSideNav))
    in Connect(InternalSideNav) (created by App)
    in div (created by ApplicationLayout)
    in div (created by ApplicationLayout)
    in div (created by ApplicationLayout)
    in ApplicationLayout (created by InternalApplicationLayout)
    in InternalApplicationLayout (created by Connect(InternalApplicationLayout))
    in Connect(InternalApplicationLayout) (created by App)
    in App (created by InjectIntl(App))
    in InjectIntl(App) (created by Connect(InjectIntl(App)))
    in Connect(InjectIntl(App)) (created by HotExportedConnect(InjectIntl(App)))
    in AppContainer (created by HotExportedConnect(InjectIntl(App)))
    in HotExportedConnect(InjectIntl(App)) (created by RouterContext)
    in RouterContext (created by Router)
    in Router
    in IntlProvider (created by LanguageProvider)
    in LanguageProvider (created by Connect(LanguageProvider))
    in Connect(LanguageProvider)
    in Provider
	printWarning (main.js:29039)
	warning (main.js:29063)
	validateProperty$1 (main.js:70246)
	warnUnknownProperties (main.js:70280)
	validateProperties$2 (main.js:70300)
	validatePropertiesInDevelopment (main.js:70351)
	setInitialProperties$1 (main.js:70577)
	finalizeInitialChildren (main.js:71668)
	completeWork (main.js:77250)
	completeUnitOfWork (main.js:78855)
	performUnitOfWork (main.js:79032)
	workLoop (main.js:79044)
	renderRoot (main.js:79084)
	performWorkOnRoot (main.js:79702)
	performWork (main.js:79624)
	performSyncWork (main.js:79596)
	requestWork (main.js:79496)
	scheduleWork$1 (main.js:79360)
	enqueueSetState (main.js:74441)
	setState (main.js:93913)
	(anonymous function) (main.js:90087)
	(anonymous function) (main.js:90970)
	(anonymous function) (main.js:90825)
	done (main.js:88888)
	(anonymous function) (main.js:88894)
	(anonymous function) (main.js:2637)
	(anonymous function) (main.js:2663)
	promiseReactionJob```

WCAG 2.1 Components

Clear up components and css in Visual Stack so that it passes the WCAG 2.1 standards.

SideNav Logo URL

Can we make the SideNav Logo/AppName link to the homepage? It would be great to add some introductory content.

CSS color variables

Add css color variables to visual stack, so apps consuming VS can use these colors easily.
Depending on the applications uses, maybe styled-components theme variables can work.
That or give the option to do that as well.

Components should not rely on Redux

Components with visual behaviors should manage their own state and not rely on Redux.

The side nav requires redux for its visual behavior. To use it, the application needs to configure Redux, breaking encapsulation. If the application happens to use Redux, the configuration presumes a particular way of merging state machines, further breaking encapsulation.

Specifically name spaces visual stack css

To prevent name-space collisions with other applications that use visual stack, it would be best to update our css to be name-spaced.
Adding a 'vs-' before css classes should be sufficient.

SideNav submenu links hidden due to container max-height

Section dropdowns limited to 16 menu items due to the container max-height.

Example: In Visual Stack Docs, the Components dropdown no longer shows links for the Spinner, TabLayout, and Table.

I believe the max-height was used for the sliding animation.

image

Remove font awesome

Remove all instances of font awesome, replace them with material UI icons.

SlidingPanel pushing content instead of overlaying

When the SlidingPanel Redux component changes to an "active" state, it pushes all other content to side. For example, I have the ToggleIcon in my Header but once I click it to reveal the SlidingPanel, the Header and its contents resize. The desired behavior to would be similar to the non-redux SlidingPanel where the SlidingPanel is overlayed.

image

<pre> element disables collapsing grid for mobile

Long blocks of code in the <pre> element aren't initializing a horizontal scrollbar and prevent the container from collapsing for mobile.

Example: Navigate to the Forms page in Visual Stack and resize the browser width. <pre> text overflow should scroll horizontally.

Fix Doc Styling

Update the css for JUST the documentation. This should be local to visual-stack-docs, and should not be global.

Required prop in PaginationPure is `undefined`

console.error node_modules/prop-types/checkPropTypes.js:19
  Warning: Failed prop type: The prop `paginationId` is marked as required in `PaginationPure`, but its value is `undefined`.
      in PaginationPure

TriStateCheckbox changes from indeterminate to clicked when clicked on even if value and checked are both set to -1

Background:
In a certain project, our team is using the TriStateCheckbox on a table that allows users to select a number of entries on the page. The "select all" checkbox updates its status to unchecked, indeterminate, or checked when the user selects and deselects entries on the page. The user can select the "select all" checkbox to select/deselect all entries on the page. There is a new feature in the project that limits the number of entries selectable in the app to 200 entries, so when the user tries to add more than 200 entries, the checkboxes would show the same state, and an error message would display saying limit reached.

Bug:
If the tristate checkbox is in an indeterminate state, and it is clicked, the checkbox will change from indeterminate to checked even if "value" and "checked" both stay at -1. When querying the value of the checkbox component, it will report -1, but the actual checkbox object will report both the indeterminate flag and the checked flag is toggled.

Expected behavior:
The checkbox should stay indeterminate when checked if "value" and "checked" attributes of the checkbox stays at -1.

How to reproduce the bug:

<TristateCheckbox 
  value={-1}
  checked={-1}
  onChange={() => {}}
/>

The attached PR would address the issue by always running the checkbox's _updateInnerCheckBoxState after every update. I wanted to open a discussion to see if change would affect others that are also using Visual Stack and if there's any performance implications on always running the checkbox's _updateInnerCheckBoxState. If there's a better way to refactor this too, I'd be interested as well.

Note that when rendering the component like this:

<TristateCheckbox 
  value={0}
  checked={0}
  onChange={() => {}}
/>
<TristateCheckbox 
  value={1}
  checked={1}
  onChange={() => {}}
/>

the checkbox stays unchecked or checked respectively.

Required prop in ListView is `undefined`

console.error node_modules/prop-types/checkPropTypes.js:19
  Warning: Failed prop type: The prop `renderContent` is marked as required in `ListView`, but its value is `undefined`.
      in ListView
      in Unknown (created by WrapperComponent)
      in WrapperComponent

Required prop in InternalTabLayout is `undefined`

console.error node_modules/prop-types/checkPropTypes.js:19
  Warning: Failed prop type: The prop `tabLayoutId` is marked as required in `InternalTabLayout`, but its value is `undefined`.
      in InternalTabLayout

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.