Skip to content

Commit 1fe19ff

Browse files
authored
adding hypelinks to TryNow pages (#74)
* added hypelinks to TryNow pages * resolved conflicts in the PR * formatted StepsToUse.tsx properly
1 parent 8c18d53 commit 1fe19ff

File tree

12 files changed

+289
-7
lines changed

12 files changed

+289
-7
lines changed

package-lock.json

Lines changed: 26 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@
1919
},
2020
"dependencies": {
2121
"@tailwindcss/vite": "^4.0.4",
22+
"@types/dompurify": "^3.0.5",
2223
"class-variance-authority": "^0.7.1",
2324
"clsx": "^2.1.1",
25+
"dompurify": "^3.2.4",
2426
"framer-motion": "^12.5.0",
2527
"lucide-react": "^0.476.0",
2628
"react": "^19.0.0",

src/components/TryNow/Paragraph.tsx

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
11
import React from 'react';
22
import { motion } from 'framer-motion';
33
import { paragraphAnimations } from '@/styles/Animations';
4+
import DOMPurify from 'dompurify';
5+
import { renderContentWithLinks } from '@/utils/renderlinks-utils';
46

57
interface ParagraphProps {
68
title: string;
79
content: string;
810
button?: string | null;
11+
links?: { text: string; url: string }[] | null;
912
}
1013

11-
const Paragraph: React.FC<ParagraphProps> = ({ title, content, button }) => {
14+
const Paragraph: React.FC<ParagraphProps> = ({
15+
title,
16+
content,
17+
button,
18+
links,
19+
}) => {
1220
const contentPoints = content.includes('\n')
1321
? content.split('\n')
1422
: [content];
@@ -39,7 +47,13 @@ const Paragraph: React.FC<ParagraphProps> = ({ title, content, button }) => {
3947
custom={index}
4048
variants={paragraphAnimations.listItem(index)}
4149
>
42-
{point.trim()}
50+
<span
51+
dangerouslySetInnerHTML={{
52+
__html: DOMPurify.sanitize(
53+
renderContentWithLinks(point.trim(), links),
54+
),
55+
}}
56+
/>
4357
</motion.li>
4458
))}
4559
</ul>
@@ -48,7 +62,13 @@ const Paragraph: React.FC<ParagraphProps> = ({ title, content, button }) => {
4862
className="text-gray-700 mt-4"
4963
variants={paragraphAnimations.text}
5064
>
51-
{content}
65+
<div
66+
dangerouslySetInnerHTML={{
67+
__html: DOMPurify.sanitize(
68+
renderContentWithLinks(content, links),
69+
),
70+
}}
71+
/>
5272
</motion.p>
5373
)}
5474

src/components/TryNow/StepsToUse.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import { Carousel } from 'react-responsive-carousel';
33
import { ArrowLeft, ArrowRight } from 'lucide-react';
44
import { steps } from '@/constants/TryNowData/bootableSoasData';
55
import { useState } from 'react';
6+
import DOMPurify from 'dompurify';
7+
import { renderContentWithLinks } from '@/utils/renderlinks-utils';
68

79
const StepsToUse = () => {
810
const [currentStep, setCurrentStep] = useState(0);
@@ -41,7 +43,15 @@ const StepsToUse = () => {
4143
<h3 className="text-2xl font-semibold text-black mt-1">
4244
{step.title}
4345
</h3>
44-
<p className="text-gray-700 mt-2">{step.description}</p>
46+
<p
47+
className="text-gray-700 mt-2"
48+
dangerouslySetInnerHTML={{
49+
__html: DOMPurify.sanitize(
50+
renderContentWithLinks(step.description, step.links),
51+
),
52+
}}
53+
/>
54+
4555
<img
4656
src={step.image}
4757
alt={step.title}

src/constants/TryNowData/bootableSoasData.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ interface StepData {
1313
title: string;
1414
description: string;
1515
image: string;
16+
links?: { text: string; url: string }[];
1617
}
1718

1819
export const steps: StepData[] = [
@@ -21,6 +22,12 @@ export const steps: StepData[] = [
2122
title: 'Sugar On a Stick',
2223
description:
2324
'To boot Sugar Labs OS on your computer, you will need a bootable Sugar on Stick setup already. To see how to set it up, visit the wiki.',
25+
links: [
26+
{
27+
text: 'wiki',
28+
url: 'https://wiki.sugarlabs.org/go/Sugar_on_a_Stick/Installation',
29+
},
30+
],
2431
image: 'assets/TryNowImages/step1.jpg',
2532
},
2633
{
@@ -64,6 +71,12 @@ export const steps: StepData[] = [
6471
description:
6572
'After selecting the USB drive, your computer should boot into the Sugar OS interface. If you encounter any issues during the boot process, seek assistance in the Sugar Labs Matrix room. For detailed instructions and additional resources, visit the Sugar Labs Booting SoaS page.',
6673
image: 'assets/TryNowImages/step7.png',
74+
links: [
75+
{
76+
text: 'Matrix room',
77+
url: 'https://matrix.to/#/#sugar:matrix.org',
78+
},
79+
],
6780
},
6881
];
6982

src/constants/TryNowData/musicBlocksData.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,36 @@ export const musicBlocksSections = [
3030
content:
3131
'Music Blocks is designed to run in the browser. It is derived from Turtle Blocks JS which can be found here. You can run the software locally from the index.html file, from the GitHub repository, or by setting up a local server. If you want to run Music Blocks offline, download this repo and point your browser to the index.html file found in the musicblocks directory on your local file system. See Using Music Blocks and Music Blocks Guide',
3232
button: 'Try Music Blocks Now',
33+
links: [
34+
{
35+
text: 'here',
36+
url: 'https://github.com/sugarlabs/turtleblocksjs',
37+
},
38+
{
39+
text: 'Github',
40+
url: 'https://github.com/sugarlabs/musicblocks/',
41+
},
42+
{
43+
text: 'Using Music Blocks',
44+
url: 'http://github.com/sugarlabs/musicblocks/tree/master/documentation',
45+
},
46+
{
47+
text: 'Music Blocks Guide',
48+
url: 'http://github.com/sugarlabs/musicblocks/tree/master/guide',
49+
},
50+
],
3351
},
3452
{
3553
title: 'Credits',
3654
content:
3755
'Music Blocks is a fork of TurtleArtJS created by Walter Bender. (Turtle Blocks JS has many contributors).\n Devin Ulibarri has contributed functional and user-interface designs. Many of his contributions were inspired by the music education ideas, representations and practices (e.g. aspects of matrix, musical cups) developed and published by Dr. Lawrence Scripp with whom Devin studied at New England Conservatory and for whom he worked at Affron Scripp & Associates, LLC.\n Much of the initial coding of the fork from Turtle Blocks was done by Yash Khandelwal as part of Google Summer of Code (GSoC) 2015. Hemant Kasat contributed to additional widgets as part of GSoC 2016. Additional contributions are being made by Tayba Wasim, Dinuka Tharangi Jayaweera, Prachi Agrawal, Cristina Del Puerto, and Hrishi Patel as part of GSoC 2017. During GSoC 2018, Riya Lohia developed a Temperament Widget. Ritwik Abhishek added a keyboard widget and a pitch-tracking widget.\n Many students contributed to the project as part of Google Code-in (2015–16, 2016–17, and 2017–2018). Sam Parkinson built the Planet during GCI 2016–17. Euan Ong redesigned the Planet code as a series of GCI tasks in 2017–18.',
3856
button: null,
57+
links: [
58+
{
59+
text: 'contributors',
60+
url: 'https://github.com/sugarlabs/turtleblocksjs/graphs/contributors',
61+
},
62+
],
3963
},
4064
];
4165

@@ -51,6 +75,12 @@ export const foundabug = [
5175
{
5276
title: 'Found a Bug?',
5377
content: 'Report it in the issues section of THIS repository.',
78+
links: [
79+
{
80+
text: 'issues',
81+
url: 'https://github.com/sugarlabs/musicblocks/issues',
82+
},
83+
],
5484
button: null,
5585
},
5686
];
@@ -66,6 +96,7 @@ export const musicBlocksLogoCards = [
6696
{
6797
text: 'Trying out Music Blocks',
6898
link: 'https://musicblocks.sugarlabs.org/',
99+
target: '_blank',
69100
},
70101
],
71102
},
@@ -79,6 +110,7 @@ export const musicBlocksLogoCards = [
79110
{
80111
text: 'Go to Youtube channel',
81112
link: 'https://www.youtube.com/channel/UCdXacR2zOXff4XCKRLTSnRw',
113+
target: '_blank',
82114
},
83115
],
84116
},
@@ -92,6 +124,7 @@ export const musicBlocksLogoCards = [
92124
{
93125
text: 'Go to Youtube channel',
94126
link: 'https://www.youtube.com/channel/UCdXacR2zOXff4XCKRLTSnRw',
127+
target: '_blank',
95128
},
96129
],
97130
},
@@ -105,6 +138,7 @@ export const musicBlocksLogoCards = [
105138
{
106139
text: 'Download PDF file',
107140
link: 'https://gakken-steam.jp/music_blocks/common/pdf/challengeprint.zip',
141+
target: '_blank',
108142
},
109143
],
110144
},

src/constants/TryNowData/raspberryPiData.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,51 @@ export const raspberrySections = [
1414
content:
1515
'As of August 2017, the best to use is Sugar on a Stick, as it has many activities and has regular security updates. See Sugar on a Stick/Raspberry Pi for how to download and install it. Sugar on a Stick is a spin of Fedora.',
1616
button: '',
17+
links: [
18+
{
19+
text: 'Sugar on a Stick/Raspberry Pi',
20+
url: 'https://wiki.sugarlabs.org/go/Sugar_on_a_Stick/Raspberry_Pi',
21+
},
22+
],
1723
},
1824
{
1925
title: 'Other methods to get Sugar on Raspberry Pi?',
2026
content:
2127
'using Raspbian, the most common operating system on a Raspberry Pi, a derivative of Debian\n using Fedora\n using Debian\n using Ubuntu',
2228
button: '',
29+
links: [
30+
{
31+
text: 'Raspbian',
32+
url: 'https://wiki.sugarlabs.org/go/Raspbian',
33+
},
34+
{
35+
text: 'Fedora',
36+
url: 'https://github.com/sugarlabs/sugar/blob/master/docs/fedora.md',
37+
},
38+
{
39+
text: 'Debian',
40+
url: 'https://github.com/sugarlabs/sugar/blob/master/docs/debian.md',
41+
},
42+
{
43+
text: 'Ubuntu',
44+
url: 'https://github.com/sugarlabs/sugar/blob/master/docs/ubuntu.md',
45+
},
46+
],
2347
},
2448
{
2549
title: 'Developers',
2650
content:
2751
'Developers may focus on Fedora or Debian when setting up a development environment for Sugar on Raspberry Pi, because Sugar development on generic computers is focused on those operating systems.',
2852
button: '',
53+
links: [
54+
{
55+
text: 'Fedora',
56+
url: 'https://github.com/sugarlabs/sugar/blob/master/docs/fedora.md',
57+
},
58+
{
59+
text: 'Debian',
60+
url: 'https://github.com/sugarlabs/sugar/blob/master/docs/debian.md',
61+
},
62+
],
2963
},
3064
];

0 commit comments

Comments
 (0)