Skip to content

Commit

Permalink
margin between toast button & give access to toast types (#169)
Browse files Browse the repository at this point in the history
* give access to toast types

* fix: toast button display
feature: support on receive class name prop and give access to toast type constants

* chore: undo story change

* chore: bump version
  • Loading branch information
Hadas Farhi authored Jul 20, 2021
1 parent b3a33b2 commit b8cd20f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
9 changes: 6 additions & 3 deletions src/components/Toast/Toast.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@ const getIcon = (type, icon) => {
/>
) : null;
};

const Toast = ({ open, autoHideDuration, type, icon, hideIcon, action, children, closeable, onClose }) => {
const classNames = useMemo(() => cx("monday-style-toast", `monday-style-toast--type-${type}`), [type]);
const Toast = ({ open, autoHideDuration, type, icon, hideIcon, action, children, closeable, onClose, className }) => {
const classNames = useMemo(() => cx("monday-style-toast", `monday-style-toast--type-${type}`, className), [type]);
const handleClose = useCallback(() => {
if (onClose) {
onClose();
Expand Down Expand Up @@ -95,8 +94,11 @@ const Toast = ({ open, autoHideDuration, type, icon, hideIcon, action, children,
);
};

Toast.types = TOAST_TYPES;

Toast.propTypes = {
/** If true, Toast is open (visible) */
className: PropTypes.string,
open: PropTypes.bool,
type: PropTypes.oneOf([TOAST_TYPES.NORMAL, TOAST_TYPES.POSITIVE, TOAST_TYPES.NEGATIVE]),
/** Possible to override the dafult icon */
Expand All @@ -116,6 +118,7 @@ Toast.propTypes = {

Toast.defaultProps = {
type: TOAST_TYPES.NORMAL,
className: "",
open: false,
action: null,
hideIcon: false,
Expand Down
1 change: 1 addition & 0 deletions src/components/Toast/Toast.scss
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

&-action {
padding-right: $spacing-small;
margin-left: $spacing-large;
}

&--type {
Expand Down
15 changes: 7 additions & 8 deletions src/components/Toast/__stories__/toast.stories.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import { useState } from "react";
import React, { useMemo, useState } from "react";
import { number, select, boolean } from "@storybook/addon-knobs";
import { TOAST_TYPES } from "../ToastConstants";
import Toast from "../Toast";
import Button from "../../Button/Button";
import Icon from "../../Icon/Icon";
import Send from "../../Icon/Icons/components/Send";
import { StoryStateColumn, StoryStateRow } from "../../storybook-helpers";

export const Toasts = () => {
export const Sandbox = () => {
const sendIconElement = (
<Icon iconType={Icon.type.SVG} clickable={false} icon={Send} iconSize="20px" ignoreFocusStyle />
);

const knobs = {
type: select("type", {
Normal: TOAST_TYPES.NORMAL,
Positive: TOAST_TYPES.POSITIVE,
Negative: TOAST_TYPES.NEGATIVE
Normal: Toast.types.NORMAL,
Positive: Toast.types.POSITIVE,
Negative: Toast.types.NEGATIVE
}),
closeable: boolean("closeable", true),
autoHideDuration: number("autoHideDuration", 0),
Expand Down Expand Up @@ -52,14 +52,13 @@ export const Toasts = () => {
autoHideDuration={knobs.autoHideDuration}
hideIcon={knobs.hideIcon}
>
Something Happened
Something Happened!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
</Toast>
</StoryStateColumn>
</StoryStateRow>
</section>
);
};

export default {
title: "Components|Toast",
component: Toast
Expand Down

0 comments on commit b8cd20f

Please sign in to comment.