GithubHelp home page GithubHelp logo

automattic / dops-components Goto Github PK

View Code? Open in Web Editor NEW
9.0 92.0 6.0 3.16 MB

Shared Calypso-style components for non-Calypso projects.

License: GNU General Public License v2.0

JavaScript 75.66% CSS 23.94% HTML 0.31% Makefile 0.09%

dops-components's Introduction

DOPS Components

Shared components for DOPS projects

Developing

To launch a development server:

gulp

Then open http://localhost:8085/demo.html in your browser. Any changes you make to SCSS or JS/JSX files should be updated as your save.

If you wish to compile a bundle (which shouldn't be something you do in this package, but I'll indulge you), you can run:

gulp webpack:build-dev

You can use that build script from the gulpfile as an example when developing your own JS projects which use dops-components.

Using DOPS Components in your project

Installing

npm install automattic/dops-components --save-dev

Using components

You'll need to require them using a full path from the module name, e.g.:

AbTest = require('@automattic/dops-components/client/components/tracks-ab-test');

Developing against a live checkout

It's handy to link the checked-out dops-components code directly into your project. You can do that as follows.

In the dops-components directory:

npm link

In the directory of a project that uses dops-components:

npm link @automattic/dops-components

Assuming you use webpack in your project, you'll want to add the paths for compiling JSX to your JSX loader, like this:

{
	test: /\.jsx?$/,
	loaders: jsLoader,

	// include both typical npm-linked locations and default module locations to handle both cases
	include: [
		path.join(__dirname, 'client'), 
		path.join(__dirname, '../dops-components/client'), 
		path.join(__dirname, 'node_modules/@automattic/dops-components/client')
	]
}

Note: the above snippet assumes your project is checked out in the same directory as dops-components. Also note that we need 2 entries because of weirdness that webpack currently has following symlinks when hot-loading.

Usage

Requires a functioning browserify or webpack environment.

A/B test example

var React = require('react'),
	PwywSlider = require('pwyw-slider'),
	AbTest = require('@automattic/dops-components/client/components/tracks-ab-test');

var MyComponent = React.createClass({
	//... other things ...
	render: function() {
		return (
			<div>
				<AbTest.Experiment name="slider">
					<AbTest.Variant name="normal">
						<PwywSlider value={this.state.value} defaultValue={this.props.defaultQty} onChange={this.handlePwywChange} interval={this.props.interval}/>
					</AbTest.Variant>
					<AbTest.Variant name="skip6">
						<PwywSlider value={this.state.value} defaultValue={this.props.defaultQty} skipValues={[6]} onChange={this.handlePwywChange} interval={this.props.interval}/>
					</AbTest.Variant>
				</AbTest.Experiment>
			</div>
		);
	}
});

module.exports = MyComponent;

dops-components's People

Contributors

dereksmart avatar eliorivero avatar eoigal avatar gravityrail avatar gziolo avatar jeffgolenski avatar michaelarestad avatar oskosk avatar retrofox avatar ryelle avatar samhotchkiss avatar sirreal avatar tug avatar zinigor avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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

dops-components's Issues

Modal: replace deprecated usage of getDOMNode

When the Modal is launched the following warning is logged in JS console:

Warning: Modal.getDOMNode(...) is deprecated. Please use ReactDOM.findDOMNode(instance) instead.

the line is in the file dops-components/client/components/modal/index.jsx

focusTrap.activate(this.getDOMNode(), {

Compiling errors?

I tried this out today and didn't get very far.

After cloning the repo. I did the following
npm install
gulp

And then run into the following errors

WARNING in ./~/payment/lib/payment.js
Critical dependencies:
1:459-466 This seems to be a pre-built javascript file. Though this is possible, it's not recommended. Try to require the original source to get better results.
 @ ./~/payment/lib/payment.js 1:459-466

ERROR in ./client/components/modal/index.jsx

/Users/enej/Code/dops-components/client/components/modal/index.jsx
  66:32  error  Strings must use singlequote  quotes

✖ 1 problem (1 error, 0 warnings)

ERROR in ./client/components/my-sites-navigation/current-site/index.jsx

/Users/enej/Code/dops-components/client/components/my-sites-navigation/current-site/index.jsx
  50:7  error  ':' should be placed at the end of the line  operator-linebreak
  64:6  error  ':' should be placed at the end of the line  operator-linebreak

✖ 2 problems (2 errors, 0 warnings)

ERROR in ./client/components/my-sites-navigation/site-icon/index.jsx

/Users/enej/Code/dops-components/client/components/my-sites-navigation/site-icon/index.jsx
  74:6  error  Bad line breaking before and after ':'  operator-linebreak

✖ 1 problem (1 error, 0 warnings)

http://localhost:8085/demo.html gave me a a white screen.

Did I miss a step?

Move credit card components out of this repo

I think this repo should just be for presentational components, but because it's trying to handle a credit card UI, we've also added libraries for wp.com API support (which are outdated now), store transactions, etc. I think these would be easier to keep up-to-date in the context of their own projects.

It looks like the only place we're using the credit card component is in Akismet, so my suggestion is to move it and all the extras out of this repo, into that one. This would include:

  • components/payment
  • lib/credit-card-details
  • lib/paygate-loader
  • lib/store-transactions
  • lib/stored-cards
  • lib/wp
  • lib/wpcom-undocumented

I just wanted to start a discussion about whether this is worthwhile, if other projects are using the credit card functionality... let me know 😄

Sass build fails on node-sass ^3.7

If I try to use dops-components in a project where node-sass is of version 3.7 and higher I get the following error message on build:

Message:
    Module build failed: 
%dashicon {
^
      You may not @extend an outer selector from within @media.
You may only @extend selectors within the same directive.
From "@extend %dashicon" on line 34 of stdin

      in /jetpack/node_modules/@automattic/dops-components/client/scss/extends.scss (line 15, column 1)

I was wondering if there's an easy fix for this? This is going to be a blocker if we decide to move to Node 6.x. cc @jeffgolenski @MichaelArestad

Main Readme should mention Devdocs/Design

It took me a while to find the link to a live list of components and code samples, while that was the main thing I was interested in when coming to this repo.
Also, the Readme mentioned that not all components were present on https://wpcalypso.wordpress.com/devdocs/design but it appears that some components over there are not present in this repo. This is the case for date-picker for example. Where has it gone?
Finally, I think Calypso is a great project and deserves more pubic attention than it currently has. Maybe it would help if the Calypso docs were more developer friendly: having two separate section for code-samples/documentation and live example is frustrating. You could take inspiration from a successful project such as http://react-toolbox.com

Anyway, keep up the good work!

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.