demoHeader.tsx 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. import styled from '@emotion/styled';
  2. import {Button} from 'sentry/components/button';
  3. import LogoSentry from 'sentry/components/logoSentry';
  4. import {t} from 'sentry/locale';
  5. import PreferencesStore from 'sentry/stores/preferencesStore';
  6. import {useLegacyStore} from 'sentry/stores/useLegacyStore';
  7. import {space} from 'sentry/styles/space';
  8. import {trackAnalytics} from 'sentry/utils/analytics';
  9. import {
  10. extraQueryParameter,
  11. extraQueryParameterWithEmail,
  12. urlAttachQueryParams,
  13. } from 'sentry/utils/demoMode';
  14. export default function DemoHeader() {
  15. const sandboxData = window.SandboxData;
  16. // if the user came from a SaaS org, we should send them back to upgrade when they leave the sandbox
  17. const extraSearchParams = extraQueryParameter();
  18. const collapsed = !!useLegacyStore(PreferencesStore).collapsed;
  19. const docsBtn = (
  20. <DocsDemoBtn
  21. onClick={() => trackAnalytics('growth.demo_click_docs', {organization: null})}
  22. href={urlAttachQueryParams('https://docs.sentry.io/', extraSearchParams)}
  23. external
  24. >
  25. {t('Documentation')}
  26. </DocsDemoBtn>
  27. );
  28. const reqDemoBtn = (
  29. <NewRequestDemoBtn
  30. onClick={() =>
  31. trackAnalytics('growth.demo_click_request_demo', {
  32. organization: null,
  33. })
  34. }
  35. href={urlAttachQueryParams('https://sentry.io/_/demo/', extraSearchParams)}
  36. external
  37. >
  38. {t('Request a Demo')}
  39. </NewRequestDemoBtn>
  40. );
  41. const signUpBtn = (
  42. <FreeTrial
  43. onClick={() => {
  44. const url =
  45. sandboxData?.cta?.url ||
  46. urlAttachQueryParams(
  47. 'https://sentry.io/signup/',
  48. extraQueryParameterWithEmail()
  49. );
  50. // Using window.open instead of href={} because we need to read `email`
  51. // from localStorage when the user clicks the button.
  52. window.open(url, '_blank');
  53. trackAnalytics('growth.demo_click_get_started', {
  54. cta: sandboxData?.cta?.id,
  55. organization: null,
  56. });
  57. }}
  58. >
  59. <FreeTrialTextLong>
  60. {sandboxData?.cta?.title || t('Start Free Trial')}
  61. </FreeTrialTextLong>
  62. <FreeTrialTextShort>
  63. {sandboxData?.cta?.shortTitle || t('Sign Up')}
  64. </FreeTrialTextShort>
  65. </FreeTrial>
  66. );
  67. return (
  68. <Wrapper collapsed={collapsed}>
  69. <StyledLogoSentry />
  70. {docsBtn}
  71. {reqDemoBtn}
  72. {signUpBtn}
  73. </Wrapper>
  74. );
  75. }
  76. // Note many of the colors don't come from the theme as they come from the marketing site
  77. const Wrapper = styled('div')<{collapsed: boolean}>`
  78. padding-right: ${space(3)};
  79. background-color: ${p => p.theme.white};
  80. height: ${p => p.theme.demo.headerSize};
  81. display: flex;
  82. justify-content: space-between;
  83. text-transform: uppercase;
  84. align-items: center;
  85. white-space: nowrap;
  86. gap: ${space(4)};
  87. margin-left: calc(
  88. -1 * ${p => (p.collapsed ? p.theme.sidebar.collapsedWidth : p.theme.sidebar.expandedWidth)}
  89. );
  90. position: fixed;
  91. width: 100%;
  92. border-bottom: 1px solid ${p => p.theme.border};
  93. z-index: ${p => p.theme.zIndex.settingsSidebarNav};
  94. @media (max-width: ${p => p.theme.breakpoints.medium}) {
  95. height: ${p => p.theme.sidebar.mobileHeight};
  96. margin-left: 0;
  97. }
  98. `;
  99. const StyledLogoSentry = styled(LogoSentry)`
  100. margin-top: auto;
  101. margin-bottom: auto;
  102. margin-left: 20px;
  103. margin-right: auto;
  104. width: 130px;
  105. height: 30px;
  106. color: ${p => p.theme.textColor};
  107. `;
  108. const FreeTrialTextShort = styled('span')`
  109. display: none;
  110. `;
  111. const FreeTrialTextLong = styled('span')``;
  112. const NewBaseButton = styled(Button)`
  113. text-transform: uppercase;
  114. `;
  115. const NewRequestDemoBtn = styled(NewBaseButton)`
  116. @media (max-width: ${p => p.theme.breakpoints.small}) {
  117. display: none;
  118. }
  119. `;
  120. const DocsDemoBtn = styled(NewBaseButton)`
  121. @media (max-width: 500px) {
  122. display: none;
  123. }
  124. `;
  125. const FreeTrial = styled(NewBaseButton)`
  126. border-color: transparent;
  127. background-color: #6c5fc7;
  128. color: #fff;
  129. .short-text {
  130. display: none;
  131. }
  132. @media (max-width: 650px) {
  133. ${FreeTrialTextLong} {
  134. display: none;
  135. }
  136. ${FreeTrialTextShort} {
  137. display: inline;
  138. }
  139. }
  140. `;