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

fix: update reverse trial button styles, add tooltips and localize nav button #5478

Merged
merged 1 commit into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/sanity/src/core/i18n/bundles/studio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,12 @@ export const studioLocaleStrings = defineLocalesResources('studio', {
'form.validation.summary.warnings-count_one': '{{count}} warning',
'form.validation.summary.warnings-count_other': '{{count}} warnings',

/** Tooltip for free trial navbar button indicating remaining days */
'free-trial.tooltip.days-count_one': '{{count}} day left in trial',
'free-trial.tooltip.days-count_other': '{{count}} days left in trial',
/** Tooltip for free trial navbar button, once trial has ended */
'free-trial.tooltip.trial-finished': 'Upgrade your project',

/**
* Label for "contact sales" call to action
* These are titles for fallback links in the event the help & resources endpoint isn't able to be fetched
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,12 @@
import styled from 'styled-components'

import {
// eslint-disable-next-line no-restricted-imports
Button as UIButton, // Button with necessary custom styles.
Text,
Card,
} from '@sanity/ui'
import {Card, Text} from '@sanity/ui'
import {BoltIcon} from '@sanity/icons'
import {purple, yellow} from '@sanity/color'
import {useTranslation} from 'react-i18next'
import {forwardRef} from 'react'
import {Button} from '../../../../../ui-components'

const StyledButton = styled(UIButton)`
padding: 2px;
margin: -2px;
position: relative;
`

const CenteredStroke = styled.div`
position: absolute;
top: 50%;
Expand All @@ -34,7 +23,7 @@ const SvgFilledOutline = ({daysLeft, totalDays}: OutlineProps) => {
const progress = totalDays - daysLeft

const percentage = Math.round((progress / totalDays) * 100)
const radius = 12.5
const radius = 10
const strokeDasharray = 2 * Math.PI * radius
const strokeDashOffset = strokeDasharray * ((100 - percentage) / 100)
const strokeWidth = 1.2
Expand Down Expand Up @@ -82,25 +71,24 @@ export const FreeTrialButtonTopbar = forwardRef(function FreeTrialButtonTopbar(
{toggleShowContent, daysLeft, totalDays}: FreeTrialButtonProps,
ref: React.Ref<HTMLButtonElement>,
) {
if (!daysLeft) {
return (
<Button
size="default"
ref={ref}
icon={BoltIcon}
mode="bleed"
onClick={toggleShowContent}
tooltipProps={{content: 'Upgrade your project'}}
/>
)
}
const {t} = useTranslation()

return (
<StyledButton ref={ref} padding={2} mode="bleed" onClick={toggleShowContent}>
<Text size={1}>
<Button
mode="bleed"
onClick={toggleShowContent}
ref={ref}
tooltipProps={{
content: daysLeft
? t('free-trial.tooltip.days-count', {count: daysLeft})
: t('free-trial.tooltip.trial-finished'),
}}
>
<Text size={0}>
<BoltIcon />
</Text>
{daysLeft > 0 && <SvgFilledOutline daysLeft={daysLeft} totalDays={totalDays} />}
</StyledButton>
</Button>
)
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ export function ManageMenu() {
<Stack as="ul" space={1}>
<Stack as="li">
<FreeTrial type="sidebar" />
</Stack>

<Stack as="li">
<Button
aria-label={t('user-menu.action.manage-project-aria-label')}
as="a"
Expand Down
Loading