diff --git a/src/App.tsx b/src/App.tsx
index 41de36d..1273f11 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -1,14 +1,12 @@
-import { Card } from './components/Card'
import * as rawChallenges from './challenges'
+import { List } from './components/List'
export function App() {
const challenges = Object.values(rawChallenges)
return (
-
- {challenges.map((challenge) => (
-
- ))}
-
+
+
+
)
}
diff --git a/src/challenges/types.ts b/src/challenges/types.ts
new file mode 100644
index 0000000..31683e7
--- /dev/null
+++ b/src/challenges/types.ts
@@ -0,0 +1,5 @@
+export type Challenge = {
+ title: string
+ url: string
+ solution: string
+}
diff --git a/src/components/Card/index.tsx b/src/components/Card/index.tsx
index 6d70c54..9a50033 100644
--- a/src/components/Card/index.tsx
+++ b/src/components/Card/index.tsx
@@ -1,25 +1,16 @@
import { HTMLAttributes } from 'react'
import parse from 'html-react-parser'
+import { Challenge } from '../../challenges/types'
import { IFrame } from '../IFrame'
// import styles from './index.module.css'
-export type CardProps = HTMLAttributes & {
- title: string
- url: string
- solution: string
-}
+export type CardProps = HTMLAttributes & Challenge
-export function Card({ title, url, solution }: CardProps) {
+export function Card({ solution }: CardProps) {
return (
-
-
- {title}
-
-
-
-
+
)
}
diff --git a/src/components/IFrame/index.module.css b/src/components/IFrame/index.module.css
index 82b8f78..7b21906 100644
--- a/src/components/IFrame/index.module.css
+++ b/src/components/IFrame/index.module.css
@@ -1,4 +1,5 @@
.container {
+ display: block;
border: none;
pointer-events: none;
}
diff --git a/src/components/List/index.module.css b/src/components/List/index.module.css
new file mode 100644
index 0000000..ecd31bf
--- /dev/null
+++ b/src/components/List/index.module.css
@@ -0,0 +1,4 @@
+.container {
+ display: flex;
+ flex-wrap: wrap;
+}
diff --git a/src/components/List/index.tsx b/src/components/List/index.tsx
new file mode 100644
index 0000000..aca3550
--- /dev/null
+++ b/src/components/List/index.tsx
@@ -0,0 +1,51 @@
+import { HTMLAttributes, useEffect, useRef, useState } from 'react'
+
+import { Challenge } from '../../challenges/types'
+import { Card } from '../Card'
+import styles from './index.module.css'
+
+export type ListProps = HTMLAttributes & {
+ challenges: Challenge[]
+}
+
+export function List({ challenges }: ListProps) {
+ const debounceRef = useRef()
+ const [availableWidth, setAvailableWidth] = useState(window.innerWidth)
+
+ function handleResize() {
+ clearTimeout(debounceRef.current)
+
+ debounceRef.current = setTimeout(() => {
+ setAvailableWidth(window.innerWidth)
+ }, 100)
+ }
+
+ useEffect(() => {
+ window.addEventListener('resize', handleResize)
+
+ return () => {
+ window.removeEventListener('resize', handleResize)
+ }
+ }, [])
+
+ const columns = Math.floor(availableWidth / 400)
+ const contentWidth = columns * 400
+ const scale = availableWidth / contentWidth
+
+ return (
+
+ {challenges.map((challenge) => (
+ -
+
+
+ ))}
+
+ )
+}