Skip to content

Commit

Permalink
Merge branch 'release/0.0.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamie Halvorson committed Jul 17, 2018
2 parents 0dca739 + a155bc5 commit 3fb4ee3
Show file tree
Hide file tree
Showing 20 changed files with 365 additions and 172 deletions.
11 changes: 0 additions & 11 deletions .flowconfig

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ dist
node_modules
npm-debug.*
build
.DS_Store
18 changes: 0 additions & 18 deletions .storybook/webpack.config.js

This file was deleted.

4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Changelog

## [0.0.3] - 17-07-18
- Public release of the tabs component, includes the `<Tabs>` and `<Tab>` with initial API.
73 changes: 73 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Contributor Covenant Code of Conduct

## Our Pledge

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment
include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.

## Scope

This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at engineering@cellosignal.com. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html

[homepage]: https://www.contributor-covenant.org
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# Contributing
# Contributing
7 changes: 7 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright 2018 CELLO SIGNAL LIMITED

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
36 changes: 23 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
![React Accessible Tabs by Signal](images/readme-header.jpg)

**Project to be moved to GitHub**

| Maintained by |
|-----------------|
| Jamie Halvorson |

Declaritive, accessible tabs in React that collapse into accordions on mobile.

This component uses the Context API, therefore there is a minimum requirement of **React 16.3**.
Expand All @@ -17,30 +11,46 @@ This component uses the Context API, therefore there is a minimum requirement of
## Usage

```javascript
export default function myComponent() {
const AwesomeTabs = () => {
return (
<Tabs>
<Tab title="Tab One">
<h1>Ain't this tidy?</h1>
<p>I'm more text</p>
</Tab>
<Tab>
<Tab title="Tab Two">
<SomeOtherComponent />
</Tab>
<Tabs>
);
}
```

## API
There are a number of options available for targeting styles and providing data to the components.

| Prop | Component | Description |
|------|-----------|-------------|
| `className` | `<Tabs>` | Add your classNames for styling, this adds it at the **top** level |
| `contentClassName` | `<Tabs>` | className for wrapping your content |
| `className` | `<Tab>` | className to add to **each** tab |
| `activeClassName` | `<Tab>` | className added to the active tab |
| `title` | `<Tab>` | *String*, the title of the Tab |
| `toggleClassName` | `<Tabs>` | className added to the button, only on **mobile** |
| `mobileBreakpoint` | `<Tabs>` | Mobile breakpoint in `px` |
| `tabListClassName` | `<Tabs>` | className added to the tab list |

## Development

We use storybook for component development, to get up and running follow these steps:

1. Clone the repository, `cd` into the root and run `npm install`
2. Open two terminal windows, in the first window:
3. cd into the root of the project run `npm run dev`, this will start webpack
4. In the second window, `cd` into the project and run `npm run storybook`

- 1\. Clone the repository, `cd` into the root and run `npm install`
- 2\. Open two terminal windows, in the first window:
- 3\. cd into the root of the project run `npm run dev`, this will start webpack
- 4\. In the second window, `cd` into the project and run `npm run storybook`
- 5\. If you have a project that you are developing locally you should `npm link` this package, to do this you need to:
- 5.1\. In your terminal, `cd` into this project and run `npm link`
- 5.2\. In your terminal, `cd` into your **application** and run `npm link @cellosignal/react-tabs`

## Contributing

Expand Down
33 changes: 33 additions & 0 deletions examples/simple.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import React, { PureComponent } from 'react';
import { Tab, Tabs } from '@cellosignal/react-tabs';

export default class SimpleExample extends PureComponent {
render() {
// Dummy content
const examples = [
{
title: 'This is an example',
content: 'This is the content of the first tab'
},
{
title: 'This is the second one',
content: 'This is more exciting content'
}
];

return (
<section>
<Tabs className="my-tabs" contentClassName="my-tabs__content" toggleClassName="my-tabs__toggle" tabListClassName="my-tabs__tablist" iconColor="#26EDC1">
{
// Map over each tab, however, you could write them individually as well
examples.map(example => (
<Tab title={example.title} className="my-tabs__tab" activeClassName="my-tabs__tab--active">
<p>{example.content}</p>
</Tab>
))
}
</Tabs>
</section>
);
}
}
Binary file modified images/example.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/readme-header.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 3 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
{
"name": "@cellosignal/react-tabs",
"version": "0.0.1",
"version": "0.0.3",
"description": "Acessible react tabs that collapse into an accordion on mobile",
"publishConfig": {
"registry": "http://npm.i.blonde.net:4873/"
},
"main": "index.js",
"scripts": {
"test": "jest",
"dev": "webpack --watch",
"build": "webpack -p",
"storybook": "start-storybook -p 6006",
"build-storybook": "build-storybook",
"flow": "flow"
"build-storybook": "build-storybook"
},
"keywords": [
"React",
Expand Down Expand Up @@ -42,12 +38,10 @@
"babel-preset-react": "^6.24.1",
"babel-preset-stage-0": "^6.24.1",
"babel-root-slash-import": "^1.1.0",
"flow-bin": "^0.70.0",
"flow-webpack-plugin": "^1.2.0",
"jest": "^22.4.2",
"react-dom": "^16.3.2",
"webpack": "^3.11.0",
"webpack-cli": "^2.0.10",
"webpack-merge": "^4.1.2"
}
}
}
7 changes: 7 additions & 0 deletions src/assets/close-icon.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import React from 'react';

export default ({ color = '#000000' }) => (
<svg xmlns="http://www.w3.org/2000/svg" width="12" height="2" viewBox="0 0 12 2">
<rect width="10.303" height="1.472" y="4.416" fill={color} fillRule="evenodd" transform="translate(.848 -3.937)" />
</svg>
);
11 changes: 11 additions & 0 deletions src/assets/open-icon.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React from 'react';

export default ({ color = '#000000' }) => (
<svg xmlns="http://www.w3.org/2000/svg" width="12" height="11" viewBox="0 0 12 11">
<g fill={color} fillRule="evenodd" transform="rotate(45 5.5 6.207)">
<rect width="10.303" height="1.472" y="4.416" transform="rotate(-45 5.152 5.152)" />
<rect width="10.303" height="1.472" y="4.416" transform="rotate(45 5.152 5.152)" />
</g>
</svg>
);

17 changes: 10 additions & 7 deletions src/components/tab/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { Component } from 'react';
import { func, number } from 'prop-types';
import { func, number, string } from 'prop-types';

export default class Tab extends Component {
static defaultStyles = {
Expand All @@ -17,8 +17,8 @@ export default class Tab extends Component {

return (
<li
style={{...Tab.defaultStyles.tab, ...isActive && Tab.defaultStyles.active, ...this.props.style}}
className={['sig-tab', isActive ? 'sig-tab__active' : '', this.props.className || ''].join(' ')}
style={{ ...Tab.defaultStyles.tab, ...isActive && Tab.defaultStyles.active, ...this.props.style }}
className={['sig-tab', isActive ? ['sig-tab__active', this.props.activeClassName || ""].join(' ') : '', this.props.className || ''].join(' ')}
role="presentation"
>
<a
Expand All @@ -27,17 +27,20 @@ export default class Tab extends Component {
href="#"
onKeyDown={e => this.props.handleKeyPress(e)}
tabIndex={!isActive ? "-1" : "0"}
role="tab"
aria-controls={`sigTabs${tabIndex}`}
id={`sigTabsTitle${tabIndex}`}
>
{title}
{title}
</a>
</li>
);
}
}

Tab.propTypes = {
onClick: func.isRequired,
title: func.isRequired,
tabIndex: number.isRequired,
onClick: func,
title: string,
tabIndex: number,
};

Loading

0 comments on commit 3fb4ee3

Please sign in to comment.