Skip to content

Commit

Permalink
Merge v3 into master (#41)
Browse files Browse the repository at this point in the history
* Commit new version!

* v3.0.0-2

* improve storybook

* try to fix type exports

* v3.0.0-3

* add missing warning dependency

* v3.0.0-4

* adding cypress, removing some jest tests

* update readme with directions to v2 docs

Co-authored-by: Rogin Farrer <rfarrer@Rogins-MacBook-Pro.local>
  • Loading branch information
roginfarrer and Rogin Farrer authored Mar 22, 2020
1 parent 34e296e commit add3ca7
Show file tree
Hide file tree
Showing 85 changed files with 16,061 additions and 5,565 deletions.
5 changes: 0 additions & 5 deletions .babelrc

This file was deleted.

17 changes: 0 additions & 17 deletions .eslintrc

This file was deleted.

7 changes: 3 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
*.log
.DS_Store
node_modules
.cache
dist
.docz/
.vscode/
coverage
.eslintcache
4 changes: 0 additions & 4 deletions .prettierignore

This file was deleted.

12 changes: 0 additions & 12 deletions .size-snapshot.json

This file was deleted.

1 change: 1 addition & 0 deletions .storybook/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import 'cypress-storybook/react';
29 changes: 29 additions & 0 deletions .storybook/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
module.exports = {
stories: ['../stories/**/*.stories.(ts|tsx)'],
addons: [
'@storybook/addon-actions',
'@storybook/addon-links',
'@storybook/addon-a11y',
'@storybook/addon-storysource',
],
webpackFinal: async config => {
config.module.rules.push({
test: /\.(ts|tsx)$/,
use: [
{
loader: require.resolve('ts-loader'),
options: {
transpileOnly: true,
},
},
{
loader: require.resolve('react-docgen-typescript-loader'),
},
],
});

config.resolve.extensions.push('.ts', '.tsx');

return config;
},
};
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2018 Rogin Farrer
Copyright (c) 2019-2020 Rogin Farrer

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
19 changes: 11 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
# React-Collapsed (useCollapse) 🙈
# react-collapsed (useCollapse)

A tiny (< 2kb) custom hook for creating flexible and accessible expand/collapse components in React.
A custom hook for creating flexible and accessible expand/collapse components in React.

## v3

This master branch now reflects the development of the next major release of this library. If you're looking for the latest stable source code, [head over to the v2 branch](https://github.com/roginfarrer/react-collapsed/tree/v2).

## Features

- Handles the height of animations of your elements, `auto` included!
- You control the UI - `useCollapse` provides the necessary props, you control everything else.
- Built with accessibility in mind - no need to worry if your collapse/expand component is accessible, since this takes care of it for you!
- Small footprint (< 2kb gzipped)
- No animation framework required! Simply powered by CSS animations

## Demo
Expand All @@ -17,9 +20,9 @@ A tiny (< 2kb) custom hook for creating flexible and accessible expand/collapse
## Installation

```bash
$ yarn add react-collapsed
$ yarn add react-collapsed@next
# or
$ npm i react-collapsed
$ npm i react-collapsed@next
```

## Usage
Expand All @@ -31,7 +34,7 @@ import React from 'react';
import useCollapse from 'react-collapsed';

function Demo() {
const {getCollapseProps, getToggleProps, isOpen} = useCollapse();
const { getCollapseProps, getToggleProps, isOpen } = useCollapse();

return (
<Fragment>
Expand All @@ -45,12 +48,12 @@ function Demo() {
### Control it yourself

```js
import React, {useState} from 'react';
import React, { useState } from 'react';
import useCollapse from 'react-collapsed';

function Demo() {
const [isOpen, setOpen] = useState(false);
const {getCollapseProps, getToggleProps} = useCollapse({isOpen});
const { getCollapseProps, getToggleProps } = useCollapse({ isOpen });

return (
<Fragment>
Expand Down
8 changes: 0 additions & 8 deletions about.mdx

This file was deleted.

3 changes: 3 additions & 0 deletions cypress.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"baseUrl": "http://localhost:6006"
}
6 changes: 6 additions & 0 deletions cypress/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"plugins": ["cypress"],
"env": {
"cypress/globals": true
}
}
5 changes: 5 additions & 0 deletions cypress/fixtures/example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "Using fixtures to represent data",
"email": "hello@cypress.io",
"body": "Fixtures are a great way to mock data for responses to routes"
}
49 changes: 49 additions & 0 deletions cypress/integration/example-spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import 'cypress-storybook/cypress';

describe('My First Test', function() {
it('Does not do much!', function() {
expect(true).to.equal(true);
});
});

describe('My First Test', function() {
it('Does not do much!', function() {
expect(true).to.equal(false);
});
});

describe('My First Test', function() {
it('clicks the link "type"', function() {
cy.visit('https://example.cypress.io');

cy.contains('type').click();
});
});

describe('RC', () => {
// Note the use of `before`
before(() => {
// Visit the storybook iframe page once per file
cy.visitStorybook();
});

// Note the use of `beforeEach`
beforeEach(() => {
// The first parameter is the category. This is the `title` in CSF or the value in `storiesOf`
// The second parameter is the name of the story. This is the name of the function in CSF or the value in the `add`
// This does not refresh the page, but will unmount any previous story and use the Storybook Router API to render a fresh new story
cy.loadStory('React-Collapsed', 'Uncontrolled');
});

it('toggles open and close the panel', () => {
cy.contains('Close').should('exist');
cy.contains('Open').should('not.exist');
cy.contains('In the morning').should('be.visible');

cy.contains('Close').click();

cy.contains('Close').should('not.exist');
cy.contains('Open').should('exist');
cy.contains('In the morning').should('not.be.visible');
});
});
Loading

0 comments on commit add3ca7

Please sign in to comment.