Skip to content

Commit

Permalink
Tweak the static display for the hour period. (#96664)
Browse files Browse the repository at this point in the history
  • Loading branch information
dognose24 authored Nov 24, 2024
1 parent 6ea0f58 commit ff937e8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
12 changes: 10 additions & 2 deletions client/components/stats-interval-dropdown/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ const IntervalDropdown = ( { slug, period, queryParams, intervals, onGatedHandle
function getDisplayLabel() {
// If the period is not in the intervals list, capitalize it and show in the label - however user wouldn't be able to select it.
// TODO: this is a temporary solution, we should remove this once we have all the intervals in the list.
return intervals[ period ]?.label ?? capitalize( period );
return intervals[ period ]?.label ?? `${ capitalize( period ) }s`;
}

function onSelectionHandler( interval ) {
Expand All @@ -93,7 +93,10 @@ const IntervalDropdown = ( { slug, period, queryParams, intervals, onGatedHandle
page( generateNewLink( interval ) );
}

return (
// Check if the selected period is in the intervals list.
const selectedPeriod = intervals[ period ];

return selectedPeriod ? (
<Dropdown
className="stats-interval-dropdown"
renderToggle={ ( { isOpen, onToggle } ) => (
Expand All @@ -114,6 +117,11 @@ const IntervalDropdown = ( { slug, period, queryParams, intervals, onGatedHandle
) }
focusOnMount={ false }
/>
) : (
// TODO: Tweak the styles or move this to another place for better UX.
<div className="stats-interval-display">
<label>{ getDisplayLabel() }</label>
</div>
);
};

Expand Down
8 changes: 8 additions & 0 deletions client/components/stats-interval-dropdown/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,11 @@
background-color: var(--color-accent-5);
}
}

// Mimic the style of Button component.
.stats-interval-display {
font-family: $font-sf-pro-text;
font-size: 13px; // stylelint-disable-line declaration-property-unit-allowed-list
font-weight: 400;
line-height: 36px;
}
2 changes: 1 addition & 1 deletion client/my-sites/stats/stats-chart-tabs/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ ul.module-tabs {
border-top-color: #DCDCDE;
}

.stats-interval-dropdown {
.stats-interval-dropdown, .stats-interval-display {
margin-left: 48px;

& > .components-button {
Expand Down

0 comments on commit ff937e8

Please sign in to comment.