🐛 Text content does not match server-rendered HTML (#1407)

Render Kbd component only on client side
This commit is contained in:
homersimpsons 2023-04-13 17:15:33 +02:00 committed by GitHub
parent 4dcf12834d
commit 2bef604bcd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 40 additions and 41 deletions

View File

@ -11,8 +11,8 @@ If you would like to add a new emoji to gitmoji, fill the provided `ISSUE_TEMPLA
1. Fork [this repository](https://github.com/carloscuesta/gitmoji/fork).
2. Create a new branch with the feature name. (Eg: add-emoji-deploy, fix-website-header)
3. Make your changes.
4. Test you changes by running `yarn test`
- 4.1. If the snapshots are failing run `yarn test -u` and be sure that the new snapshots match your changes
4. Test you changes by running `yarn turbo test`
- 4.1. If the snapshots are failing run `yarn turbo test -- -u` and be sure that the new snapshots match your changes
5. Commit your changes. Don't forget to add a commit title with an emoji and a description.
6. Push your changes.
7. Submit your pull request.

View File

@ -564,12 +564,6 @@ exports[`Pages Index should render the page 1`] = `
type="search"
value=""
/>
<kbd
className="kbd"
>
Ctrl
K
</kbd>
</div>
<div
className="actionsContainer"

View File

@ -0,0 +1,14 @@
import styles from './styles.module.css'
const isMacOs = () => {
return (
typeof window !== 'undefined' &&
window.navigator.platform.toUpperCase().includes('MAC')
)
}
const Kbd = () => {
return <kbd className={styles.kbd}>{isMacOs() ? '⌘' : 'Ctrl'} K</kbd>
}
export default Kbd

View File

@ -0,0 +1,21 @@
.kbd {
right: 0;
align-items: center;
border-radius: 3px;
border: solid 1px #999;
color: #595959;
display: flex;
font-family: system-ui;
margin-right: 0.5rem;
padding: 0.25rem 0.5rem;
}
[data-theme='dark'] .kbd {
color: #b8b8b8;
}
@media (max-width: 568px) {
.kbd {
display: none;
}
}

View File

@ -1,7 +1,9 @@
import { useEffect, useRef } from 'react'
import dynamic from 'next/dynamic'
import ListModeSelector from './ListModeSelector'
import ThemeSelector from './ThemeSelector'
const Kbd = dynamic(() => import('./Kbd'), { ssr: false })
import styles from './styles.module.css'
type Props = {
@ -11,12 +13,6 @@ type Props = {
setSearchInput: (searchInput: string) => void
}
const isMacOs = () => {
return typeof window === 'undefined'
? true
: window.navigator.platform.toUpperCase().indexOf('MAC') >= 0
}
const Toolbar = (props: Props) => {
const searchInputRef = useRef<HTMLInputElement>(null)
@ -55,7 +51,7 @@ const Toolbar = (props: Props) => {
value={props.searchInput}
/>
<kbd className={styles.kbd}>{isMacOs() ? '⌘' : 'Ctrl'} K</kbd>
<Kbd />
</div>
<div className={styles.actionsContainer}>

View File

@ -41,26 +41,10 @@
outline: none;
}
.kbd {
right: 0;
align-items: center;
border-radius: 3px;
border: solid 1px #999;
color: #595959;
display: flex;
font-family: system-ui;
margin-right: 0.5rem;
padding: 0.25rem 0.5rem;
}
[data-theme='dark'] .searchInput {
color: var(--text);
}
[data-theme='dark'] .kbd {
color: #b8b8b8;
}
@media (max-width: 568px) {
.searchInput {
margin: 0;
@ -71,8 +55,4 @@
flex-direction: column-reverse;
align-items: stretch;
}
.kbd {
display: none;
}
}

View File

@ -360,12 +360,6 @@ exports[`GitmojiList when is not list mode should render the component 1`] = `
type="search"
value=""
/>
<kbd
className="kbd"
>
Ctrl
K
</kbd>
</div>
<div
className="actionsContainer"