Skip to content

Commit

Permalink
rename useTitleCase to toTitleCase; style Clear Filters button
Browse files Browse the repository at this point in the history
  • Loading branch information
ccatherinetan committed Dec 29, 2024
1 parent 284883c commit 9e06512
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 20 deletions.
12 changes: 6 additions & 6 deletions app/seasonal-planting-guide/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use client';

import React, { useEffect, useState } from 'react';
import { SmallButton } from '@/components/Buttons';
import FilterDropdownMultiple from '@/components/FilterDropdownMultiple';
import FilterDropdownSingle from '@/components/FilterDropdownSingle';
import { PlantCalendarList } from '@/components/PlantCalendarList';
Expand All @@ -15,7 +16,7 @@ import {
seasonOptions,
usStateOptions,
} from '@/utils/dropdownOptions';
import { useTitleCase } from '@/utils/helpers'; // is this necessary?
import { toTitleCase } from '@/utils/helpers';
import { useProfile } from '@/utils/ProfileProvider';
import {
FilterContainer,
Expand Down Expand Up @@ -54,9 +55,7 @@ export default function SeasonalPlantingGuide() {
useEffect(() => {
if (profileReady && profileData) {
setSelectedUsState({
label:
profileData.us_state.charAt(0) +
profileData.us_state.slice(1).toLowerCase(), // can't use useTitleCase here, lint error
label: toTitleCase(profileData.us_state),
value: profileData.us_state,
});
}
Expand Down Expand Up @@ -107,8 +106,9 @@ export default function SeasonalPlantingGuide() {
placeholder="Planting Type"
disabled={!selectedUsState}
/>

<button onClick={clearFilters}>Clear filters</button>
<SmallButton $secondaryColor={COLORS.shrub} onClick={clearFilters}>
Clear Filters
</SmallButton>
</FilterContainer>
</HeaderContainer>
{!selectedUsState ? (
Expand Down
4 changes: 2 additions & 2 deletions app/seasonal-planting-guide/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ export const HeaderContainer = styled.div`
z-index: 2;
`;

//TODO: consolidate styling for Filters in view plants and seasonal planting guide
export const FilterContainer = styled.div`
display: flex;
flex-direction: row;
gap: 8px;
margin-top: 12px;
position: relative;
overflow-x: auto;
padding-top: 1px;
padding-bottom: 1px;
align-items: center;
`;

export const StateOptionsContainer = styled.div`
Expand Down
2 changes: 1 addition & 1 deletion components/PlantCalendarList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const months = [
'Dec',
];

const MonthHeader = () => {
export const MonthHeader = () => {
return (
<Styles.MonthsContainer>
{months.map((month, index) => (
Expand Down
2 changes: 1 addition & 1 deletion components/PlantCalendarRow/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { memo, useMemo } from 'react';
import COLORS from '@/styles/colors';
import { fillCalendarGridArrayRowWithColor } from '@/utils/helpers';
import MonthHeader from '../MonthHeader';
import { MonthHeader } from '../PlantCalendarList';
import SeasonColorKey from '../SeasonColorKey';
import { CalendarCell, CalendarGrid } from './styles';

Expand Down
8 changes: 3 additions & 5 deletions components/PlantCard/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { memo } from 'react';
import { P1 } from '@/styles/text';
import { Plant } from '@/types/schema';
import { mapMonthToSeason, useTitleCase } from '@/utils/helpers';
import { mapMonthToSeason, toTitleCase } from '@/utils/helpers';
import DifficultyLevelBar from '../DifficultyLevelBar';
import Icon from '../Icon';
import {
Expand Down Expand Up @@ -48,15 +48,13 @@ const PlantCard = memo(function PlantCard({
<Attribute>
<Icon type="outdoorsSeason"></Icon>
<AttributeContent>
{useTitleCase(
mapMonthToSeason(plant.outdoors_start) || 'Unknown',
)}
{toTitleCase(mapMonthToSeason(plant.outdoors_start) || 'Unknown')}
</AttributeContent>
</Attribute>
<Attribute>
<Icon type="harvestSeason"></Icon>
<AttributeContent>
{useTitleCase(plant.harvest_season)}
{toTitleCase(plant.harvest_season)}
</AttributeContent>
</Attribute>
<Attribute>
Expand Down
4 changes: 2 additions & 2 deletions components/PlantCardKey/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import COLORS from '@/styles/colors';
import { Flex } from '@/styles/containers';
import { P3 } from '@/styles/text';
import { DifficultyLevelEnum } from '@/types/schema';
import { useTitleCase } from '@/utils/helpers';
import { toTitleCase } from '@/utils/helpers';
import DifficultyLevelBar from '../DifficultyLevelBar';
import Icon from '../Icon';
import {
Expand All @@ -25,7 +25,7 @@ const DifficultyBarAndLabel = ({
<DifficultyLevelBar
difficultyLevel={difficultyLevel as DifficultyLevelEnum}
/>
<P3>{useTitleCase(difficultyLevel)}</P3>
<P3>{toTitleCase(difficultyLevel)}</P3>
</Flex>
);
};
Expand Down
4 changes: 2 additions & 2 deletions components/YourPlantDetails/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import COLORS from '@/styles/colors';
import { Flex } from '@/styles/containers';
import { P1, P3 } from '@/styles/text';
import { PlantingTypeEnum } from '@/types/schema';
import { formatTimestamp, useTitleCase } from '@/utils/helpers';
import { formatTimestamp, toTitleCase } from '@/utils/helpers';
import Icon from '../Icon';
import { Container, Header } from './style';

Expand Down Expand Up @@ -39,7 +39,7 @@ export default function YourPlantDetails({
</Header>
<Flex $direction="column" $gap="8px">
{DetailRow('calendar', `Date Planted: ${formatTimestamp(datePlanted)}`)}
{DetailRow('plantHand', `Planting Type: ${useTitleCase(plantingType)}`)}
{DetailRow('plantHand', `Planting Type: ${toTitleCase(plantingType)}`)}
{recentHarvestDate &&
DetailRow(
'plant',
Expand Down
2 changes: 1 addition & 1 deletion utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ export function checkUsState(
return plant.us_state === selectedState;
}

export function useTitleCase(text: string) {
export function toTitleCase(text: string) {
return text.charAt(0) + text.slice(1).toLowerCase();
}

Expand Down

0 comments on commit 9e06512

Please sign in to comment.