Skip to content

Commit

Permalink
Rename Banner attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
hanbyul-here committed Jul 24, 2024
1 parent 508bd47 commit 6f61fbc
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 21 deletions.
16 changes: 8 additions & 8 deletions app/scripts/components/common/banner/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,21 @@ enum BannerType {
const infoTypeFlag = BannerType.info;
interface BannerProps {
appTitle: string,
expiryDate: Date,
actionUrl: string,
contents: string,
expires: Date,
url: string,
text: string,
type?: BannerType
}

export default function Banner({appTitle, expiryDate, actionUrl, contents, type = infoTypeFlag }: BannerProps) {
export default function Banner({appTitle, expires, url, text, type = infoTypeFlag }: BannerProps) {

const showBanner = localStorage.getItem(BANNER_KEY) !== actionUrl;
const [isOpen, setIsOpen] = useState(showBanner && !(hasExpired(expiryDate)));
const showBanner = localStorage.getItem(BANNER_KEY) !== url;
const [isOpen, setIsOpen] = useState(showBanner && !(hasExpired(expires)));

function onClose () {
localStorage.setItem(
BANNER_KEY,
actionUrl
url
);
setIsOpen(false);
}
Expand All @@ -43,7 +43,7 @@ export default function Banner({appTitle, expiryDate, actionUrl, contents, type
<USWDSBanner aria-label={appTitle} className={type !== infoTypeFlag? 'bg-secondary-lighter': ''}>
<a href={actionUrl} target='_blank' rel='noreferrer'>

Check failure on line 44 in app/scripts/components/common/banner/index.tsx

View workflow job for this annotation

GitHub Actions / ts-check

Cannot find name 'actionUrl'.
<BannerContent className='padding-top-1 padding-bottom-1' isOpen={true}>
<p dangerouslySetInnerHTML={{ __html: contents }} />
<p dangerouslySetInnerHTML={{ __html: text }} />
</BannerContent>
</a>
</USWDSBanner>
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/components/home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ function RootHome() {
const { show: showFeedbackModal } = useFeedbackModal();

const banner = getBanner();
const renderBanner = !!banner && banner.contents && banner.actionUrl && banner.expiryDate;
const renderBanner = !!banner && banner.text && banner.url && banner.expires;

return (
<PageMainContent>
Expand Down
12 changes: 6 additions & 6 deletions docs/content/CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,17 @@ strings: {
`Banner` object allows you to display a site-wide banner that sits atop your application. To create a banner, you need to provide four attributes (one optional) as outlined below.

```
expiryDate: Date,
actionUrl: string,
contents: string,
expires: Date,
url: string,
text: string,
type?: BannerType
```

| Option | Type | Description| Example|
|---|---|---|---|
| expiryDate | Date | The date and time when the banner expires. (ISO 8601 format) | '2024-08-03T12:00:00-04:00'|
| actionUrl | string | The URL that will be triggered when the user clicks on the banner. | 'stories/emit-and-aviris-3' |
| contents | string | The text content to display in the banner. | 'Read the new data insight on using EMIT and AVIRIS-3 for monitoring large methane emission events.' |
| expires | Date | The date and time when the banner expires. (ISO 8601 format) | '2024-08-03T12:00:00-04:00'|
| url | string | The URL that will be triggered when the user clicks on the banner. | 'stories/emit-and-aviris-3' |
| text | string | The text content to display in the banner. This can be an HTML string. | 'Read the new data insight on using EMIT and AVIRIS-3 for monitoring large methane emission events.' |
| type | enum('info', 'warning') |The type of information delivered by the banner, which determines its background color. | 'info'|


Expand Down
6 changes: 3 additions & 3 deletions mock/veda.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ module.exports = {
}
},
banner: {
contents: 'Read the new data insight on using EMIT and AVIRIS-3 for monitoring large methane emission events.',
actionUrl: 'stories/emit-and-aviris-3',
expiryDate: '2024-08-03T12:00:00-04:00',
text: 'Read the new data insight on using EMIT and AVIRIS-3 for monitoring large methane emission events.',
url: 'stories/emit-and-aviris-3',
expires: '2024-08-03T12:00:00-04:00',
type: 'info'
}
};
6 changes: 3 additions & 3 deletions parcel-resolver-veda/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,9 @@ export interface LayerInfo {

const infoTypeFlag = BannerType.info;
interface BannerData {
expiryDate: Date,
actionUrl: string,
contents: string,
expires: Date,
url: string,
text: string,
type?: BannerType
}

Expand Down

0 comments on commit 6f61fbc

Please sign in to comment.