Skip to content

Commit 89d608d

Browse files
committed
chore(docs): add Docusaurus components
For: - Class blocks - Codelab cards - Homepage features - Images
1 parent f5d792b commit 89d608d

5 files changed

Lines changed: 158 additions & 0 deletions

File tree

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import React from 'react';
2+
3+
/**
4+
* ClassBlock Component
5+
* Renders a block of content with a CSS class applied
6+
* Used for styling specific content blocks (e.g., compare-worse, compare-better)
7+
*
8+
* @param {string} className - The CSS class name to apply
9+
* @param {React.ReactNode} children - The content to render
10+
* @returns {JSX.Element}
11+
*/
12+
export default function ClassBlock({ className, children }) {
13+
return <p className={className}>{children}</p>;
14+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import React from 'react';
2+
import Link from '@docusaurus/Link';
3+
import styles from './styles.module.css';
4+
5+
// This component renders the grid layout
6+
export function CodelabGrid({ children }) {
7+
return <div className={styles.codelabGrid}>{children}</div>;
8+
}
9+
10+
// This component renders a single card
11+
export function CodelabCard({ href, title, description, children, level }) {
12+
return (
13+
<div className={styles.codelabCard}>
14+
<div className={styles.cardHeader}>
15+
<span className={styles.cardIcon}>{children}</span>
16+
</div>
17+
<div>
18+
<span className={styles.eyebrow}>{level}</span>
19+
</div>
20+
<div className={styles.cardFooter}>
21+
<h3 className={styles.cardTitle}>{title}</h3>
22+
<Link href={href}><span className={styles.cardButton}>Start</span></Link>
23+
</div>
24+
</div>
25+
);
26+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import clsx from 'clsx';
2+
import Heading from '@theme/Heading';
3+
import styles from './styles.module.css';
4+
5+
6+
const FeatureList = [
7+
{
8+
title: 'Accessible by design',
9+
Svg: require('@site/static/images/HomePage/Accessibility-tier-4.svg').default,
10+
description: (
11+
<>
12+
Built so everyone can engage with visual code — helping developers create experiences that are inclusive by default.
13+
</>
14+
),
15+
},
16+
{
17+
title: 'Built for flexibility',
18+
Svg: require('@site/static/images/HomePage/Explore-tier-4.svg').default,
19+
description: (
20+
<>
21+
An open-source library that adapts to your needs. With APIs, generators, and integrations, Blockly fits into most platforms, and environments.
22+
</>
23+
),
24+
},
25+
{
26+
title: 'Driven by community',
27+
Svg: require('@site/static/images/HomePage/Connect-tier-4.svg').default,
28+
description: (
29+
<>
30+
A global community of passionate developers and educators helps Blockly stay open, innovative, and ready for what’s next.
31+
</>
32+
),
33+
},
34+
];
35+
36+
function Feature({Svg, title, description}) {
37+
return (
38+
<div className={clsx('col col--4')}>
39+
<div className="text--center">
40+
<Svg className={styles.featureSvg} role="img" />
41+
</div>
42+
<div className="text--center padding-horiz--md">
43+
<Heading as="h2">{title}</Heading>
44+
<p>{description}</p>
45+
</div>
46+
</div>
47+
);
48+
}
49+
50+
export default function HomepageFeatures() {
51+
return (
52+
<section className={styles.features}>
53+
<div className="container">
54+
<div className="row">
55+
{FeatureList.map((props, idx) => (
56+
<Feature key={idx} {...props} />
57+
))}
58+
</div>
59+
</div>
60+
</section>
61+
);
62+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
.features {
2+
display: flex;
3+
align-items: center;
4+
padding: 3rem 0 5rem 0;
5+
width: 100%;
6+
}
7+
8+
.featureSvg {
9+
height: 200px;
10+
width: 200px;
11+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import React from 'react';
2+
import {useColorMode} from '@docusaurus/theme-common';
3+
4+
/**
5+
* Image component for use in MDX docs
6+
* Wraps HTML img tag with additional styling and responsiveness
7+
* Supports theme-based image loading (light/dark mode)
8+
*
9+
* @param {string} src - Image source path (for light mode)
10+
* @param {string} srcDark - Optional image source path for dark mode
11+
* @param {string} alt - Alt text for accessibility
12+
* @param {number|string} width - Optional width (in pixels)
13+
* @param {number|string} height - Optional height (in pixels)
14+
* @param {string} className - Optional CSS class for custom styling
15+
* @param {object} style - Optional inline styles
16+
*/
17+
export default function Image({ src, srcDark, alt, width, height, className, style = {}, ...props }) {
18+
const {colorMode} = useColorMode();
19+
20+
// Select image source based on current theme
21+
const imageSrc = colorMode === 'dark' && srcDark ? srcDark : src;
22+
23+
const imgStyle = {
24+
maxWidth: '100%',
25+
height: 'auto',
26+
...style,
27+
};
28+
29+
if (width) {
30+
imgStyle.width = typeof width === 'number' ? `${width}px` : width;
31+
}
32+
if (height) {
33+
imgStyle.height = typeof height === 'number' ? `${height}px` : height;
34+
}
35+
36+
return (
37+
<img
38+
src={imageSrc}
39+
alt={alt}
40+
className={className}
41+
style={{ ...imgStyle }}
42+
{...props}
43+
/>
44+
);
45+
}

0 commit comments

Comments
 (0)