pageTimeRangeSelector.tsx 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. import styled from '@emotion/styled';
  2. import TimeRangeSelector from 'sentry/components/organizations/timeRangeSelector';
  3. import {Panel} from 'sentry/components/panels';
  4. import {t} from 'sentry/locale';
  5. import space from 'sentry/styles/space';
  6. type Props = React.ComponentProps<typeof TimeRangeSelector> & {className?: string};
  7. function PageTimeRangeSelector({className, ...props}: Props) {
  8. return (
  9. <DropdownDate className={className}>
  10. <TimeRangeSelector
  11. key={`period:${props.relative}-start:${props.start}-end:${props.end}-utc:${props.utc}-defaultPeriod:${props.defaultPeriod}`}
  12. label={<DropdownLabel>{t('Date Range:')}</DropdownLabel>}
  13. detached
  14. {...props}
  15. />
  16. </DropdownDate>
  17. );
  18. }
  19. const DropdownDate = styled(Panel)`
  20. padding: 0;
  21. margin: 0;
  22. display: flex;
  23. justify-content: center;
  24. align-items: center;
  25. height: ${p => p.theme.form.md.height}px;
  26. background: ${p => p.theme.background};
  27. border: 1px solid ${p => p.theme.border};
  28. border-radius: ${p => p.theme.borderRadius};
  29. font-size: ${p => p.theme.fontSizeMedium};
  30. color: ${p => p.theme.textColor};
  31. > div {
  32. width: 100%;
  33. align-self: stretch;
  34. }
  35. /* StyledItemHeader used to show selected value of TimeRangeSelector */
  36. > div > div:first-child > div {
  37. padding: 0 ${space(2)};
  38. }
  39. /* Menu that dropdowns from TimeRangeSelector */
  40. > div > div:last-child:not(:first-child) {
  41. /* Remove awkward 1px width difference on dropdown due to border */
  42. min-width: calc(100% + 2px);
  43. transform: translateX(-1px);
  44. right: auto;
  45. }
  46. `;
  47. const DropdownLabel = styled('span')`
  48. text-align: left;
  49. font-weight: 600;
  50. color: ${p => p.theme.textColor};
  51. > span:last-child {
  52. font-weight: 400;
  53. }
  54. `;
  55. export default PageTimeRangeSelector;