-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Calypso UI Components: DateRange: Refactor "header" and "footer" area…
…s of component (#94567) * simplify * move buttons to bottom * add new dateRangeFooter * refactor renderDateHelp into header * refactor header content out of index * styling header + footer * add description to readme * fix daterange styling regression * fix button import
- Loading branch information
Showing
5 changed files
with
125 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { Button } from '@automattic/components'; | ||
import { useTranslate } from 'i18n-calypso'; | ||
import { FunctionComponent } from 'react'; | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-empty-function | ||
const noop = () => {}; | ||
|
||
interface Props { | ||
onApplyClick: () => void; | ||
onCancelClick: () => void; | ||
applyButtonText: string | null | undefined; | ||
cancelButtonText: string | null | undefined; | ||
} | ||
|
||
const DateRangeFooter: FunctionComponent< Props > = ( { | ||
onCancelClick = noop, | ||
onApplyClick = noop, | ||
cancelButtonText, | ||
applyButtonText, | ||
} ) => { | ||
const translate = useTranslate(); | ||
|
||
const cancelText = cancelButtonText || translate( 'Cancel' ); | ||
const applyText = applyButtonText || translate( 'Apply' ); | ||
|
||
return ( | ||
<div className="date-range__popover-footer"> | ||
<Button | ||
className="date-range__cancel-btn" | ||
onClick={ onCancelClick } | ||
compact | ||
aria-label={ cancelText } | ||
> | ||
{ cancelText } | ||
</Button> | ||
<Button | ||
className="date-range__apply-btn" | ||
onClick={ onApplyClick } | ||
primary | ||
compact | ||
aria-label={ applyText } | ||
> | ||
{ applyText } | ||
</Button> | ||
</div> | ||
); | ||
}; | ||
|
||
export default DateRangeFooter; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters