Skip to content

Commit ad24558

Browse files
committed
resolve theme conditionals for frontmatter thumbs
Signed-off-by: Randy Lau <[email protected]>
1 parent cbe6bf5 commit ad24558

File tree

19 files changed

+64
-66
lines changed

19 files changed

+64
-66
lines changed

context-wrapper.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@ import React from "react";
22
import { StyledThemeProvider } from "./src/theme/app/StyledThemeProvider";
33
import { ThemeManagerProvider } from "./src/theme/app/ThemeManager";
44
import lighttheme, { darktheme } from "./src/theme/app/themeStyles";
5-
import { GlobalStyle } from "./src/sections/app.style";
65

76
export const ContextWrapper = ({ children }) => {
87
return (
98
<ThemeManagerProvider>
109
<StyledThemeProvider lightTheme={lighttheme} darkTheme={darktheme}>
11-
<GlobalStyle />
1210
{children}
1311
</StyledThemeProvider>
1412
</ThemeManagerProvider>

src/components/Card/Card.style.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export const CardWrapper = styled.div`
66
border-radius: 0.5rem;
77
background-Color:${props => props.theme.grey212121ToWhite};
88
box-shadow: 0px 2px 6px 0px ${props => props.theme.green00D3A9ToBlackTwo};
9-
transition: all 0.3s ease-in;
9+
transition: 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
1010
&:hover{
1111
box-shadow: 0px 2px 15px 4px ${props => props.theme.whiteNineToBlackOne};
1212
.post-thumb-block{

src/components/Card/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ import { useStyledDarkMode } from "../../theme/app/useStyledDarkMode";
99
const Card = ({ frontmatter, fields }) => {
1010

1111
const { isDark } = useStyledDarkMode();
12-
const theme = isDark ? "dark" : "light";
1312

1413
return (
1514
<CardWrapper fixed={!!frontmatter.abstract}>
1615
<div className="post-block">
1716
<div className="post-thumb-block">
1817
<Image
19-
{...(theme === "dark" ? frontmatter.darkthumbnail : frontmatter.thumbnail)}
18+
{...((isDark && frontmatter.darkthumbnail.publicURL !== frontmatter.thumbnail.publicURL)
19+
? frontmatter.darkthumbnail : frontmatter.thumbnail)}
2020
imgStyle={{ objectFit: "contain" }}
2121
alt={frontmatter.title}
2222
/>

src/components/blog-view-tooltip.js

Lines changed: 35 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from "react";
1+
import React, { useState, useEffect } from "react";
22
import { Row } from "../reusecore/Layout";
33
import { TiThList } from "@react-icons/all-files/ti/TiThList";
44
import { BsGrid3X3GapFill } from "@react-icons/all-files/bs/BsGrid3X3GapFill";
@@ -36,43 +36,59 @@ export const ToolTipWrapper = styled.div`
3636
`;
3737

3838
const BlogViewToolTip = ({ isListView, setListView, setGridView }) => {
39+
40+
const NoSsr = ({ children }) => {
41+
const [isMounted, setMount] = useState(false);
42+
43+
useEffect(() => {
44+
setMount(true);
45+
}, []);
46+
47+
return <>{isMounted ? children : null}</>;
48+
};
49+
3950
return (
4051
<ToolTipWrapper>
4152
<Row className="border">
4253
<a
4354
data-tip="Grid View"
4455
data-for="grid-view"
4556
onClick={setGridView}
46-
className={`${isListView ? "" : "active"}`}
57+
className={`${!isListView && "active"}`}
4758
>
4859
<BsGrid3X3GapFill size={22} />
4960
</a>
50-
<ReactTooltip
51-
id="grid-view"
52-
border
53-
className="grid-view"
54-
backgroundColor="black"
55-
place="top"
56-
effect="solid"
57-
/>
61+
<NoSsr>
62+
<ReactTooltip
63+
id="grid-view"
64+
border
65+
className="grid-view"
66+
backgroundColor="black"
67+
place="top"
68+
effect="solid"
69+
/>
70+
</NoSsr>
5871
<a
5972
data-tip="List View"
6073
data-for="list-view"
6174
onClick={setListView}
62-
className={`${isListView ? "active" : ""}`}
75+
className={`${isListView && "active"}`}
6376
>
6477
<TiThList size={22} />
6578
</a>
66-
<ReactTooltip
67-
id="list-view"
68-
className="list-view"
69-
backgroundColor="black"
70-
place="top"
71-
type="dark"
72-
effect="solid"
73-
/>
79+
<NoSsr>
80+
<ReactTooltip
81+
id="list-view"
82+
className="list-view"
83+
backgroundColor="black"
84+
place="top"
85+
type="dark"
86+
effect="solid"
87+
/>
88+
</NoSsr>
7489
</Row>
7590
</ToolTipWrapper>
91+
7692
);
7793
};
7894

src/components/image.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
import React from "react";
22
import { GatsbyImage } from "gatsby-plugin-image";
33

4-
54
const Image = ({ childImageSharp, extension, publicURL, alt, ...rest }) => {
5+
66
if (!childImageSharp && extension === "svg") {
77
return (
88
<div className="old-gatsby-image-wrapper">
99
<img src={publicURL} alt={alt} />
1010
</div>
1111
);
12-
} else {
13-
return <GatsbyImage image={childImageSharp.gatsbyImageData} {...rest} alt={alt} />;
1412
}
13+
14+
return <GatsbyImage
15+
key={publicURL} image={childImageSharp.gatsbyImageData} {...rest} alt={alt}/>;
1516
};
1617

1718
export default Image;

src/components/layout.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@ import PropTypes from "prop-types";
1212
import ScrollToTopBtn from "./Scrolltotop-button";
1313
import Navigation from "../sections/General/Navigation";
1414
import Footer from "../sections/General/Footer";
15+
import { GlobalStyle } from "../sections/app.style";
1516

1617
const Layout = ({ children }) => {
1718

1819
return (
1920
<>
21+
<GlobalStyle />
2022
<Navigation/>
2123
{children}
2224
<ScrollToTopBtn />

src/pages/blog/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import React, { useState, useEffect } from "react";
2-
32
import SEO from "../../components/seo";
43
import BlogGrid from "../../sections/Blog/Blog-grid";
5-
64
import { graphql } from "gatsby";
75
import loadable from "@loadable/component";
86
const BlogList = loadable(() => import ("../../sections/Blog/Blog-list"));
7+
98
export const query = graphql`
109
query allBlogs {
1110
allMdx(
@@ -44,6 +43,7 @@ export const query = graphql`
4443
}
4544
}
4645
`;
46+
4747
const Blog = (props) => {
4848
const [isListView, setIsListView] = useState(false);
4949
const setListView = () => {

src/sections/Blog/Blog-grid/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ const BlogGrid = ({
6464

6565
{searchedPosts.length > 0 && searchedPosts.map(({ id, frontmatter, fields }) => (
6666
<Col key={id} xs={12} sm={6}>
67-
<Card frontmatter={frontmatter} fields={fields} />
67+
<Card frontmatter={frontmatter} fields={fields} />
6868
</Col>
6969
))}
7070
<Col>

src/sections/Blog/Blog-single/index.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ const BlogSingle = ({ data }) => {
9292

9393
const [copied, setCopied] = useState(false);
9494
const { isDark } = useStyledDarkMode();
95-
const theme = isDark ? "dark" : "light";
9695

9796
useEffect(() => {
9897
if (copied) {
@@ -116,10 +115,9 @@ const BlogSingle = ({ data }) => {
116115
subtitle={frontmatter.subtitle}
117116
category={frontmatter.category}
118117
author={{ name: frontmatter.author }}
119-
thumbnail={(theme === "dark" ? frontmatter.darkthumbnail : frontmatter.thumbnail)}
118+
thumbnail={(isDark ? frontmatter.darkthumbnail : frontmatter.thumbnail)}
120119
darkthumbnail={frontmatter.thumbnail}
121120
date={frontmatter.date}
122-
123121
/>
124122
<div className="single-post-wrapper">
125123
<SRLWrapper>

src/sections/Careers/Careers-Programs-grid/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ const ProgramsGrid = ({ hide_path, sub_section }) => {
4646
let path = hide_path ? "" : "Programs";
4747
let programsArray = [];
4848
const { isDark } = useStyledDarkMode();
49-
const theme = isDark ? "dark" : "light";
5049

5150
const programs = data.allMdx.nodes.filter((item) => {
5251
if (programsArray.indexOf(item.frontmatter.program) >= 0) {
@@ -76,7 +75,7 @@ const ProgramsGrid = ({ hide_path, sub_section }) => {
7675
<div className={`program ${sub_section ? "sub-section_program" : ""}`}>
7776
<div className={`icon ${sub_section ? "sub-section_icon" : ""}`}>
7877
<Image
79-
{...(frontmatter.darkthumbnail !== null && theme === "dark" ? frontmatter.darkthumbnail : frontmatter.thumbnail)}
78+
{...(frontmatter.darkthumbnail !== null && isDark ? frontmatter.darkthumbnail : frontmatter.thumbnail)}
8079
imgStyle={{ objectFit: "contain" }}
8180
alt={frontmatter.title}
8281
/>

src/sections/General/Navigation/utility/ScrollspyMenu.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,17 @@ import SupportingArrows from "../../../../sections/Meshmap/Meshmap-collaborate/i
1212
import EmptyLight from "../../../../sections/Meshmap/Meshmap-collaborate/images/banner-transitions/empty-light.svg";
1313
import EmptyDark from "../../../../sections/Meshmap/Meshmap-collaborate/images/banner-transitions/empty-dark.svg";
1414
import { useInView } from "react-intersection-observer";
15+
import { useStyledDarkMode } from "../../../../theme/app/StyledThemeProvider";
1516

16-
const ScrollspyMenu = ({ menuItems, theme, ...props }) => {
17+
const ScrollspyMenu = ({ menuItems, ...props }) => {
1718
const { blogData,className } = props;
1819

1920
const addAllClasses = className ? [className] : [""];
2021
const [activeState,setActiveState] = useState(null);
2122

2223
const [isWrapVisible,setIsWrapperVisible] = useState(false);
2324
const [imageInView, setimageInView] = useState(false);
25+
const { isDark } = useStyledDarkMode();
2426

2527
const handleMouseOver = (index) => {
2628
setActiveState(menuItems[index]);
@@ -107,7 +109,7 @@ const ScrollspyMenu = ({ menuItems, theme, ...props }) => {
107109
<Link to="/cloud-native-management/meshmap">
108110
<div className="single-card">
109111
<div className="transition-container" ref={transitionRef}>
110-
<img className="canvas" src={theme == "dark" ? EmptyDark : EmptyLight} alt="" />
112+
<img className="canvas" src={isDark ? EmptyDark : EmptyLight} alt="" />
111113
<ServiceIntefaceImage className="service-interface" alt="ServiceIntefaceImage" />
112114
<IngressGatewayImage alt="IngressGatewayImage" className={imageInView ? "ingress-gateway-transition ingress-gateway" : "ingress-gateway"}/>
113115
<KubernetesImage className={imageInView ? "kubernetes-transition kubernetes" : "kubernetes"} alt="KubernetesImage" />

src/sections/Home/So-Special-Section/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ const SoSpecial = () => {
9999
};
100100

101101
const { isDark } = useStyledDarkMode();
102-
const theme = isDark ? "dark" : "light";
103102

104103
return (
105104
<SoSpecialWrapper>
@@ -115,7 +114,7 @@ const SoSpecial = () => {
115114
<div id="special-cont" >
116115
<div id="special-cont_img">
117116
<Image
118-
{...(theme === "dark" ? frontmatter.darkthumbnail : frontmatter.thumbnail)}
117+
{...(isDark ? frontmatter.darkthumbnail : frontmatter.thumbnail)}
119118
imgStyle={{ objectFit: "contain" }}
120119
alt={frontmatter.title}
121120
/>

src/sections/Landscape/ServiceMeshTimeline.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ const ServiceMeshTimeline = () => {
2727
const [elements, setElements] = useState(initialMeshes);
2828
const [loadedAll, showIcon] = useState(false);
2929
const { isDark } = useStyledDarkMode();
30-
const theme = isDark ? "dark" : "light";
3130

3231
const loadMore = () => {
3332
setElements([...elements, ...remainingMeshes]);
@@ -46,7 +45,7 @@ const ServiceMeshTimeline = () => {
4645
>
4746
{mesh.icon ?
4847
<div className={`meshtitle-img-${mesh.timeline_order % 2}`}>
49-
<img src={theme === "dark" ? mesh?.darkIcon || mesh.icon : mesh.icon} alt={mesh.name} className={mesh.name === "Vulcand" ? "vulcan-img" : ""} />
48+
<img src={isDark ? mesh?.darkIcon || mesh.icon : mesh.icon} alt={mesh.name} className={mesh.name === "Vulcand" ? "vulcan-img" : ""} />
5049
</div>
5150
: <div className={`meshtitle-img-${mesh.timeline_order % 2}`}>
5251
<img src={ServiceMeshIcon} alt={mesh.name} />

src/sections/Meshery/Meshery-integrations/IntegrationsGrid.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ const IntegrationsGrid = ({ category, count }) => {
8787
const [hideFilter, setHideFilter] = useState(false);
8888
const allIntegrations = useRef(data.allMdx.nodes);
8989
const { isDark } = useStyledDarkMode();
90-
const theme = isDark ? "dark" : "light";
9190

9291
// fetch all the category names from activeIntegrationList and remove the duplicate category names
9392
const categoryNames = allIntegrations.current.reduce(
@@ -283,7 +282,7 @@ const IntegrationsGrid = ({ category, count }) => {
283282
<img
284283
className="integration-icon"
285284
src={
286-
theme === "dark" && darkModeIntegrationIcon !== null
285+
isDark && darkModeIntegrationIcon !== null
287286
? darkModeIntegrationIcon.publicURL
288287
: integrationIcon
289288
}
@@ -311,7 +310,7 @@ const IntegrationsGrid = ({ category, count }) => {
311310
<img
312311
className="integration-icon"
313312
src={
314-
theme === "dark" && darkModeIntegrationIcon !== null
313+
isDark && darkModeIntegrationIcon !== null
315314
? darkModeIntegrationIcon.publicURL
316315
: integrationIcon
317316
}
@@ -320,7 +319,7 @@ const IntegrationsGrid = ({ category, count }) => {
320319
width={70}
321320
style={{
322321
filter:
323-
theme === "dark" && darkModeIntegrationIcon == null
322+
isDark && darkModeIntegrationIcon == null
324323
? "brightness(0) invert(1)"
325324
: "none",
326325
}}

src/sections/Meshmap/Meshmap-collaborate/meshmap-collaborate-banner.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,6 @@ const MeshmapCollaborateBanner = () => {
184184
setimageInView(false);
185185

186186
const { isDark } = useStyledDarkMode();
187-
const theme = isDark ? "dark" : "light";
188187

189188
return (
190189
<CollaborationBannerWrapper>
@@ -195,7 +194,7 @@ const MeshmapCollaborateBanner = () => {
195194
<Button primary className="join-community-button" title="Start Collaborating" url="/projects" />
196195
</div>
197196
<div className="transition-container" ref={transitionRef}>
198-
<img className="canvas" src={theme == "dark" ? EmptyDark : EmptyLight} alt="" />
197+
<img className="canvas" src={isDark ? EmptyDark : EmptyLight} alt="" />
199198
<div>
200199
<ServiceIntefaceImage className="service-interface" alt="ServiceIntefaceImage" />
201200
</div>

src/sections/Meshmap/Meshmap-design/meshmap-design-hero.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,12 @@ const MeshmapHeroSection = () => {
8282
setimageInView(false);
8383

8484
const { isDark } = useStyledDarkMode();
85-
const theme = isDark ? "dark" : "light";
8685

8786
return (
8887
<HeroSectionWrapper>
8988
<div className="hero-image">
90-
<img className={imageInView ? "locator-moving" : "locator"} src={theme === "dark" ? MeshmapLocatorDark : MeshmapLocatorLight} alt="locator" />
91-
<img className={imageInView ? "map map-visible" : "map"} src={theme === "dark" ? MeshmapImageBottomDark : MeshmapImageBottomLight} alt="integrations" ref={locatorRef} />
89+
<img className={imageInView ? "locator-moving" : "locator"} src={isDark ? MeshmapLocatorDark : MeshmapLocatorLight} alt="locator" />
90+
<img className={imageInView ? "map map-visible" : "map"} src={isDark ? MeshmapImageBottomDark : MeshmapImageBottomLight} alt="integrations" ref={locatorRef} />
9291
</div>
9392
<div className="hero-text">
9493
<h1><span>Design your infrastructure</span></h1>

src/sections/Meshmap/Meshmap-visualize/meshmap-visualize-features.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ const MeshmapVisualizerFeatures = () => {
122122
const [hoveredFeature, sethoveredFeature] = useState("");
123123

124124
const { isDark } = useStyledDarkMode();
125-
const theme = isDark ? "dark" : "light";
126125

127126
const handleMouseOver = (num) => {
128127
setisHovered(true);
@@ -181,7 +180,7 @@ const MeshmapVisualizerFeatures = () => {
181180
<Col sm={12} md={6} lg={4}>
182181
<div className={(isHovered && hoveredFeature != "Feature5") ? "project__block__inner darken" : "project__block__inner"} onMouseOver={() => handleMouseOver(5)} onMouseOut={handleMouseOut}>
183182
<div className="feature-image">
184-
<img src={theme == "dark" ? ServicePerformanceGearDark : ServicePerformanceGearLight} alt="Service Performance" style={{ position: "absolute", zIndex: "0" }} />
183+
<img src={isDark ? ServicePerformanceGearDark : ServicePerformanceGearLight} alt="Service Performance" style={{ position: "absolute", zIndex: "0" }} />
185184
<ServicePerformanceMeter alt="" className={hoveredFeature == "Feature5" ? "meter-visible" : "secondary-image"}
186185
style={{ height: "auto", width: "70%",position: "relative", zIndex: "10", transformOrigin: "center center" }}
187186
/>

0 commit comments

Comments
 (0)