-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: various tags improvements (#5386)
* refactor: various tags improvements * Fixes after review * Better styling with Infima
- Loading branch information
Showing
8 changed files
with
170 additions
and
23 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,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 Link from '@docusaurus/Link'; | ||
import type {Props} from '@theme/Tag'; | ||
|
||
import styles from './styles.module.css'; | ||
|
||
function Tag(props: Props): JSX.Element { | ||
const {permalink, name, count} = props; | ||
|
||
return ( | ||
<Link | ||
href={permalink} | ||
className={clsx(styles.tag, { | ||
[styles.tagRegular]: !count, | ||
[styles.tagWithCount]: count, | ||
})}> | ||
{name} | ||
{count && <span>{count}</span>} | ||
</Link> | ||
); | ||
} | ||
|
||
export default Tag; |
70 changes: 70 additions & 0 deletions
70
packages/docusaurus-theme-classic/src/theme/Tag/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,70 @@ | ||
/** | ||
* 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. | ||
*/ | ||
|
||
:root { | ||
--docusaurus-tag-list-border: var(--ifm-color-emphasis-300); | ||
} | ||
|
||
.tag { | ||
border: 1px solid var(--docusaurus-tag-list-border); | ||
transition: border var(--ifm-transition-fast); | ||
} | ||
|
||
.tag:hover { | ||
--docusaurus-tag-list-border: var(--ifm-link-color); | ||
text-decoration: none; | ||
} | ||
|
||
.tagRegular { | ||
border-radius: 0.5rem; | ||
padding: 0.3rem 0.5rem; | ||
font-size: 90%; | ||
} | ||
|
||
.tagWithCount { | ||
display: flex; | ||
align-items: center; | ||
position: relative; | ||
padding: 0 0.5rem 0 1rem; | ||
border-left: 0; | ||
} | ||
|
||
.tagWithCount:before, | ||
.tagWithCount:after { | ||
content: ''; | ||
position: absolute; | ||
top: 50%; | ||
border: 1px solid var(--docusaurus-tag-list-border); | ||
transition: inherit; | ||
} | ||
|
||
.tagWithCount:before { | ||
right: 100%; | ||
transform: translate(50%, -50%) rotate(-45deg); | ||
width: 1.18rem; | ||
height: 1.18rem; | ||
border-right: 0; | ||
border-bottom: 0; | ||
} | ||
|
||
.tagWithCount:after { | ||
left: 0; | ||
transform: translateY(-50%); | ||
width: 0.5rem; | ||
height: 0.5rem; | ||
border-radius: 50%; | ||
} | ||
|
||
.tagWithCount span { | ||
background: var(--ifm-color-secondary); | ||
color: var(--ifm-color-black); | ||
font-size: 0.7rem; | ||
line-height: 1.2; | ||
border-radius: var(--ifm-global-radius); | ||
padding: 0.1rem 0.4rem; | ||
margin-left: 0.3rem; | ||
} |
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
11 changes: 11 additions & 0 deletions
11
packages/docusaurus-theme-classic/src/theme/TagsListByLetter/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. | ||
*/ | ||
|
||
.tag { | ||
display: inline-block; | ||
margin: 0.5rem 0.5rem 0 1rem; | ||
} |
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
15 changes: 15 additions & 0 deletions
15
packages/docusaurus-theme-classic/src/theme/TagsListInline/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,15 @@ | ||
/** | ||
* 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. | ||
*/ | ||
|
||
.tags { | ||
list-style: none; | ||
display: inline-flex; | ||
} | ||
|
||
.tag { | ||
margin-right: 0.4rem; | ||
} |
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