Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(theme-classic): split AnnouncementBar, increase z-index, use…
… shadow (#7940)
- Loading branch information
Showing
7 changed files
with
115 additions
and
37 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
31 changes: 31 additions & 0 deletions
31
packages/docusaurus-theme-classic/src/theme/AnnouncementBar/CloseButton/index.tsx
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,31 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import React from 'react'; | ||
import clsx from 'clsx'; | ||
import {translate} from '@docusaurus/Translate'; | ||
import IconClose from '@theme/Icon/Close'; | ||
import type {Props} from '@theme/AnnouncementBar/CloseButton'; | ||
import styles from './styles.module.css'; | ||
|
||
export default function AnnouncementBarCloseButton( | ||
props: Props, | ||
): JSX.Element | null { | ||
return ( | ||
<button | ||
type="button" | ||
aria-label={translate({ | ||
id: 'theme.AnnouncementBar.closeButtonAriaLabel', | ||
message: 'Close', | ||
description: 'The ARIA label for close button of announcement bar', | ||
})} | ||
{...props} | ||
className={clsx('clean-btn close', styles.closeButton, props.className)}> | ||
<IconClose width={14} height={14} strokeWidth={3.1} /> | ||
</button> | ||
); | ||
} |
11 changes: 11 additions & 0 deletions
11
packages/docusaurus-theme-classic/src/theme/AnnouncementBar/CloseButton/styles.module.css
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,11 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
.closeButton { | ||
padding: 0; | ||
line-height: 0; | ||
} |
28 changes: 28 additions & 0 deletions
28
packages/docusaurus-theme-classic/src/theme/AnnouncementBar/Content/index.tsx
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,28 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import React from 'react'; | ||
import clsx from 'clsx'; | ||
import {useThemeConfig} from '@docusaurus/theme-common'; | ||
import type {Props} from '@theme/AnnouncementBar/Content'; | ||
import styles from './styles.module.css'; | ||
|
||
export default function AnnouncementBarContent( | ||
props: Props, | ||
): JSX.Element | null { | ||
const {announcementBar} = useThemeConfig(); | ||
const {content} = announcementBar!; | ||
return ( | ||
<div | ||
{...props} | ||
className={clsx(styles.content, props.className)} | ||
// Developer provided the HTML, so assume it's safe. | ||
// eslint-disable-next-line react/no-danger | ||
dangerouslySetInnerHTML={{__html: content}} | ||
/> | ||
); | ||
} |
17 changes: 17 additions & 0 deletions
17
packages/docusaurus-theme-classic/src/theme/AnnouncementBar/Content/styles.module.css
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,17 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
.content { | ||
font-size: 85%; | ||
text-align: center; | ||
padding: 5px 0; | ||
} | ||
|
||
.content a { | ||
color: inherit; | ||
text-decoration: underline; | ||
} |
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