Skip to content

Commit

Permalink
exposing core types
Browse files Browse the repository at this point in the history
  • Loading branch information
Luccasoli committed Aug 31, 2021
1 parent 63b5419 commit 70dbbb2
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 19 deletions.
22 changes: 3 additions & 19 deletions src/components/toaster.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
import { css, setup } from 'goober';
import * as React from 'react';
import { setup, css } from 'goober';

import { resolveValue, ToasterProps, ToastPosition } from '../core/types';
import { useToaster } from '../core/use-toaster';
import { ToastBar } from './toast-bar';
import {
ToastPosition,
DefaultToastOptions,
Toast,
resolveValue,
} from '../core/types';
import { createRectRef, prefersReducedMotion } from '../core/utils';
import { ToastBar } from './toast-bar';

setup(React.createElement);

Expand Down Expand Up @@ -49,16 +43,6 @@ const activeClass = css`
}
`;

interface ToasterProps {
position?: ToastPosition;
toastOptions?: DefaultToastOptions;
reverseOrder?: boolean;
gutter?: number;
containerStyle?: React.CSSProperties;
containerClassName?: string;
children?: (toast: Toast) => JSX.Element;
}

const DEFAULT_OFFSET = 16;

export const Toaster: React.FC<ToasterProps> = ({
Expand Down
10 changes: 10 additions & 0 deletions src/core/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,13 @@ export type DefaultToastOptions = ToastOptions &
{
[key in ToastType]?: ToastOptions;
};

export interface ToasterProps {
position?: ToastPosition;
toastOptions?: DefaultToastOptions;
reverseOrder?: boolean;
gutter?: number;
containerStyle?: React.CSSProperties;
containerClassName?: string;
children?: (toast: Toast) => JSX.Element;
}
14 changes: 14 additions & 0 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ import {
ToastOptions as _ToastOptions,
ToastPosition as _ToastPosition,
Toast as _Toast,
Renderable as _Renderable,
ValueOrFunction as _ValueOrFunction,
ToasterProps as _ToasterProps,
DefaultToastOptions as _DefaultToastOptions,
IconTheme as _IconTheme,
ToastType as _ToastType,
ValueFunction as _ValueFunction,
} from './core/types';
export { useToaster } from './core/use-toaster';
export { ToastBar } from './components/toast-bar';
Expand All @@ -19,6 +26,13 @@ export { resolveValue } from './core/types';
export type ToastOptions = _ToastOptions;
export type ToastPosition = _ToastPosition;
export type Toast = _Toast;
export type Renderable = _Renderable;
export type ValueOrFunction<TValue, TArg> = _ValueOrFunction<TValue, TArg>;
export type ToasterProps = _ToasterProps;
export type DefaultToastOptions = _DefaultToastOptions;
export type IconTheme = _IconTheme;
export type ToastType = _ToastType;
export type ValueFunction<TArg, TValue> = _ValueFunction<TArg, TValue>;

export { toast };
export default toast;

0 comments on commit 70dbbb2

Please sign in to comment.