Skip to content
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] Create the plantcalendarrow component #46

Merged
merged 19 commits into from
Dec 2, 2024

Conversation

kylezryr
Copy link
Collaborator

@kylezryr kylezryr commented Nov 18, 2024

What's new in this PR 🧑‍🌾

Description

  • Created plant calendar row component that is displayed in /seasonal-planting-guide
    • the Plant CalendarRows are displayed in a table along with plant_name
  • Styled the seasonal planting guide page, including search bar, filters dropdowns, and text
  • refactored filtering logic

Screenshots

Prior to the table:
image

After the table:
Screen Shot 2024-12-02 at 1 27 09 AM
Example of Scrolling / Sticky plant_name
Screen Shot 2024-12-02 at 1 27 43 AM

How to review

  • Go to /seasonal-planting-guide and check that calendar rows are rendering correctly
  • Use the filters and search bar to see if results change

Next steps

  • Styling: make the plant name column more compact (or see if Grid layout rather than a table would solve this)
  • test scrolling and usability on a mobile device

Functionality

  • refactor checkGrowingSeason filter to use mapMonthToSeason

Relevant links

Online sources

Related PRs

CC: @ccatherinetan

@ccatherinetan ccatherinetan linked an issue Nov 18, 2024 that may be closed by this pull request
@kylezryr kylezryr marked this pull request as ready for review November 19, 2024 00:58
Copy link
Collaborator

@ccatherinetan ccatherinetan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking so great kyle! left some comments :)

components/PlantList/index.tsx Outdated Show resolved Hide resolved
components/PlantCalendarRow/index.tsx Outdated Show resolved Hide resolved
utils/helpers.ts Outdated Show resolved Hide resolved
utils/helpers.ts Outdated Show resolved Hide resolved
utils/helpers.ts Outdated Show resolved Hide resolved
options={growingSeasonOptions}
placeholder="Growing Season"
/>
<HeaderContainer>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: in the future, we can consider refactoring by making the header (including the search bar and filters) into a separate component that takes in a list of filters as props??
it's great as it is now, but this refactor might make it slightly more reusable in /view-plants??? just an idea

utils/helpers.ts Outdated Show resolved Hide resolved
utils/helpers.ts Outdated Show resolved Hide resolved
utils/helpers.ts Outdated
// if the end month is EARLY_MONTH, end column should be the first column for that month
// otherwise, start column should be the first column and end column should be the second column for that month
const startColumn = startMonth.startsWith('LATE')
? monthToIndex.get(processedStartMonth)! * 2 + 1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should remove the ! operator here, and instead type monthToIndex as Map<MonthEnum, number>, defining the MonthEnum type in schema.d.ts

This way we can ensure that monthToIndex always returns a valid value.

This might be a tedious change, so we can also put this off.

utils/helpers.ts Outdated Show resolved Hide resolved
@kylezryr kylezryr force-pushed the 34-create-the-plantcalendarrow-component branch from e7bec20 to 1d008a5 Compare November 25, 2024 01:38
Copy link
Collaborator

@ccatherinetan ccatherinetan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking great! i think i might just merge this in soon, but i do think it's worth thinking about using a table or a gridview to style the PlantCalendarRows on the /seasonal-planting-guide page + taking plantName out of PlantCalendarRow

utils/helpers.ts Outdated Show resolved Hide resolved
utils/helpers.ts Outdated Show resolved Hide resolved
app/seasonal-planting-guide/page.tsx Outdated Show resolved Hide resolved
return (
<div>
<MonthHeader />
<CalendarRowsContainer>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: i think we want to make the calendars longer and scrollable in the future - let's check w/ kyrene for the desire minimum length of each calendar row

components/PlantCalendarRow/styles.ts Outdated Show resolved Hide resolved
return (
<PlantCalendarRowContainer>
<PlantText>{plantName}</PlantText>
<CalendarGrid>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screen Shot 2024-11-28 at 12 25 11 PM

i noticed that some of the calendar cells look larger than others (possibly b/c in mobile view, some plant names are longer / overflow to the 2nd line??)
Maybe we should provide a fixed pixel value for the height of the CalendarGrid?


return (
<div>
<MonthHeader />
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if we made this into an actual table, like

<table>
   <tr>
     <th></th> // empty since no label above plants 
     <th><MonthHeader /></th>
   </tr>
{filteredPlantList.map((plant, key) => (
    <tr>
        <td>plant.plant_name</td>
        <td>
          <PlantCalendarRow
            key={key}
            harvestStart={plant.harvest_start}
            harvestEnd={plant.harvest_end}
            transplantStart={plant.transplant_start}
            transplantEnd={plant.transplant_end}
            indoorsStart={plant.indoors_start}
            indoorsEnd={plant.indoors_end}
            outdoorsStart={plant.outdoors_start}
            outdoorsEnd={plant.outdoors_end}
          />
      </td>
    </tr>))}
</table>

this would allow us to ensure that the header and the tables/names are all aligned with one another, whereas currently the header is not aligned in mobile view -- and we want to make the column containing calendar rows scrollable in the future
Screen Shot 2024-11-28 at 12 48 15 PM

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we also might consider add sticky styling for the plant names! let's check with kyrene

components/PlantCalendarRow/index.tsx Outdated Show resolved Hide resolved
@ccatherinetan ccatherinetan force-pushed the 34-create-the-plantcalendarrow-component branch from 870cb6f to 4571599 Compare December 2, 2024 09:17
import styled from 'styled-components';
import COLORS from '@/styles/colors';

export const FilterDropdownInput = styled.select<{ $hasValue: boolean }>`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: we eventually want to import a custom dropdown arrow icon to ensure that the positioning matches the design

}
}

// helper constants for processing months to indexes
const growingSeasonToIndex = new Map<SeasonEnum, number[]>([
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: we might want to eventually refactor these into Records rather than Maps, since we don't need all the features of Map

@ccatherinetan ccatherinetan merged commit 77b7c5a into main Dec 2, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create the PlantCalendarRow component
2 participants