-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7543 from ethereum/chakra-emoji
[UI lib] Chakra Emoji migration
- Loading branch information
Showing
48 changed files
with
118 additions
and
67 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
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
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
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
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 |
---|---|---|
@@ -1,46 +1,33 @@ | ||
import React from "react" | ||
import { Twemoji } from "react-emoji-render" | ||
import styled from "@emotion/styled" | ||
import { margin, MarginProps } from "styled-system" | ||
import { Box, HTMLChakraProps } from "@chakra-ui/react" | ||
import { Twemoji, Props } from "react-emoji-render" | ||
|
||
import { IS_DEV } from "../utils/env" | ||
|
||
export interface IProps extends MarginProps { | ||
size?: number | ||
text: string | ||
} | ||
export interface IProps extends HTMLChakraProps<"span">, Props {} | ||
|
||
const StyledEmoji = styled(Twemoji)<{ size: number }>` | ||
const StyledEmoji = styled(Twemoji)` | ||
& > img { | ||
width: ${(props) => props.size}em !important; | ||
height: ${(props) => props.size}em !important; | ||
margin: 0 !important; | ||
} | ||
display: inline-block; /* respect top & bottom margins */ | ||
${margin} | ||
` | ||
|
||
const Emoji: React.FC<IProps> = ({ size = 1.5, text, ...props }) => { | ||
const Emoji = (props: IProps) => { | ||
return ( | ||
<StyledEmoji | ||
<Box | ||
as={StyledEmoji} | ||
// The emoji lib is switching the protocol based on the existence of the | ||
// `location` object. That condition in DEV causes hydration mismatches. | ||
// https://github.com/tommoor/react-emoji-render/blob/master/src/index.js#L8 | ||
// Hence, here we are defining how we want it to handle the protocol to | ||
// avoid differences in SSR | ||
options={{ protocol: IS_DEV ? "http" : "https" }} | ||
size={size} | ||
text={text} | ||
svg | ||
d="inline-block" | ||
{...props} | ||
/> | ||
) | ||
} | ||
|
||
Emoji.defaultProps = { | ||
mt: 0, | ||
mr: 0, | ||
mb: 0, | ||
ml: 0, | ||
} | ||
|
||
export default Emoji |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import React from "react" | ||
import { Twemoji } from "react-emoji-render" | ||
import styled from "@emotion/styled" | ||
import { margin, MarginProps } from "styled-system" | ||
|
||
import { IS_DEV } from "../utils/env" | ||
|
||
export interface IProps extends MarginProps { | ||
size?: number | ||
text: string | ||
} | ||
|
||
const StyledEmoji = styled(Twemoji)<{ size: number }>` | ||
& > img { | ||
width: ${(props) => props.size}em !important; | ||
height: ${(props) => props.size}em !important; | ||
margin: 0 !important; | ||
} | ||
display: inline-block; /* respect top & bottom margins */ | ||
${margin} | ||
` | ||
|
||
/** | ||
* DEPRECATED component. | ||
* | ||
* Use the new `src/components/Emoji.tsx` instead. | ||
*/ | ||
const Emoji: React.FC<IProps> = ({ size = 1.5, text, ...props }) => { | ||
return ( | ||
<StyledEmoji | ||
// The emoji lib is switching the protocol based on the existence of the | ||
// `location` object. That condition in DEV causes hydration mismatches. | ||
// https://github.com/tommoor/react-emoji-render/blob/master/src/index.js#L8 | ||
// Hence, here we are defining how we want it to handle the protocol to | ||
// avoid differences in SSR | ||
options={{ protocol: IS_DEV ? "http" : "https" }} | ||
size={size} | ||
text={text} | ||
svg | ||
{...props} | ||
/> | ||
) | ||
} | ||
|
||
Emoji.defaultProps = { | ||
mt: 0, | ||
mr: 0, | ||
mb: 0, | ||
ml: 0, | ||
} | ||
|
||
export default Emoji |
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
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
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
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
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
Oops, something went wrong.