Add link style (#26)
This commit is contained in:
parent
3e1bbd89dd
commit
f0dec3d5af
|
@ -1,4 +1,7 @@
|
||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
|
import styled from "styled-components";
|
||||||
|
|
||||||
|
import { Theme } from "../../styles/themes";
|
||||||
|
|
||||||
/* eslint-disable no-useless-escape */
|
/* eslint-disable no-useless-escape */
|
||||||
const regEx =
|
const regEx =
|
||||||
|
@ -7,9 +10,13 @@ const regEx =
|
||||||
|
|
||||||
type ChatMessageContentProps = {
|
type ChatMessageContentProps = {
|
||||||
content: string;
|
content: string;
|
||||||
|
theme: Theme;
|
||||||
};
|
};
|
||||||
|
|
||||||
export function ChatMessageContent({ content }: ChatMessageContentProps) {
|
export function ChatMessageContent({
|
||||||
|
content,
|
||||||
|
theme,
|
||||||
|
}: ChatMessageContentProps) {
|
||||||
const [elements, setElements] = useState<(string | React.ReactElement)[]>([
|
const [elements, setElements] = useState<(string | React.ReactElement)[]>([
|
||||||
content,
|
content,
|
||||||
]);
|
]);
|
||||||
|
@ -25,9 +32,15 @@ export function ChatMessageContent({ content }: ChatMessageContentProps) {
|
||||||
? match
|
? match
|
||||||
: "https://" + match;
|
: "https://" + match;
|
||||||
newSplit.push(
|
newSplit.push(
|
||||||
<a key={idx} href={link}>
|
<Link
|
||||||
|
key={idx}
|
||||||
|
href={link}
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
theme={theme}
|
||||||
|
>
|
||||||
{match}
|
{match}
|
||||||
</a>,
|
</Link>,
|
||||||
split[idx + 1]
|
split[idx + 1]
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -37,3 +50,8 @@ export function ChatMessageContent({ content }: ChatMessageContentProps) {
|
||||||
|
|
||||||
return <>{elements.map((el) => el)}</>;
|
return <>{elements.map((el) => el)}</>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const Link = styled.a`
|
||||||
|
text-decoration: underline;
|
||||||
|
color: ${({ theme }) => theme.memberNameColor};
|
||||||
|
`;
|
||||||
|
|
|
@ -49,7 +49,7 @@ export function ChatMessages({ messages, theme }: ChatMessagesProps) {
|
||||||
</TimeWrapper>
|
</TimeWrapper>
|
||||||
</MessageHeaderWrapper>
|
</MessageHeaderWrapper>
|
||||||
<MessageText theme={theme}>
|
<MessageText theme={theme}>
|
||||||
<ChatMessageContent content={message.content} />
|
<ChatMessageContent content={message.content} theme={theme} />
|
||||||
</MessageText>
|
</MessageText>
|
||||||
</ContentWrapper>
|
</ContentWrapper>
|
||||||
</MessageWrapper>
|
</MessageWrapper>
|
||||||
|
|
|
@ -116,6 +116,9 @@ const MemberName = styled.p<ThemeProps>`
|
||||||
color: ${({ theme }) => theme.textPrimaryColor};
|
color: ${({ theme }) => theme.textPrimaryColor};
|
||||||
opacity: 0.7;
|
opacity: 0.7;
|
||||||
margin-left: 8px;
|
margin-left: 8px;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
overflow: hidden;
|
||||||
|
white-space: nowrap;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const MembersList = styled.div`
|
const MembersList = styled.div`
|
||||||
|
@ -139,6 +142,7 @@ const MemberIcon = styled(Icon)<ThemeProps>`
|
||||||
position: relative;
|
position: relative;
|
||||||
background-size: contain;
|
background-size: contain;
|
||||||
background-position: center;
|
background-position: center;
|
||||||
|
flex-shrink: 0;
|
||||||
|
|
||||||
&.online {
|
&.online {
|
||||||
&::after {
|
&::after {
|
||||||
|
|
|
@ -100,7 +100,7 @@ export const channels = [
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 3,
|
id: 3,
|
||||||
name: "Guest",
|
name: "Merry Silvester Christmas",
|
||||||
isOnline: true,
|
isOnline: true,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
|
@ -118,7 +118,7 @@ export const GlobalStyle = createGlobalStyle`
|
||||||
}
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
line-height: 1;
|
line-height: 147%;
|
||||||
}
|
}
|
||||||
|
|
||||||
ol,
|
ol,
|
||||||
|
|
Loading…
Reference in New Issue