Skip to content

Commit 63c2360

Browse files
authored
Feat: Add color to link messages & link in link preview based on light and dark theme (#912)
1 parent 58d672e commit 63c2360

File tree

2 files changed

+37
-9
lines changed

2 files changed

+37
-9
lines changed

packages/markups/src/elements/LinkSpan.js

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
3+
import { useTheme } from '@embeddedchat/ui-elements';
34
import PlainSpan from './PlainSpan';
45
import StrikeSpan from './StrikeSpan';
56
import ItalicSpan from './ItalicSpan';
@@ -27,6 +28,9 @@ const getBaseURI = () => {
2728
const isExternal = (href) => href.indexOf(getBaseURI()) !== 0;
2829

2930
const LinkSpan = ({ href, label }) => {
31+
const { theme } = useTheme();
32+
const { mode } = useTheme();
33+
3034
const contents = React.useMemo(() => {
3135
const labelArray = Array.isArray(label) ? label : [label];
3236

@@ -54,13 +58,31 @@ const LinkSpan = ({ href, label }) => {
5458

5559
if (isExternal(href)) {
5660
return (
57-
<a href={href} title={href} rel="noopener noreferrer" target="_blank">
61+
<a
62+
href={href}
63+
title={href}
64+
style={{
65+
color:
66+
mode === 'light'
67+
? theme.colors.info
68+
: theme.colors.warningForeground,
69+
}}
70+
rel="noopener noreferrer"
71+
target="_blank"
72+
>
5873
{contents}
5974
</a>
6075
);
6176
}
6277
return (
63-
<a href={href} title={href}>
78+
<a
79+
href={href}
80+
title={href}
81+
style={{
82+
color:
83+
mode === 'light' ? theme.colors.info : theme.colors.warningForeground,
84+
}}
85+
>
6486
{contents}
6587
</a>
6688
);

packages/react/src/views/LinkPreview/LinkPreview.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React, { useState } from 'react';
22
import PropTypes from 'prop-types';
3-
import { css } from '@emotion/react';
43
import {
54
Box,
65
ActionButton,
@@ -20,6 +19,7 @@ const LinkPreview = ({
2019
}) => {
2120
const { classNames, styleOverrides } = useComponentOverrides('LinkPreview');
2221
const { theme } = useTheme();
22+
const { mode } = useTheme();
2323
const styles = getLinkPreviewStyles(theme);
2424

2525
const [isPreviewOpen, setIsPreviewOpen] = useState(true);
@@ -88,9 +88,12 @@ const LinkPreview = ({
8888
<Box style={{ padding: '8px' }}>
8989
<a
9090
href={url}
91-
css={css`
92-
color: ${theme.colors.foreground};
93-
`}
91+
style={{
92+
color:
93+
mode === 'light'
94+
? theme.colors.info
95+
: theme.colors.warningForeground,
96+
}}
9497
target="_blank"
9598
rel="noopener noreferrer"
9699
>
@@ -100,9 +103,12 @@ const LinkPreview = ({
100103
{isSiteName && (
101104
<a
102105
href={url}
103-
css={css`
104-
color: ${theme.colors.foreground};
105-
`}
106+
style={{
107+
color:
108+
mode === 'light'
109+
? theme.colors.info
110+
: theme.colors.warningForeground,
111+
}}
106112
target="_blank"
107113
rel="noopener noreferrer"
108114
>

0 commit comments

Comments
 (0)