Skip to content

Commit

Permalink
⏪ Remove another feature
Browse files Browse the repository at this point in the history
  • Loading branch information
almond-bongbong committed May 26, 2023
1 parent c00f40d commit cec45f7
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 26 deletions.
15 changes: 4 additions & 11 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export interface ToastOptions {
position?: ToastPosition;
maxVisibleToasts?: number | null;
render?: ((message: ReactNode) => ReactNode) | null;
theme?: 'light' | 'dark';
onClick?: ClickHandler;
onClose?: () => void;
onCloseStart?: () => void;
Expand All @@ -45,13 +44,12 @@ export interface ConfigArgs
| 'position'
| 'maxVisibleToasts'
| 'render'
| 'theme'
> {}

export interface ToastProps
extends Pick<
ToastOptions,
'className' | 'clickable' | 'position' | 'render' | 'theme' | 'onClick'
'className' | 'clickable' | 'position' | 'render' | 'onClick'
> {
message: ReactNode;
isExit?: boolean;
Expand Down Expand Up @@ -90,16 +88,15 @@ const defaultOptions: Required<ConfigArgs> = {
clickClosable: false,
render: null,
maxVisibleToasts: null,
theme: 'dark',
};

const isValidPosition = (position: ToastPosition): boolean => {
const positionList = Object.values(Position);
if (!positionList.includes(position)) {
throw new Error(
`Invalid position value. Expected one of ${Object.values(Position).join(
', ',
)} but got ${position}`,
`Invalid position value. Expected one of ${Object.values(
Position,
).join(', ')} but got ${position}`,
);
}

Expand Down Expand Up @@ -181,7 +178,6 @@ const Toast = ({
position,
isExit,
render,
theme,
onClick,
}: ToastProps): ReactElement => {
const messageDOM = useRef<HTMLDivElement>(null);
Expand Down Expand Up @@ -209,7 +205,6 @@ const Toast = ({
const contentClassNames = [
styles['toast-content'],
clickable ? styles['clickable'] : '',
`toast-${theme}`,
]
.filter(Boolean)
.join(' ');
Expand Down Expand Up @@ -282,7 +277,6 @@ function renderToast(
position = defaultOptions.position,
maxVisibleToasts = defaultOptions.maxVisibleToasts,
render = defaultOptions.render,
theme = defaultOptions.theme,
onClick = undefined,
onClose = undefined,
onCloseStart = undefined,
Expand Down Expand Up @@ -318,7 +312,6 @@ function renderToast(
clickable={clickable || clickClosable}
position={position}
render={render}
theme={theme}
onClick={handleClick}
/>
),
Expand Down
17 changes: 17 additions & 0 deletions src/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,23 @@
.top-right .toast-message {
transform: translateY(-10px);
}
.toast-content {
display: inline-block;
overflow: hidden;
min-width: 290px;
padding: 12px 22px;
background: rgba(0, 0, 10, 0.8);
box-shadow: 1px 2px 5px 1px rgba(0, 0, 0, 0.2);
border-radius: 40px;
font-family: -apple-system, system-ui, BlinkMacSystemFont, 'Segoe UI', Roboto,
'Helvetica Neue', Arial, sans-serif;
color: #fff;
font-size: 16px;
text-align: center;
line-height: 1.5;
vertical-align: top;
white-space: pre-line;
}
.clickable {
cursor: pointer;
}
Expand Down
15 changes: 0 additions & 15 deletions src/theme/dark.css

This file was deleted.

Empty file removed src/theme/light.css
Empty file.

0 comments on commit cec45f7

Please sign in to comment.