Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New navigations buttons #1574

Merged
merged 12 commits into from
Sep 28, 2021
26 changes: 24 additions & 2 deletions packages/common-components/src/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { Typography } from "../Typography"
const useStyles = makeStyles(
({ constants, typography, animation, palette, overrides }: ITheme) =>
createStyles({
// JSS in CSS goes here
root: {
...typography.button,
borderRadius: `${constants.generalUnit / 4}px`,
Expand Down Expand Up @@ -110,6 +109,29 @@ const useStyles = makeStyles(
},
...overrides?.Button?.variants?.secondary?.root
},
tertiary: {
backgroundColor: palette.additional["gray"][3],
color: palette.common.black.main,
"& svg": {
fill: palette.common.white.main
},
"&:hover": {
backgroundColor: palette.primary.main,
color: palette.common.white.main,
...overrides?.Button?.variants?.secondary?.hover
},
"&:focus": {
backgroundColor: palette.primary.main,
color: palette.common.white.main,
...overrides?.Button?.variants?.secondary?.focus
},
"&:active": {
backgroundColor: palette.primary.main,
color: palette.common.white.main,
...overrides?.Button?.variants?.secondary?.active
},
...overrides?.Button?.variants?.secondary?.root
},
outline: {
color: palette.additional["gray"][8],
backgroundColor: palette.common?.white.main,
Expand Down Expand Up @@ -271,7 +293,7 @@ interface IButtonProps extends Omit<ReactButton, "size"> {
className?: string
children?: ReactNode | ReactNode[]
fullsize?: boolean
variant?: "link" | "primary" | "secondary" | "outline" | "dashed" | "danger"
variant?: "link" | "primary" | "secondary" |"tertiary" | "outline" | "dashed" | "danger"
iconButton?: boolean
size?: "large" | "medium" | "small"
type?: "button" | "submit" | "reset"
Expand Down
2 changes: 1 addition & 1 deletion packages/common-theme/src/Defaults/ThemeConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ const DefaultThemeConfig: IThemeConfig = {
},
button: {
...defaultFontStyles,
fontWeight: defaultFontWeights.regular,
fontWeight: defaultFontWeights.semibold,
fontSize: 14,
lineHeight: "22px"
},
Expand Down
77 changes: 77 additions & 0 deletions packages/files-ui/src/Components/Elements/TeamModal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import { Button, Typography } from "@chainsafe/common-components"
import { createStyles, makeStyles } from "@chainsafe/common-theme"
import { Trans } from "@lingui/macro"
import React, { useCallback } from "react"
import { CSFTheme } from "../../Themes/types"
import { ROUTE_LINKS } from "../FilesRoutes"
import CustomModal from "./CustomModal"

const useStyles = makeStyles(
({ constants }: CSFTheme) => {
return createStyles({
root: {
padding: `${constants.generalUnit * 6}px ${constants.generalUnit * 4}px`,
flexDirection: "column",
display: "flex",
alignItems: "center"
},
title: {
marginBottom: constants.generalUnit * 3
},
modalInner: {
maxWidth: "600px !important"
},
buttonContainer: {
width: "100%"
},
nextButton: {
margin: "auto",
marginTop: constants.generalUnit * 3
}
})
})

interface Props {
onHide: () => void
}

const TeamModal = ({ onHide }: Props) => {
const classes = useStyles()

const onSignupTeamClick = useCallback(() => {
window.open(ROUTE_LINKS.TeamSignup, "_blank")
onHide()
}, [onHide])

return (
<CustomModal
injectedClass={{ inner: classes.modalInner }}
active={true}
closePosition="right"
maxWidth="sm"
onClose={onHide}
mobileStickyBottom={false}
>
<div className={classes.root}>
<Typography variant="h2"
className={classes.title}
>
<Trans>Teams</Trans>
</Typography>
<Typography variant="h4">
<Trans>A better sharing experience is coming soon.</Trans>
</Typography>
<div className={classes.buttonContainer}>
<Button
data-posthog="Sign-me-up"
className={classes.nextButton}
onClick={onSignupTeamClick}
>
<Trans>Sign me up!</Trans>
</Button>
</div>
</div>
</CustomModal>
)}

export default TeamModal
3 changes: 2 additions & 1 deletion packages/files-ui/src/Components/FilesRoutes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ export const ROUTE_LINKS = {
const adjustedRawCurrentPath = !rawCurrentPath ? "/" : rawCurrentPath
return `/shared/${bucketId}${adjustedRawCurrentPath}`
},
DiscordInvite: "https://discord.gg/zAEY37fNb2"
DiscordInvite: "https://discord.gg/zAEY37fNb2",
TeamSignup: "https://shrl.ink/cgQy"
}

export const SETTINGS_PATHS = ["profile", "plan", "security"] as const
Expand Down
51 changes: 47 additions & 4 deletions packages/files-ui/src/Components/Layouts/AppHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import {
HamburgerMenu,
MenuDropdown,
PowerDownSvg,
useHistory
useHistory,
Button
} from "@chainsafe/common-components"
import { ROUTE_LINKS } from "../FilesRoutes"
import SearchModule from "../Modules/SearchModule"
Expand All @@ -17,6 +18,7 @@ import { useThresholdKey } from "../../Contexts/ThresholdKeyContext"
import { CSFTheme } from "../../Themes/types"
import { useUser } from "../../Contexts/UserContext"
import { useFilesApi } from "../../Contexts/FilesApiContext"
import TeamModal from "../Elements/TeamModal"

const useStyles = makeStyles(
({ palette, animation, breakpoints, constants, zIndex }: CSFTheme) => {
Expand Down Expand Up @@ -99,9 +101,7 @@ const useStyles = makeStyles(
justifyContent: "flex-end",
alignItems: "center",
flexDirection: "row",
[breakpoints.up("md")]: {
marginLeft: constants.accountControlsPadding
},

"& > *:first-child": {
marginRight: constants.generalUnit * 2
}
Expand Down Expand Up @@ -142,6 +142,19 @@ const useStyles = makeStyles(
},
title : {
marginLeft: constants.generalUnit
},
buttonsSection: {
display: "flex",
alignItems: "center",
margin: `0 ${constants.generalUnit * 2}px`,

"& button" : {
height: constants.generalUnit * 4,

"&:not(:first-child)": {
marginLeft: constants.generalUnit * 2
}
}
}
})
}
Expand All @@ -159,6 +172,7 @@ const AppHeader = ({ navOpen, setNavOpen }: IAppHeader) => {
const { publicKey, isNewDevice, shouldInitializeAccount, logout } = useThresholdKey()
const { getProfileTitle, removeUser } = useUser()
const [searchActive, setSearchActive] = useState(false)
const [isTeamModalOpen, setIsTeamModalOpen] = useState(false)
const { history } = useHistory()

const signOut = useCallback(async () => {
Expand All @@ -171,6 +185,14 @@ const AppHeader = ({ navOpen, setNavOpen }: IAppHeader) => {

}, [logout, removeUser, history])

const onReportBugClick = useCallback(() => {
window.open(ROUTE_LINKS.DiscordInvite, "_blank")
}, [])

const onStartATeamClick = useCallback(() => {
setIsTeamModalOpen(true)
}, [])

return (
<header
className={clsx(classes.root, {
Expand All @@ -197,6 +219,26 @@ const AppHeader = ({ navOpen, setNavOpen }: IAppHeader) => {
setSearchActive={setSearchActive}
/>
</section>
<section className={classes.buttonsSection}>
<Button
data-posthog="Report-a-bug"
data-cy="send-feedback-nav"
variant="tertiary"
size="small"
onClick={onReportBugClick}
>
<Trans>Report a bug</Trans>
</Button>
<Button
data-posthog="Start-a-team"
data-cy="start-team-nav"
variant="tertiary"
size="small"
onClick={onStartATeamClick}
>
<Trans>Start a team</Trans>
</Button>
</section>
<section className={classes.accountControls}>
<MenuDropdown
title={getProfileTitle()}
Expand Down Expand Up @@ -260,6 +302,7 @@ const AppHeader = ({ navOpen, setNavOpen }: IAppHeader) => {
)}
</>
)}
{isTeamModalOpen && <TeamModal onHide={() => setIsTeamModalOpen(false)}/>}
</header>
)
}
Expand Down
78 changes: 26 additions & 52 deletions packages/files-ui/src/Components/Layouts/AppNav.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import { useFiles } from "../../Contexts/FilesContext"
import {
createStyles,
makeStyles,
useThemeSwitcher
} from "@chainsafe/common-theme"
import { createStyles, makeStyles, useThemeSwitcher } from "@chainsafe/common-theme"
import React, { useCallback } from "react"
import clsx from "clsx"
import {
Expand All @@ -14,10 +10,10 @@ import {
SettingSvg,
PowerDownSvg,
ProgressBar,
Button,
formatBytes,
DeleteSvg,
UserShareSvg } from "@chainsafe/common-components"
UserShareSvg
} from "@chainsafe/common-components"
import { ROUTE_LINKS } from "../FilesRoutes"
import { Trans } from "@lingui/macro"
import { useThresholdKey } from "../../Contexts/ThresholdKeyContext"
Expand Down Expand Up @@ -201,9 +197,6 @@ const useStyles = makeStyles(
},
betaCaption: {
marginBottom: constants.generalUnit * 0.5
},
supportButton: {
margin: "auto"
}
})
}
Expand All @@ -214,15 +207,12 @@ interface IAppNav {
setNavOpen: (state: boolean) => void
}

const AppNav: React.FC<IAppNav> = ({ navOpen, setNavOpen }: IAppNav) => {
const AppNav = ({ navOpen, setNavOpen }: IAppNav) => {
const { desktop } = useThemeSwitcher()
const classes = useStyles()

const { storageSummary } = useFiles()

const { isLoggedIn, secured } = useFilesApi()
const { publicKey, isNewDevice, shouldInitializeAccount, logout } = useThresholdKey()

const { removeUser } = useUser()

const signOut = useCallback(() => {
Expand All @@ -236,19 +226,15 @@ const AppNav: React.FC<IAppNav> = ({ navOpen, setNavOpen }: IAppNav) => {
}
}, [desktop, navOpen, setNavOpen])

const collectFeedback = () => {
window.open(ROUTE_LINKS.DiscordInvite, "_blank")
}

return (
<section
className={clsx(classes.root, {
active: desktop
? isLoggedIn &&
secured &&
!!publicKey &&
!isNewDevice &&
!shouldInitializeAccount
secured &&
!!publicKey &&
!isNewDevice &&
!shouldInitializeAccount
: navOpen
})}
>
Expand Down Expand Up @@ -349,37 +335,25 @@ const AppNav: React.FC<IAppNav> = ({ navOpen, setNavOpen }: IAppNav) => {
</div>
<section>
{desktop && (
<div
data-cy="label-space-used"
>
{
storageSummary && (
<>
<Typography
variant="body2"
className={classes.spaceUsedMargin}
component="p"
>{`${formatBytes(storageSummary.used_storage, 2)} of ${formatBytes(
storageSummary.total_storage, 2
)} used`}</Typography>
<ProgressBar
data-cy="progress-bar-space-used"
className={classes.spaceUsedMargin}
progress={(storageSummary.used_storage / storageSummary.total_storage) * 100}
size="small"
/>
</>
)
<div data-cy="label-space-used">
{storageSummary && (
<>
<Typography
variant="body2"
className={classes.spaceUsedMargin}
component="p"
>{`${formatBytes(storageSummary.used_storage, 2)} of ${formatBytes(
storageSummary.total_storage, 2
)} used`}</Typography>
<ProgressBar
data-cy="progress-bar-space-used"
className={classes.spaceUsedMargin}
progress={(storageSummary.used_storage / storageSummary.total_storage) * 100}
size="small"
/>
</>
)
}
<Button
className={classes.supportButton}
data-cy="send-feedback-nav"
variant="secondary"
size="medium"
onClick={() => collectFeedback()}
>
<Trans>Got an issue?</Trans>
</Button>
</div>
)}
{!desktop && (
Expand Down
Loading