Skip to content

Commit d942614

Browse files
committed
Add FeatureGroup component
1 parent cce8771 commit d942614

File tree

4 files changed

+116
-30
lines changed

4 files changed

+116
-30
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"features": [
3+
{
4+
"title": "AI Native",
5+
"description": "AIscript is designed to be the first-class language for AI development. It is designed to be easy to learn and use, and it is designed to be fast and efficient.",
6+
"code": "// Define a function that takes a prompt and returns a response\nfn generate_response(prompt: string) -> string {\n // Call the AI model to generate a response\n let response = ai.generate({\n model: \"gpt-4\",\n prompt: prompt,\n max_tokens: 100\n });\n \n return response;\n}\n\n// Example usage\nlet result = generate_response(\"Tell me a joke\");\nprint(result);",
7+
"filename": "main.ai"
8+
},
9+
{
10+
"title": "Type Safe",
11+
"description": "AIscript comes with a powerful type system that helps catch errors before they happen. The type system is designed to be intuitive and easy to use.",
12+
"code": "// Define a function that takes a prompt and returns a response\nfn generate_response(prompt: string) -> string {\n // Call the AI model to generate a response\n let response = ai.generate({\n model: \"gpt-4\",\n prompt: prompt,\n max_tokens: 100\n });\n \n return response;\n}\n\n// Example usage\nlet result = generate_response(\"Tell me a joke\");\nprint(result);",
13+
"filename": "main.ai",
14+
"isReversed": true
15+
}
16+
]
17+
}

theme/components/Landingpage/index.tsx

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,11 @@
11
import { BackgroundImage } from '../background-image';
22
import { Hero } from '../hero';
3-
// import CodeDemo from '../code-demo';
4-
import FeatureDemo from '../feature-demo';
3+
import FeatureGroup from '../feature-group';
54
import styles from './index.module.scss';
65

76
import { useCallback } from 'react';
87
import { useNavigate } from 'rspress/runtime';
9-
10-
const demoCode = `// Define a function that takes a prompt and returns a response
11-
fn generate_response(prompt: string) -> string {
12-
// Call the AI model to generate a response
13-
let response = ai.generate({
14-
model: "gpt-4",
15-
prompt: prompt,
16-
max_tokens: 100
17-
});
18-
19-
return response;
20-
}
21-
22-
// Example usage
23-
let result = generate_response("Tell me a joke");
24-
print(result);`;
8+
import { features } from './features.json';
259

2610
const LandingPage = () => {
2711
const navigate = useNavigate();
@@ -39,18 +23,7 @@ const LandingPage = () => {
3923
githubURL="https://github.com/aiscriptdev/aiscript"
4024
onClickGetStarted={onClickGetStarted}
4125
/>
42-
<FeatureDemo
43-
title='AI Native'
44-
description='AIscript is designed to be the first-class language for AI development. It is designed to be easy to learn and use, and it is designed to be fast and efficient.'
45-
code={demoCode}
46-
filename='main.ai' />
47-
48-
<FeatureDemo
49-
title='AI Native'
50-
description='AIscript is designed to be the first-class language for AI development. It is designed to be easy to learn and use, and it is designed to be fast and efficient.'
51-
code={demoCode}
52-
isReversed={true}
53-
filename='main.ai' />
26+
<FeatureGroup features={features} />
5427
</div>
5528
);
5629
};
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
.featureGroup {
2+
width: 100%;
3+
max-width: 1200px;
4+
margin: 0 auto;
5+
padding: 2rem;
6+
}
7+
8+
.tabs {
9+
display: flex;
10+
gap: 1rem;
11+
margin-bottom: 2rem;
12+
justify-content: center;
13+
flex-wrap: wrap;
14+
}
15+
16+
.tab {
17+
padding: 0.75rem 1.5rem;
18+
border: none;
19+
border-radius: 25px;
20+
background: transparent;
21+
color: var(--rstack-hero-desc-color, #6b7075);
22+
font-size: 1rem;
23+
font-weight: 600;
24+
cursor: pointer;
25+
transition: all 0.2s ease-in-out;
26+
27+
&:hover {
28+
color: var(--rs-hero-title-color, #0b0c0e);
29+
background: rgba(0, 0, 0, 0.05);
30+
}
31+
32+
&.active {
33+
background: linear-gradient(279deg, #ff8b00 35.21%, #f93920 63.34%);
34+
color: white;
35+
}
36+
}
37+
38+
@media screen and (max-width: 768px) {
39+
.featureGroup {
40+
padding: 1rem;
41+
}
42+
43+
.tabs {
44+
gap: 0.5rem;
45+
margin-bottom: 1rem;
46+
}
47+
48+
.tab {
49+
padding: 0.5rem 1rem;
50+
font-size: 0.875rem;
51+
}
52+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { type FC, useState } from 'react';
2+
import FeatureDemo from '../feature-demo';
3+
import styles from './index.module.scss';
4+
5+
interface Feature {
6+
title: string;
7+
description: string;
8+
code: string;
9+
filename?: string;
10+
isReversed?: boolean;
11+
}
12+
13+
interface FeatureGroupProps {
14+
features: Feature[];
15+
}
16+
17+
const FeatureGroup: FC<FeatureGroupProps> = ({ features }) => {
18+
const [activeIndex, setActiveIndex] = useState(0);
19+
20+
return (
21+
<div className={styles.featureGroup}>
22+
<div className={styles.tabs}>
23+
{features.map((feature, index) => (
24+
<button
25+
key={index}
26+
className={`${styles.tab} ${index === activeIndex ? styles.active : ''}`}
27+
onClick={() => setActiveIndex(index)}
28+
>
29+
{feature.title}
30+
</button>
31+
))}
32+
</div>
33+
<FeatureDemo
34+
title={features[activeIndex].title}
35+
description={features[activeIndex].description}
36+
code={features[activeIndex].code}
37+
filename={features[activeIndex].filename}
38+
isReversed={features[activeIndex].isReversed}
39+
/>
40+
</div>
41+
);
42+
};
43+
44+
export default FeatureGroup;

0 commit comments

Comments
 (0)