-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[feat] view plants: created PlantCard component #4
Changes from all commits
7d28dbe
c6c2fc1
8385a12
dc4b78f
616160d
7b1573d
77493d6
6ff3e11
1077750
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
'use client'; | ||
|
||
import { useEffect, useState } from 'react'; | ||
import { UUID } from 'crypto'; | ||
import { getPlantById } from '@/api/supabase/queries/plants'; | ||
import PlantCard from '@/components/PlantCard/PlantCard'; | ||
import { Plant } from '@/types/schema'; | ||
|
||
export default function Home() { | ||
const [result, setResult] = useState<Plant>(); | ||
useEffect(() => { | ||
const getData = async () => { | ||
const testUUID: UUID = '010ae695-6cc8-4af4-919a-d15b92fdd68d'; | ||
const plant2 = await getPlantById(testUUID); | ||
setResult(plant2); // Set the result to state | ||
}; | ||
|
||
getData(); // Call the async function when the component mounts | ||
}, []); | ||
if (result === undefined) { | ||
return <div>Loading...</div>; | ||
} else { | ||
return <PlantCard plant={result} />; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import React from 'react'; | ||
import { Plant } from '@/types/schema'; | ||
import styles from './PlantCardStyles.module.css'; | ||
|
||
export default function PlantCard({ plant }: { plant: Plant }) { | ||
return ( | ||
<div className={styles.Card}> | ||
<div className={styles.CardPic}> | ||
<img alt={plant.plant_name}></img> | ||
Check warning on line 9 in components/PlantCard/PlantCard.tsx GitHub Actions / Run ESLint, Prettier, and TypeScript compiler
Check warning on line 9 in components/PlantCard/PlantCard.tsx GitHub Actions / Run ESLint, Prettier, and TypeScript compiler
Check warning on line 9 in components/PlantCard/PlantCard.tsx GitHub Actions / Run ESLint, Prettier, and TypeScript compiler
Check warning on line 9 in components/PlantCard/PlantCard.tsx GitHub Actions / Run ESLint, Prettier, and TypeScript compiler
|
||
</div> | ||
<div className={styles.CardContent}> | ||
<h2>{plant.plant_name}</h2> | ||
<div className={styles.PlantAttributes}> | ||
<div className={styles.Attribute}> | ||
{/* icon */} | ||
<p>{plant.harvest_start + ' - ' + plant.harvest_end}</p> | ||
</div> | ||
<div className={styles.Attribute}> | ||
{/* icon */} | ||
<p>{plant.water_frequency}</p> | ||
</div> | ||
<div className={styles.Attribute}> | ||
{/* icon */} | ||
<p> | ||
{plant.sunlight_min_hours} | ||
{plant.sunlight_max_hours | ||
? ' - ' + plant.sunlight_max_hours | ||
: ''}{' '} | ||
hours/day | ||
</p> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
.Card { | ||
height: 40vh; | ||
width: 20vw; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: start; | ||
border-radius: 12px; | ||
background-color: white; | ||
box-shadow: | ||
0 24px 38px 3px rgba(0, 0, 0, 0.14), | ||
0 9px 46px 8px rgba(0, 0, 0, 0.12), | ||
0 11px 15px -7px rgba(0, 0, 0, 0.2); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
.CardPic { | ||
height: 60%; | ||
width: 100%; | ||
background-color: #f5f6f6; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
border-top-left-radius: 12px; | ||
border-top-right-radius: 12px; | ||
} | ||
.CardContent { | ||
display: flex; | ||
flex-direction: column; | ||
padding-left: 1vw; | ||
height: 40%; | ||
row-gap: 1vh; | ||
} | ||
.CardContent > * { | ||
margin: 0; | ||
} | ||
.CardContent > h2 { | ||
font-size: 1.5vw; | ||
margin-top: 1vh; | ||
} | ||
.PlantAttributes { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 1vh; | ||
} | ||
|
||
.Attribute { | ||
display: flex; | ||
flex-direction: row; | ||
} | ||
.Attribute > * { | ||
margin: 0; | ||
font-size: 1vw; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks so much for starting the initial styling! can we migrate these styles to Styled Components?
see kevin's pr for reference on using Styled Components!
Styled components doc: https://styled-components.com/
Here's a
styles.tsx
file reference from IJP: https://github.com/calblueprint/immigration-justice-project/blob/main/src/components/ListingDetails/styles.ts