Skip to content

Commit 7ecd915

Browse files
πŸ”§ Fix: SVG Loading Issues in Dark Mode for Case Studies (#1000)
* ✨ feat: Enhance UI components and assets - 🎨 Refactor (card): Reorder CSS classes for improved readability and consistency, enhancing maintainability by standardizing class order. - 🌐 Implement theme-based image URLs in case studies, adjusting image URLs based on the selected theme to improve layout structure and user experience. - πŸ†• Add new GitHub logo image file to maintain branding consistency. * 🎨 refactor ♻️(assets): Update logos to SVG format - Updated logo file format from PNG to SVG in case studies JSON - Refactored image URL transformation logic for clarity - Added new SVG files for 6river and GitHub logos in white - Deleted old GitHub logo image file These changes enhance logo quality and improve dark theme support.
1 parent 13c081f commit 7ecd915

File tree

6 files changed

+37
-3
lines changed

6 files changed

+37
-3
lines changed

β€Ždata/case-studies.jsonβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
{
33
"title": "How JSON Schema Was an Obvious Choice at GitHub",
44
"summary": "At GitHub's Docs Engineering team, while shipping releases to production 20 times per day or more, JSON Schema is critical in increasing confidence in changes to data, content and APIs.",
5-
"logo": "/img/logos/github-logo.png",
5+
"logo": "/img/logos/github-logo.svg",
66
"links": {
77
"lang": "URL1",
88
"url": "/blog/posts/github-case-study"

β€Žpages/overview/case-studies/index.page.tsxβ€Ž

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,22 @@ import { SectionContext } from '~/context';
66
import data from 'data/case-studies.json';
77
import Card from '~/components/Card';
88
import { DocsHelp } from '~/components/DocsHelp';
9+
import { useTheme } from 'next-themes';
910

1011
export default function ContentExample() {
1112
const newTitle = 'Case Studies';
1213
const markdownFile = '_indexPage';
14+
const { resolvedTheme } = useTheme();
15+
16+
const imgUrl = (src: string): string => {
17+
if (
18+
resolvedTheme === 'dark' &&
19+
['github', '6river'].some((str) => src.includes(str))
20+
) {
21+
return src.replace(/\.(svg)$/, '-white.$1');
22+
}
23+
return src;
24+
};
1325

1426
return (
1527
<SectionContext.Provider value='docs'>
@@ -23,13 +35,13 @@ export default function ContentExample() {
2335
Please replace this text with a two to three liner so that we can avoid
2436
the layout shifting bug.
2537
</p>
26-
<div className='w-full lg:w-full grid grid-cols-1 sm:grid-cols-2 gap-6 my-[10px] mx-auto mt-8'>
38+
<div className='mx-auto my-[10px] mt-8 grid w-full grid-cols-1 gap-6 sm:grid-cols-2 lg:w-full'>
2739
{data.map((element, index) => (
2840
<Card
2941
key={index}
3042
title={element.title}
3143
body={element.summary}
32-
image={element.logo}
44+
image={imgUrl(element.logo)}
3345
extended={true}
3446
link={element.links.url}
3547
/>
Lines changed: 11 additions & 0 deletions
Loading
-12.7 KB
Binary file not shown.
Lines changed: 11 additions & 0 deletions
Loading

0 commit comments

Comments
Β (0)