Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added color to the link messages & link present in link preview based on light and dark theme #912

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions packages/markups/src/elements/LinkSpan.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import { useTheme } from '@embeddedchat/ui-elements';
import PlainSpan from './PlainSpan';
import StrikeSpan from './StrikeSpan';
import ItalicSpan from './ItalicSpan';
Expand Down Expand Up @@ -27,6 +28,9 @@ const getBaseURI = () => {
const isExternal = (href) => href.indexOf(getBaseURI()) !== 0;

const LinkSpan = ({ href, label }) => {
const { theme } = useTheme();
const { mode } = useTheme();

const contents = React.useMemo(() => {
const labelArray = Array.isArray(label) ? label : [label];

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

if (isExternal(href)) {
return (
<a href={href} title={href} rel="noopener noreferrer" target="_blank">
<a
href={href}
title={href}
style={{
color:
mode === 'light'
? theme.colors.info
: theme.colors.warningForeground,
}}
rel="noopener noreferrer"
target="_blank"
>
{contents}
</a>
);
}
return (
<a href={href} title={href}>
<a
href={href}
title={href}
style={{
color:
mode === 'light' ? theme.colors.info : theme.colors.warningForeground,
}}
>
{contents}
</a>
);
Expand Down
20 changes: 13 additions & 7 deletions packages/react/src/views/LinkPreview/LinkPreview.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React, { useState } from 'react';
import PropTypes from 'prop-types';
import { css } from '@emotion/react';
import {
Box,
ActionButton,
Expand All @@ -20,6 +19,7 @@ const LinkPreview = ({
}) => {
const { classNames, styleOverrides } = useComponentOverrides('LinkPreview');
const { theme } = useTheme();
const { mode } = useTheme();
const styles = getLinkPreviewStyles(theme);

const [isPreviewOpen, setIsPreviewOpen] = useState(true);
Expand Down Expand Up @@ -88,9 +88,12 @@ const LinkPreview = ({
<Box style={{ padding: '8px' }}>
<a
href={url}
css={css`
color: ${theme.colors.foreground};
`}
style={{
color:
mode === 'light'
? theme.colors.info
: theme.colors.warningForeground,
}}
target="_blank"
rel="noopener noreferrer"
>
Expand All @@ -100,9 +103,12 @@ const LinkPreview = ({
{isSiteName && (
<a
href={url}
css={css`
color: ${theme.colors.foreground};
`}
style={{
color:
mode === 'light'
? theme.colors.info
: theme.colors.warningForeground,
}}
target="_blank"
rel="noopener noreferrer"
>
Expand Down
Loading