Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge v3 into master #41

Merged
merged 9 commits into from Mar 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
@@ -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
@@ -0,0 +1 @@
import 'cypress-storybook/react';
29 changes: 29 additions & 0 deletions .storybook/main.js
@@ -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
@@ -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
@@ -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
@@ -0,0 +1,3 @@
{
"baseUrl": "http://localhost:6006"
}
6 changes: 6 additions & 0 deletions cypress/.eslintrc.json
@@ -0,0 +1,6 @@
{
"plugins": ["cypress"],
"env": {
"cypress/globals": true
}
}
5 changes: 5 additions & 0 deletions cypress/fixtures/example.json
@@ -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
@@ -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');
});
});