Skip to content

Commit

Permalink
Merge pull request #1324 from push-protocol/skeleton-loading-dark-mode
Browse files Browse the repository at this point in the history
🐛 [BUG] - <Skeleton loading in dark mode appears like light mode in chat>
  • Loading branch information
corlard3y authored May 29, 2024
2 parents d8b026f + d8241be commit 8512e41
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ export const ChatPreview: React.FC<IChatPreviewProps> = (options: IChatPreviewPr
flex="initial"
cursor="pointer"
className={options.readmode ? 'skeleton' : ''}
animation={theme.skeletonBG}
>
<Message theme={theme}>
{options?.chatPreviewPayload?.chatMsg?.messageType === 'Image' ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export const EncryptionMessage = ({ id, className }: { id: EncryptionKeys; class
fontWeight="400"
textAlign="left"
className={className}
animation={theme.skeletonBG}
>
{EncryptionMessageContent[id].text}
</Span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export const ProfileContainer = ({ theme, member, copy, customStyle, loading }:
borderRadius="100%"
overflow="hidden"
className={loading ? 'skeleton' : ''}
animation={theme.skeletonBG}
>
{member?.icon && (
<Image
Expand Down Expand Up @@ -131,6 +132,7 @@ export const ProfileContainer = ({ theme, member, copy, customStyle, loading }:
setCopyText('Copied');
}}
className={loading ? 'skeleton' : ''}
animation={theme.skeletonBG}
>
<RecipientSpan
fontSize={member?.name || member?.web3Name ? '14px' : customStyle?.fontSize ?? '18px'}
Expand Down
33 changes: 32 additions & 1 deletion packages/uiweb/src/lib/components/chat/theme/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* @file theme file: all the predefined themes are defined here
*/
import { CHAT_THEME_OPTIONS } from '../exportedTypes';
import styled, { keyframes, css } from 'styled-components';
// bgColorPrimary: "#fff",
// bgColorSecondary: "#D53A94",
// textColorPrimary: "#1e1e1e",
Expand Down Expand Up @@ -191,10 +192,38 @@ export interface IChatTheme {
textColor?: ITextColor;
backdropFilter?: string;
scrollbarColor?: string;

skeletonBG?: any;
spinnerColor?: string;
}

const lightSkeletonLoading = keyframes`
0% {
background-color: hsl(200, 20%, 80%);
}
100% {
background-color: hsl(200, 20%, 95%);
}
`;

const darkSkeletonLoading = keyframes`
0% {
background-color: #575D73;
}
100% {
background-color: #6E748B;
}
`;

const animation = () =>
css`
${lightSkeletonLoading} 1s linear infinite alternate;
`;

const darkAnimation = () =>
css`
${darkSkeletonLoading} 1s linear infinite alternate;
`;

//dark theme object
export const lightChatTheme: IChatTheme = {
borderRadius: {
Expand Down Expand Up @@ -368,6 +397,7 @@ export const lightChatTheme: IChatTheme = {
backdropFilter: 'none',
spinnerColor: 'rgb(202, 89, 155)',
scrollbarColor: 'rgb(202, 89, 155)',
skeletonBG: animation
};

export const darkChatTheme: IChatTheme = {
Expand Down Expand Up @@ -541,4 +571,5 @@ export const darkChatTheme: IChatTheme = {
backdropFilter: 'none',
spinnerColor: 'rgb(202, 89, 155)',
scrollbarColor: 'rgb(202, 89, 155)',
skeletonBG: darkAnimation
};
26 changes: 10 additions & 16 deletions packages/uiweb/src/lib/components/reusables/sharedStyling.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
import styled, { keyframes } from 'styled-components';
import styled from 'styled-components';

// Define keyframes
const skeletonLoading = keyframes`
0% {
background-color: hsl(200, 20%, 80%);
}
100% {
background-color: hsl(200, 20%, 95%);
}
`;

// Define types and export components
type SectionStyleProps = {
Expand Down Expand Up @@ -45,6 +36,7 @@ type SectionStyleProps = {
visibility?: string;
zIndex?: string;
fontSize?: string;
animation?: string;
};

export const Section = styled.div<SectionStyleProps>`
Expand Down Expand Up @@ -84,7 +76,7 @@ export const Section = styled.div<SectionStyleProps>`
&.skeleton {
> * {
visibility: ${(props) => (props.visibility || skeletonLoading ? 'hidden' : 'visible')};
visibility: ${(props) => (props.visibility || props.animation ? 'hidden' : 'visible')};
}
&:after {
Expand All @@ -95,7 +87,7 @@ export const Section = styled.div<SectionStyleProps>`
left: 0;
right: 0;
z-index: 1;
animation: ${skeletonLoading} 1s linear infinite alternate;
animation: ${(props) => props.animation};
border-radius: 8px;
}
}
Expand All @@ -112,6 +104,7 @@ type DivStyleProps = {
borderRadius?: string;
textAlign?: string;
visibility?: string;
animation?: string;
};
export const Div = styled.div<DivStyleProps>`
height: ${(props) => props.height || 'auto'};
Expand All @@ -126,7 +119,7 @@ export const Div = styled.div<DivStyleProps>`
&.skeleton {
> * {
visibility: ${(props) => (props.visibility || skeletonLoading ? 'hidden' : 'visible')};
visibility: ${(props) => (props.visibility || props.animation ? 'hidden' : 'visible')};
}
&:after {
Expand All @@ -138,7 +131,7 @@ export const Div = styled.div<DivStyleProps>`
right: 0;
opacity: 1;
z-index: 1;
animation: ${skeletonLoading} 1s linear infinite alternate;
animation: ${(props) => props.animation};
border-radius: 8px;
}
}
Expand Down Expand Up @@ -170,6 +163,7 @@ type SpanStyleProps = {
whiteSpace?: string;
visibility?: string;
textWrap?: string;
animation?: string;
};

export const Span = styled.span<SpanStyleProps>`
Expand Down Expand Up @@ -201,7 +195,7 @@ export const Span = styled.span<SpanStyleProps>`
&.skeleton {
> * {
visibility: ${(props) => (props.visibility || skeletonLoading ? 'hidden' : 'visible')};
visibility: ${(props) => (props.visibility || props.animation ? 'hidden' : 'visible')};
}
&:after {
Expand All @@ -213,7 +207,7 @@ export const Span = styled.span<SpanStyleProps>`
right: 0;
opacity: 1;
z-index: 1;
animation: ${skeletonLoading} 1s linear infinite alternate;
animation: ${(props) => props.animation};
border-radius: 8px;
}
}
Expand Down

0 comments on commit 8512e41

Please sign in to comment.