-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add survey banner to Explorer (#1063)
Co-authored-by: rainandbare <[email protected]>
- Loading branch information
1 parent
cf3608f
commit a875df6
Showing
13 changed files
with
314 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export const BANNER_FEEDBACK_SURVEY_LINK = | ||
"https://airtable.com/app8fNSQ8ieIiHLOv/shrmD31azkGtSupmO"; | ||
export const BOTTOM_BANNER_SURVEY_LINK_TEXT = "quick survey."; | ||
export const BOTTOM_BANNER_SURVEY_TEXT = "Send us feedback with this"; | ||
export const BOTTOM_BANNER_LAST_CLOSED_TIME_KEY = "bottomBannerLastClosedTime"; | ||
export const BOTTOM_BANNER_EXPIRATION_TIME_MS = 30 * 24 * 60 * 60 * 1000; // 30 days | ||
// export const BOTTOM_BANNER_EXPIRATION_TIME_MS = 30 * 1000; // 30 seconds |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import React, { memo } from "react"; | ||
import { connect } from "react-redux"; | ||
import { | ||
BOTTOM_BANNER_ID, | ||
StyledBanner, | ||
StyledBottomBannerWrapper, | ||
StyledLink, | ||
} from "./style"; | ||
import { | ||
BOTTOM_BANNER_SURVEY_LINK_TEXT, | ||
BOTTOM_BANNER_SURVEY_TEXT, | ||
} from "./constants"; | ||
import { AppDispatch, RootState } from "../../reducers"; | ||
|
||
export interface BottomBannerProps { | ||
surveyLink: string; | ||
showBottomBanner: boolean; | ||
dispatch: AppDispatch; | ||
} | ||
|
||
const mapStateToProps = (state: RootState) => ({ | ||
showBottomBanner: state.showBottomBanner, | ||
}); | ||
|
||
const mapDispatchToProps = (dispatch: AppDispatch) => ({ | ||
dispatch, | ||
}); | ||
|
||
const BottomBanner = memo( | ||
({ | ||
surveyLink, | ||
showBottomBanner, | ||
dispatch, | ||
}: BottomBannerProps): JSX.Element | null => { | ||
const setBottomBannerLastClosedTime = () => { | ||
dispatch({ | ||
type: "update bottom banner last closed time", | ||
time: Date.now(), | ||
}); | ||
}; | ||
|
||
if (!showBottomBanner) return null; | ||
|
||
return ( | ||
<> | ||
<StyledBottomBannerWrapper | ||
id={BOTTOM_BANNER_ID} | ||
data-testid={BOTTOM_BANNER_ID} | ||
> | ||
<StyledBanner | ||
dismissible | ||
sdsType="primary" | ||
onClose={setBottomBannerLastClosedTime} | ||
// @ts-expect-error -- czifui Banner component types text prop as a string but the prop works with JSX as well | ||
text={ | ||
<span> | ||
{BOTTOM_BANNER_SURVEY_TEXT} | ||
<StyledLink href={surveyLink} target="_blank" rel="noopener"> | ||
{BOTTOM_BANNER_SURVEY_LINK_TEXT} | ||
</StyledLink> | ||
</span> | ||
} | ||
/> | ||
</StyledBottomBannerWrapper> | ||
</> | ||
); | ||
} | ||
); | ||
|
||
export default connect(mapStateToProps, mapDispatchToProps)(BottomBanner); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import styled from "@emotion/styled"; | ||
import { Banner, Icon } from "czifui"; | ||
import { beta100, beta400, gray500 } from "../theme"; | ||
|
||
export const SKINNY_MODE_BREAKPOINT_WIDTH = 960; | ||
export const BOTTOM_BANNER_ID = "bottom-banner"; | ||
|
||
export const StyledBanner = styled(Banner)` | ||
@media (max-width: ${SKINNY_MODE_BREAKPOINT_WIDTH}px) { | ||
padding: 8px 16px; | ||
box-shadow: 0px 0px 4px 0px rgba(50, 50, 50, 0.75); | ||
} | ||
span { | ||
font-family: "Roboto Condensed", "Helvetica Neue", "Helvetica", "Arial", | ||
sans-serif; | ||
font-weight: 400; | ||
} | ||
/** | ||
* beta intent does not exist for SDS banner, but the colors do targeting | ||
* specific id to overwrite style | ||
*/ | ||
border-color: ${beta400} !important; | ||
background-color: ${beta100}; | ||
color: black; | ||
/* Hide default svg icon in the Banner as it is not in figma */ | ||
:first-of-type > div:first-of-type > div:first-of-type { | ||
display: none; | ||
} | ||
/* Change close button icon default color */ | ||
button svg { | ||
path { | ||
fill: ${gray500}; | ||
} | ||
} | ||
`; | ||
|
||
export const StyledBottomBannerWrapper = styled.div` | ||
width: 100%; | ||
/* Right behind modal overlay */ | ||
z-index: 19; | ||
background-color: purple; | ||
`; | ||
|
||
export const StyledLink = styled.a` | ||
padding: 0px 5px 0px 5px; | ||
text-decoration-line: underline; | ||
color: #8f5aff; | ||
font-weight: 500; | ||
:hover { | ||
color: #5826c1; | ||
} | ||
`; | ||
|
||
const STYLED_CLOSE_BUTTON_ICON_DENY_PROPS = ["hideCloseButton"]; | ||
|
||
export const StyledCloseButtonIcon = styled(Icon, { | ||
shouldForwardProp: (prop) => | ||
!STYLED_CLOSE_BUTTON_ICON_DENY_PROPS.includes(prop), | ||
})``; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.