Skip to content

Commit

Permalink
Merge pull request #1 in FFE/ffe-accordion-react from master_v1.0.0 t…
Browse files Browse the repository at this point in the history
…o master

* commit 'b8b176c7e6d262bdcf519be8d15d6b79cdac82cc':
  v1.0.0 of ffe-accordion-react
  • Loading branch information
Erik Wendel committed Jun 9, 2016
2 parents 2049fff + 778f039 commit 6443388
Show file tree
Hide file tree
Showing 18 changed files with 744 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"presets": [
"es2015",
"react"
],
"plugins": [
'transform-object-rest-spread'
]
}
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
root = true

[*]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.js]
indent_style = space
indent_size = 4

[package.json]
indent_style = space
indent_size = 2
29 changes: 29 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"env": {
"es6": true,
"browser": true,
"node": true
},
"extends": "eslint-config-ffe",
"parserOptions": {
sourceType: "module",
"ecmaFeatures": {
"jsx": true
}
},
"plugins": [
"react",
"jsx-a11y"
],

"globals": {
"describe": true,
"it": true
},
"rules": {
"react/prefer-es6-class": 0,
"curly": 0,
"no-script-url": 0,
"react/require-render-return": 0
}
}
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* text=auto
*.js text eol=lf
39 changes: 39 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/lib
# Created by https://www.gitignore.io/api/node

### Node ###
# Logs
logs
*.log
npm-debug.log*

# Runtime data
pids
*.pid
*.seed

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directory
node_modules

# Optional npm cache directory
.npm

# Optional REPL history
.node_repl_history

example.html
Empty file added .npmignore
Empty file.
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
git-tag-version=false
61 changes: 61 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# ffe-accordion-react

## Install

```
$ npm install --save ffe-accordion-react
```

## Example

```javascript
import { WhiteAccordion, AccordionItem } from 'ffe-accordion-react';

<WhiteAccordion>
<AccordionItem expandedContent="Some more content, only shown when expanded">
Some header text, always visible.
</AccordionItem>
</WhiteAccordion>
```

## API

#### `Accordion`

* `children` (AccordionItem)

The AccordionItems contained by the Accordion.

#### `AccordionItem`

* `children` (renderable - string | component | array of components)

The accordion header content. May be a simple string or a more complex construction of components.

* `expandedContent` (renderable - string | component | array of components)

The content shown when the accordion is expanded. May be a simple string or a more complex construction of components.

* `isOpen` (boolean)

Enables you to override whether an item is open by default

* `ignoredNodeNames` (array of strings)

Some scenarios might involve having a form element (e.g a checkbox) inside the accordion item. In these cases you don't want a click event on the checkbox to propagate to the underlying element and thus cause the accordion to expand. Avoid this by passing the HTML node names you want to ignore clicks on (e.g. ['INPUT', 'LABEL'])

## Test

# Local

Use npm linking to test local changes in your own project

```
sudo npm link
```

and in your own project:

```
npm link ffe-accordion-react
```
5 changes: 5 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash -e

npm install
npm test
npm run lint
3 changes: 3 additions & 0 deletions docs/create.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Documentation from './docs';

console.log(Documentation);
264 changes: 264 additions & 0 deletions docs/docs.js

Large diffs are not rendered by default.

39 changes: 39 additions & 0 deletions docs/example-component.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import React from 'react';
import { WhiteAccordion, BlueAccordion, AccordionItem } from '../lib';

const items = [<AccordionItem
key={ Math.random() }
expandedContent="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.">
What is Lorem Ipsum?
</AccordionItem>,

<AccordionItem
key={ Math.random() }
expandedContent="It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).">
Why do we use it?

</AccordionItem>,

<AccordionItem
key={ Math.random() }
expandedContent="It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).">
Where does it come from?

</AccordionItem>,

<AccordionItem
key={ Math.random() }
expandedContent="It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).">
Where can I get some?

</AccordionItem>];

export const whiteAccordion = <WhiteAccordion>
{ items }
</WhiteAccordion>;

export const blueAccordion = <BlueAccordion>
{ items }
</BlueAccordion>;

export default whiteAccordion;
42 changes: 42 additions & 0 deletions flow.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash

# Makes functions inherit trap ERR
set -E


trap 'executionFailed ${LINENO}' ERR

function main() {
./build.sh

if should_publish; then
npm run has-published -s || npm publish
bob ci job build --jobname ffe-design-system_build_deploy
fi
}

function should_publish() {
[[ $GIT_BRANCH =~ ^(origin/)?master$ ]]
}

# Fail the build if someone tries to send it parameters since script doesn't handle params at the moment.
if [ $# -ne 0 ] ; then
echo "Failed the build. flow.sh does not support input parameters. Input parameters were '$@'"
exit 1;
fi

function executionFailed() {
# Called when some command fail execution
local self=$(basename "$0")
local parent_lineno="$1"
local message="$2"
local resultCode="${3:-1}"
if [[ -n "$message" ]]; then
echo "${self}: Error on or near line ${parent_lineno}: ${message}; exiting with status ${resultCode}"
else
echo "${self}: Error on or near line ${parent_lineno}; exiting with status ${resultCode}"
fi
exit "${resultCode}"
}

main
64 changes: 64 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
"name": "ffe-accordion-react",
"version": "1.0.0",
"main": "lib/index.js",
"scripts": {
"build": "babel -d lib/. --ignore=*.test.js src/. && npm run example",
"watch": "onchange 'src/**.js' -- npm run build",
"lint": "eslint src/.",
"test:nsp": "nsp check",
"test:spec": "mocha --require babel-register src/**/*.test.js",
"test": "npm run test:spec && npm run test:nsp",
"tdd": "mocha --require babel-register src/**/*.test.js -w",
"example": "babel-node docs/create.js > example.html",
"prepublish": "npm run build",
"has-published": "npm show . versions -s | grep -q ${npm_package_version}"
},
"peerDependencies": {
"react": "^15.0.0",
"ffe-core": "*"
},
"devDependencies": {
"babel-cli": "^6.4.5",
"babel-core": "^6.5.2",
"babel-plugin-transform-object-rest-spread": "^6.5.0",
"babel-preset-es2015": "^6.3.13",
"babel-preset-react": "^6.5.0",
"babel-register": "^6.4.3",
"chai": "^3.5.0",
"enzyme": "^2.0.0",
"eslint": "^2.9.0",
"eslint-config-ffe": "^2.0.0",
"eslint-plugin-jsx-a11y": "1.2.2",
"mocha": "^2.4.5",
"nsp": "^2.2.0",
"onchange": "2.4.0",
"react-addons-test-utils": "^15.0.0",
"react-dom": "^15.0.0"
},
"publishConfig": {
"registry": "***REMOVED***"
},
"files": [
"lib",
"example.html",
"*.js"
],
"eslintConfig": {
"extends": "eslint-config-ffe"
},
"repository": "",
"author": "SpareBank1",
"license": "",
"babel": {
"presets": [
"react",
"es2015"
]
},
"dependencies": {
"classnames": "2.2.5",
"ffe-expandable-react": "0.0.0",
"ffe-icons-react": "0.4.1"
}
}
Loading

0 comments on commit 6443388

Please sign in to comment.