Skip to content

Commit 49a6124

Browse files
authored
Hackathon details (#348)
* fix: modify api.ts * fix: remove google auth buttom * fix: fixes responsive fixes on organization * fix: minor fixes * fix: modify create organization * fix: modify create organization * fix: fix organization permission * fix: merge into main * feat: hackathon overview page * feat: hackathon overview page * feat: implement participant overview * feat: implement participant overview * feat: implement resources tab * feat: implement the submission tab * feat: implement comment tab * fix: implement provider for hackathon * fix: implement provider for hackathon * fix: minor fixes * fix: hackathon banner * fix: hackathon banner * fix: fix organization page * fix: fix organization page
1 parent 17694d4 commit 49a6124

5 files changed

Lines changed: 74 additions & 6 deletions

File tree

components/hackathons/hackathonBanner.tsx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ import { Card } from '@/components/ui/card';
44
import { Badge } from '@/components/ui/badge';
55
import { formatDate } from '@/lib/utils';
66
import { useEffect, useState } from 'react';
7+
import { sanitizeHtml } from '@/lib/utils/renderHtml';
78

89
interface HackathonBannerProps {
910
title: string;
10-
subtitle?: string;
11+
subtitle?: string | React.ReactNode;
1112
imageUrl?: string;
1213
deadline?: string;
1314
startDate?: string;
@@ -244,11 +245,17 @@ export function HackathonBanner({
244245
<h1 className='text-left text-3xl leading-tight font-bold text-white drop-shadow-lg md:text-4xl lg:text-5xl'>
245246
{title}
246247
</h1>
247-
{subtitle && (
248-
<p className='max-w-2xl text-left text-base text-gray-200 drop-shadow-md md:text-lg'>
249-
{subtitle.slice(3)}
250-
</p>
248+
{subtitle && typeof subtitle === 'string' ? (
249+
<div
250+
className='max-w-2xl text-left text-base text-gray-200 drop-shadow-md md:text-lg'
251+
dangerouslySetInnerHTML={sanitizeHtml(subtitle)}
252+
/>
253+
) : (
254+
<div className='max-w-2xl text-left text-base text-gray-200 drop-shadow-md md:text-lg'>
255+
{subtitle}
256+
</div>
251257
)}
258+
252259
{subtitle && (
253260
<div className='h-1 w-20 rounded-full bg-[#a7f950] md:w-24' />
254261
)}

components/wallet/WalletButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ export const WalletButton = () => {
115115
return (
116116
<Button
117117
onClick={handleConnect}
118-
className='flex items-center gap-2 bg-blue-500 text-white hover:bg-blue-600 dark:bg-blue-600 dark:hover:bg-blue-700'
118+
className='bg-primary hover:bg-primary/60 flex items-center gap-2 text-black dark:bg-blue-600 dark:hover:bg-blue-700'
119119
>
120120
<Wallet className='h-4 w-4' />
121121
Connect Wallet

lib/utils/renderHtml.ts

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import DOMPurify from 'dompurify';
2+
3+
export function sanitizeHtml(html: string | undefined | null) {
4+
const dirty = html ?? '';
5+
6+
try {
7+
const clean = DOMPurify.sanitize(dirty, {
8+
ALLOWED_TAGS: [
9+
'b',
10+
'i',
11+
'em',
12+
'strong',
13+
'a',
14+
'p',
15+
'ul',
16+
'ol',
17+
'li',
18+
'br',
19+
'span',
20+
'div',
21+
'h1',
22+
'h2',
23+
'h3',
24+
'h4',
25+
'h5',
26+
'img',
27+
'code',
28+
'pre',
29+
'blockquote',
30+
'small',
31+
'sup',
32+
'sub',
33+
],
34+
ALLOWED_ATTR: [
35+
'href',
36+
'target',
37+
'rel',
38+
'class',
39+
'id',
40+
'title',
41+
'alt',
42+
'src',
43+
],
44+
});
45+
return { __html: clean };
46+
} catch (err) {
47+
console.error(err);
48+
return { __html: dirty };
49+
}
50+
}

package-lock.json

Lines changed: 10 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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@
9494
"clsx": "^2.1.1",
9595
"cmdk": "^1.1.1",
9696
"date-fns": "^4.1.0",
97+
"dompurify": "^3.3.0",
9798
"embla-carousel-autoplay": "^8.6.0",
9899
"embla-carousel-react": "^8.6.0",
99100
"framer-motion": "^12.23.12",

0 commit comments

Comments
 (0)