Skip to content

Commit

Permalink
refactor: Repo dependency overhaul (#73)
Browse files Browse the repository at this point in the history
* minor: Repo dependency overhaul

* remove old github actions file

* add nvmrc

* add files to package.json
  • Loading branch information
roginfarrer committed Oct 3, 2021
1 parent 2e89e3d commit 62b2d58
Show file tree
Hide file tree
Showing 54 changed files with 8,115 additions and 9,663 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Release npm package

on:
push:
branches:
- main
pull_request:

jobs:
test:
name: 'CI'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 14
- name: Install Dependencies
uses: bahmutov/npm-install@v1
- name: Build
run: yarn build
- name: Lint
run: yarn lint
- name: Test
run: yarn test

release:
name: Publish to NPM
needs: test
# publish only when merged in master on original repo, not on PR
if: github.repository == 'roginfarrer/react-collapsed' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 14
- name: Install Dependencies
uses: bahmutov/npm-install@v1
- name: Build
run: yarn build
- run: npx semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
33 changes: 0 additions & 33 deletions .github/workflows/test.yml

This file was deleted.

1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
14.18.0
1 change: 0 additions & 1 deletion .storybook/config.js

This file was deleted.

43 changes: 9 additions & 34 deletions .storybook/main.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,11 @@
const webpack = require('webpack');

module.exports = {
stories: ['../stories/**/*.stories.(ts|tsx)'],
addons: [
'@storybook/addon-actions',
'@storybook/addon-links',
'@storybook/addon-a11y',
'@storybook/addon-storysource',
"stories": [
"../src/**/*.stories.mdx",
"../src/**/*.stories.@(js|jsx|ts|tsx)"
],
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');
config.plugins.push(
new webpack.DefinePlugin({
__DEV__: JSON.stringify(process.env.NODE_ENV),
})
);

return config;
},
};
"addons": [
"@storybook/addon-links",
"@storybook/addon-essentials",
"@storybook/addon-a11y"
]
}
3 changes: 0 additions & 3 deletions .storybook/preview-body.html

This file was deleted.

9 changes: 9 additions & 0 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export const parameters = {
actions: { argTypesRegex: "^on[A-Z].*" },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/,
},
},
}
26 changes: 13 additions & 13 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,44 @@

Complete rewrite using React hooks!

* Ends support for React versions < 16.8.x
* Library now exports a custom hook in lieu of a render prop component
* Adds support for unmounting the contents of the Collapse element when closed
- Ends support for React versions < 16.8.x
- Library now exports a custom hook in lieu of a render prop component
- Adds support for unmounting the contents of the Collapse element when closed

```js
import React from 'react';
import useCollapse from 'react-collapsed';
import React from 'react'
import useCollapse from 'react-collapsed'

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

return (
<>
<button {...getToggleProps()}>{isOpen ? 'Collapse' : 'Expand'}</button>
<section {...getCollapseProps()}>Collapsed content 🙈</section>
</>
);
)
}
```

# 1.0.0

Bumped to full release! :)

* `duration`, `easing`, and `delay` now support taking an object with `in` and `out` keys to configure differing in-and-out transitions
- `duration`, `easing`, and `delay` now support taking an object with `in` and `out` keys to configure differing in-and-out transitions

# 0.2.0

### Breaking Changes

* `getCollapsibleProps` => `getCollapseProps`. Renamed since it's easier to spell 😅
- `getCollapsibleProps` => `getCollapseProps`. Renamed since it's easier to spell 😅

### Other

* Slew of Flow bug fixes
* Improved documentation
- Slew of Flow bug fixes
- Improved documentation

# 0.1.3

* ESLINT wasn't working properly - fixed this
* Added `files` key to package.json to improve NPM load
- ESLINT wasn't working properly - fixed this
- Added `files` key to package.json to improve NPM load
11 changes: 5 additions & 6 deletions MIGRATION-2.x-to-3.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,15 @@ Now, you must provide a boolean or a function that returns a boolean:

```javascript
function Collapse() {
const [mountChildren, setMountChildren] = useState(false);
const [mountChildren, setMountChildren] = useState(false)
const { getToggleProps, getCollapseProps } = useCollapse({
onCollapseEnd() {
setMountChildren(false);
setMountChildren(false)
},
onExpandStart() {
setMountChildren(true);
setMountChildren(true)
},
});
})

return (
<div>
Expand All @@ -93,7 +93,6 @@ function Collapse() {
{mountChildren && <p>I will only render when expanded!</p>}
</div>
</div>
);
)
}
```

50 changes: 23 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ $ npm i react-collapsed
### Simple Usage

```js
import React from 'react';
import useCollapse from 'react-collapsed';
import React from 'react'
import useCollapse from 'react-collapsed'

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

return (
<div>
Expand All @@ -47,19 +47,19 @@ function Demo() {
</button>
<section {...getCollapseProps()}>Collapsed content 🙈</section>
</div>
);
)
}
```

### Control it yourself

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

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

return (
<div>
Expand All @@ -72,31 +72,27 @@ function Demo() {
</button>
<section {...getCollapseProps()}>Collapsed content 🙈</section>
</div>
);
)
}
```

## API

```js
const {
getCollapseProps,
getToggleProps,
isExpanded,
setExpanded,
} = useCollapse({
isExpanded: boolean,
defaultExpanded: boolean,
expandStyles: {},
collapseStyles: {},
collapsedHeight: 0,
easing: string,
duration: number,
onCollapseStart: func,
onCollapseEnd: func,
onExpandStart: func,
onExpandEnd: func,
});
const { getCollapseProps, getToggleProps, isExpanded, setExpanded } =
useCollapse({
isExpanded: boolean,
defaultExpanded: boolean,
expandStyles: {},
collapseStyles: {},
collapsedHeight: 0,
easing: string,
duration: number,
onCollapseStart: func,
onCollapseEnd: func,
onExpandStart: func,
onExpandEnd: func,
})
```

### `useCollapse` Config
Expand Down
3 changes: 0 additions & 3 deletions cypress.json

This file was deleted.

6 changes: 0 additions & 6 deletions cypress/.eslintrc.json

This file was deleted.

5 changes: 0 additions & 5 deletions cypress/fixtures/example.json

This file was deleted.

49 changes: 0 additions & 49 deletions cypress/integration/example-spec.js

This file was deleted.

Loading

0 comments on commit 62b2d58

Please sign in to comment.