Skip to content

Commit

Permalink
adding toast and tool tip updates.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick Grato committed Jan 3, 2023
1 parent 23c41f1 commit d298dbe
Show file tree
Hide file tree
Showing 32 changed files with 804 additions and 541 deletions.
9 changes: 5 additions & 4 deletions .storybook/preview-head.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<link rel="preconnect" href="https://fonts.gstatic.com" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link
href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;700&display=swap"
rel="stylesheet"
rel="preconnect"
href="https://fonts.gstatic.com"
crossOrigin="true"
/>
<link
href="https://fonts.googleapis.com/css2?family=Inter:wght@500;600&family=Space+Grotesk:wght@700&display=swap"
href="https://fonts.googleapis.com/css2?family=Inter:wght@500;600;700&family=Space+Grotesk:wght@400;500;700&display=swap"
rel="stylesheet"
/>

Expand Down
4 changes: 2 additions & 2 deletions src/components/Avatar/Avatar.module.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@use '../../styles/boilerplate.scss'as *;
@use '../../styles/core/boilerplate.scss'as *;

.avatar {
position: relative;
Expand All @@ -16,4 +16,4 @@
text-align: center;
object-fit: cover;
}
}
}
7 changes: 3 additions & 4 deletions src/components/Badge/Badge.module.scss
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
@use '../../styles/boilerplate.scss'as *;
@use '../../styles/core/boilerplate.scss'as *;

.badge {

&_primary,
&_secondary {
@include primary-font(500);
@include font-size(14);
line-height: 18px;
text-transform: capitalize;
letter-spacing: .5px;
letter-spacing: 0.5px;
padding: 5px 12px;
border-radius: 56px;
height: 28px;
Expand All @@ -23,4 +22,4 @@
background-color: $color-interaction-secondary;
color: $color-text-subtle;
}
}
}
8 changes: 2 additions & 6 deletions src/components/Button/Button.module.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@use '../../styles/boilerplate.scss'as *;
@use '../../styles/core/boilerplate.scss'as *;

@mixin rect_button_base() {
@include primary-font(600);
Expand Down Expand Up @@ -29,7 +29,6 @@
PRIMARY BUTTONS
******************************/


/*-------------------------------
SOLID BUTTON
-------------------------------*/
Expand Down Expand Up @@ -111,8 +110,6 @@
}
}



/******************************
SECONDARY BUTTONS
******************************/
Expand Down Expand Up @@ -198,7 +195,6 @@
}
}


/*-------------------------------
SIZES
-------------------------------*/
Expand All @@ -225,4 +221,4 @@
&_round {
padding: 12px;
}
}
}
2 changes: 1 addition & 1 deletion src/components/Checkbox/Checkbox.module.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@use '../../styles/boilerplate.scss'as *;
@use '../../styles/core/boilerplate.scss'as *;

.container {
@include prefix(user-select, none, webkit ms moz);
Expand Down
4 changes: 2 additions & 2 deletions src/components/CopyButton/CopyButton.module.scss
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
@use '../../styles/boilerplate.scss'as *;
@use '../../styles/core/boilerplate.scss'as *;

.success {
@include primary-font(500);
@include font-size(16);
line-height: 24px;
color: $color-text-subtle;
padding: 8px;
}
}
2 changes: 1 addition & 1 deletion src/components/Dropdown/Dropdown.module.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@use '../../styles/boilerplate.scss'as *;
@use '../../styles/core/boilerplate.scss'as *;

.dropdown_wrapper {
position: relative;
Expand Down
2 changes: 1 addition & 1 deletion src/components/Input/Input.module.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@use '../../styles/boilerplate.scss'as *;
@use '../../styles/core/boilerplate.scss'as *;

.input {
&_wrapper {
Expand Down
2 changes: 1 addition & 1 deletion src/components/ProgressBar/ProgressBar.module.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@use '../../styles/boilerplate.scss'as *;
@use '../../styles/core/boilerplate.scss'as *;

.wrapper {
width: 100%;
Expand Down
17 changes: 8 additions & 9 deletions src/components/RadioButton/RadioButton.module.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@use '../../styles/boilerplate.scss'as *;
@use '../../styles/core/boilerplate.scss'as *;
@use '../../styles/tools/functions.scss'as *;

.button {
Expand All @@ -7,7 +7,7 @@
display: flex;
align-items: center;

input[type="radio"] {
input[type='radio'] {
@include prefix(appearance, none, webkit ms moz);
background-color: $color-interaction-primary-alt;
margin: 0;
Expand All @@ -22,13 +22,12 @@
place-content: center;
}


input[type="radio"]:hover {
input[type='radio']:hover {
background-color: $color-interaction-primary-alt-hover;
}

input[type="radio"]::before {
content: "";
input[type='radio']::before {
content: '';
width: 14px;
height: 14px;
border-radius: 50%;
Expand All @@ -39,11 +38,11 @@
background-color: $color-interaction-primary-alt;
}

input[type="radio"]:checked::before {
input[type='radio']:checked::before {
transform: scale(1);
}

input[type="radio"]:focus::before {
input[type='radio']:focus::before {
box-shadow: inset 1em 1em $color-interaction-primary-hover;
}

Expand All @@ -54,4 +53,4 @@
margin-left: 16px;
}
}
}
}
2 changes: 1 addition & 1 deletion src/components/Select/Select.module.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@use '../../styles/boilerplate.scss'as *;
@use '../../styles/core/boilerplate.scss'as *;

.select {
&_wrapper {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Switch/Switch.module.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@use '../../styles/boilerplate.scss'as *;
@use '../../styles/core/boilerplate.scss'as *;

.wrapper {
display: flex;
Expand Down
2 changes: 1 addition & 1 deletion src/components/TextArea/TextArea.module.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@use '../../styles/boilerplate.scss'as *;
@use '../../styles/core/boilerplate.scss'as *;

.text_area {
&_wrapper {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Toast/Toast.module.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@use '../../styles/boilerplate.scss'as *;
@use '../../styles/core/boilerplate.scss'as *;

.top_right {
position: fixed;
Expand Down
10 changes: 5 additions & 5 deletions src/components/Toast/ToastMessage.module.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@use '../../styles/boilerplate.scss'as *;
@use '../../styles/core/boilerplate.scss'as *;

.wrapper {
position: absolute;
Expand All @@ -22,13 +22,13 @@
}

&.success {
background-color: green;
background-color: $color-semantic-success;
}
&.error {
background-color: red;
background-color: $color-semantic-critical;
}
&.warn {
background-color: #ef6500;
background-color: $color-semantic-warning;
}
&.plain {
color: $color-text-main;
Expand Down Expand Up @@ -76,5 +76,5 @@
}

.title {
@include h3;
@include heading-sm();
}
44 changes: 37 additions & 7 deletions src/components/Toast/ToastMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ const ToastMessage = ({
const progressBar = useRef<HTMLDivElement>(null);
const timeVisible = useRef<number>(0);

/**
* Init Component
*/
useEffect(() => {
setIsVisible(true);
setIsOpen(true);
Expand All @@ -52,6 +55,10 @@ const ToastMessage = ({
initInterval(timeVisible.current);
}, []);

/**
* Init intercal for countdown
* @param time number
*/
const initInterval = (time: number) => {
const interval = window.setInterval(() => {
const increment = 10;
Expand All @@ -71,28 +78,52 @@ const ToastMessage = ({
setIntervalId(interval);
};

/**
* Animate progress bar
* @param time
* @param duration
*/
const animateProgress = (time: number, duration: number) => {
progressBar.current?.style.setProperty(
'--progress',
String(1 - time / duration)
);
};

/**
* Mouse Enter
*/
const handleMouseEnter = () => {
if (!pauseOnHover) return;
if (!pauseOnHover || !autoClose) return;
clearInterval(intervalId);
};

/**
* Mouse Leave
*/
const handleMouseLeave = () => {
if (!pauseOnHover) return;
if (!pauseOnHover || !autoClose) return;
initInterval(timeVisible.current);
};

/**
* On Close
*/
const handleClose = useCallback(() => {
setIsOpen(false);
clearInterval(intervalId);
}, []);

/**
* Handle CTA action click
*/
const handleAction = useCallback(() => {
typeof callback === 'function' && callback();
}, []);

/**
* On fade out complete
*/
const handleOnComplete = useCallback(() => {
if (!isOpen) {
setIsVisible(false);
Expand All @@ -101,10 +132,9 @@ const ToastMessage = ({
}
}, [isOpen]);

const handleAction = useCallback(() => {
typeof callback === 'function' && callback();
}, []);

/**
* Get button category
*/
const ButtonCategory = (): ButtonCategoriesE => {
let category = ButtonCategoriesE.SECONDARY_CLEAR;
if (type === ToastTypesE.PLAIN) {
Expand All @@ -130,7 +160,7 @@ const ToastMessage = ({
category={ButtonCategory()}
/>
<div className={styles.header}>
{icon && <Icon name={icon} size={18} />}
{icon && <Icon name={icon} size={20} />}
<div className={styles.title}>{title}</div>
</div>
<p>{description}</p>
Expand Down
Loading

0 comments on commit d298dbe

Please sign in to comment.