Skip to content

Commit

Permalink
Attempt to fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
timolins committed Dec 17, 2020
1 parent 72bd21b commit d5c4067
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 60 deletions.
9 changes: 2 additions & 7 deletions .github/workflows/main.yml
Expand Up @@ -2,13 +2,8 @@ name: CI
on: [push]
jobs:
build:
name: Build, lint, and test on Node ${{ matrix.node }} and ${{ matrix.os }}

runs-on: ${{ matrix.os }}
strategy:
matrix:
node: ['10.x', '12.x', '14.x']
os: [ubuntu-latest]
name: Build, lint, and test
runs-on: ubuntu-latest

steps:
- name: Checkout repo
Expand Down
17 changes: 7 additions & 10 deletions src/components/toast-bar.tsx
Expand Up @@ -11,18 +11,14 @@ import {
import { Indicator } from './indicator';
import { AnimatedIconWrapper } from './icon-wrapper';

const enterAnimation = (reverse: boolean) => `
0% {transform: translate3d(0,${
(reverse ? -1 : 1) * -80
}px,0) scale(.6); opacity:.5;}
const enterAnimation = (factor: number) => `
0% {transform: translate3d(0,${factor * -80}px,0) scale(.6); opacity:.5;}
100% {transform: translate3d(0,0,0) scale(1); opacity:1;}
`;

const exitAnimation = (reverse: boolean) => `
const exitAnimation = (factor: number) => `
0% {transform: translate3d(0,0,-1px) scale(1); opacity:1;}
100% {transform: translate3d(0,${
(reverse ? -1 : 1) * -130
}px,-1px) scale(.5); opacity:0;}
100% {transform: translate3d(0,${factor * -130}px,-1px) scale(.5); opacity:0;}
`;

const ToastBarBase = styled('div', React.forwardRef)`
Expand Down Expand Up @@ -92,15 +88,16 @@ const getAnimationStyle = (
visible: boolean
): React.CSSProperties => {
const top = position.includes('top');
const factor = top ? 1 : -1;
return visible
? {
animation: `${keyframes`${enterAnimation(
!top
factor
)}`} 0.35s cubic-bezier(.21,1.02,.73,1) forwards`,
}
: {
animation: `${keyframes`${exitAnimation(
!top
factor
)}`} 0.8s forwards cubic-bezier(.06,.71,.55,1)`,
pointerEvents: 'none',
};
Expand Down
1 change: 0 additions & 1 deletion src/core/store.ts
@@ -1,5 +1,4 @@
import { useEffect, useState } from 'react';
import { toast } from './toast';
import { Toast } from './types';

const TOAST_LIMIT = 20;
Expand Down
2 changes: 1 addition & 1 deletion src/core/use-toaster.ts
Expand Up @@ -76,7 +76,7 @@ export const useToaster = () => {
return offset;
},
}),
[toasts, visibleToasts, pausedAt]
[visibleToasts, pausedAt]
);

return {
Expand Down
10 changes: 8 additions & 2 deletions src/index.tsx
@@ -1,4 +1,10 @@
import { toast } from './core/toast';

// Type re-export workaround, to stay compatible with TS 3.7 and lower
import {
ToastOptions as _ToastOptions,
ToastPosition as _ToastPosition,
} from './core/types';
export { useToaster } from './core/use-toaster';
export { dispatch, ActionType } from './core/store';
export { ToastBar } from './components/toast-bar';
Expand All @@ -9,8 +15,8 @@ export { CheckmarkIcon } from './components/checkmark';
export { ErrorIcon } from './components/error';
export { LoaderIcon } from './components/loader';

export * from './core/toast';
export * from './core/types';
export type ToastOptions = _ToastOptions;
export type ToastPosition = _ToastPosition;

export { toast };
export default toast;
39 changes: 0 additions & 39 deletions test/toast.test.tsx
Expand Up @@ -9,43 +9,4 @@ describe('it', () => {
ReactDOM.render(<Toaster />, div);
ReactDOM.unmountComponentAtNode(div);
});
it('call all functions without crashing', () => {
const div = document.createElement('div');
toast('Hello World');
toast.success('Success');
toast.error('Success', {
duration: 2000,
});
toast.loading('loading');

toast(
<span>
I'm <b>custom</b>
</span>,
{
icon: '👏',
}
);

ReactDOM.render(<Toaster />, div);
ReactDOM.unmountComponentAtNode(div);
});
it('toast a promise', () => {
const promise = new Promise((res) => {
setTimeout(res, 1000);
});

toast.promise(
promise,
{
error: <b>ERROR</b>,
success: 'Success',
loading: 'Loading',
},
{
error: { duration: 1000 },
loading: { duration: 2000 },
}
);
});
});

0 comments on commit d5c4067

Please sign in to comment.