Skip to content

Commit

Permalink
feat: drop old map
Browse files Browse the repository at this point in the history
  • Loading branch information
benfurber committed Nov 14, 2024
1 parent 779efbc commit b98e20e
Show file tree
Hide file tree
Showing 21 changed files with 506 additions and 1,113 deletions.
12 changes: 2 additions & 10 deletions packages/components/src/CardList/CardList.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,9 @@ const allItems = [
]

export const Default: StoryFn<typeof CardList> = () => {
return <CardList dataCy="stories" list={allItems} filteredList={null} />
}

export const FiltedDisplay: StoryFn<typeof CardList> = () => {
const filteredList = [allItems[0], allItems[2]]

return (
<CardList dataCy="stories" list={allItems} filteredList={filteredList} />
)
return <CardList dataCy="stories" list={allItems} />
}

export const WhenFiltedDisplayIsZero: StoryFn<typeof CardList> = () => {
return <CardList dataCy="stories" list={allItems} filteredList={[]} />
return <CardList dataCy="stories" list={[]} />
}
16 changes: 2 additions & 14 deletions packages/components/src/CardList/CardList.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@ import { describe, expect, it } from 'vitest'

import { render } from '../test/utils'
import { EMPTY_LIST, type IProps } from './CardList'
import {
Default,
FiltedDisplay,
WhenFiltedDisplayIsZero,
} from './CardList.stories'
import { Default, WhenFiltedDisplayIsZero } from './CardList.stories'

describe('CardList', () => {
it('Shows all items when no filtering is done', () => {
Expand All @@ -17,15 +13,7 @@ describe('CardList', () => {
expect(getAllByTestId('CardListItem').length).toBe(4)
})

it('Shows only filted items when provided', () => {
const { getAllByTestId } = render(
<FiltedDisplay {...(FiltedDisplay.args as IProps)} />,
)

expect(getAllByTestId('CardListItem').length).toBe(2)
})

it('Shows the no items label when filted items is empty', () => {
it('Shows the no item label when filted items is empty', () => {
const { getByText } = render(
<WhenFiltedDisplayIsZero {...(WhenFiltedDisplayIsZero.args as IProps)} />,
)
Expand Down
67 changes: 27 additions & 40 deletions packages/components/src/CardList/CardList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,34 @@ import { Flex, Text } from 'theme-ui'

import { CardListItem } from '../CardListItem/CardListItem'
import { Icon } from '../Icon/Icon'
import { Loader } from '../Loader/Loader'

import type { IMapPin } from 'oa-shared'

export interface IProps {
columnsCountBreakPoints?: { [key: number]: number }
dataCy: string
filteredList: IMapPin[] | null
list: IMapPin[]
}

export const EMPTY_LIST = 'Oh nos! Nothing to show!'
const DEFAULT_BREAKPOINTS = { 600: 1, 1100: 2, 1600: 3 }

export const CardList = (props: IProps) => {
const { columnsCountBreakPoints, dataCy, filteredList, list } = props
const { dataCy, list } = props

const listToShow = filteredList === null ? list : filteredList
const displayItems = listToShow
const displayItems = list
.splice(0, 30)
.sort(
(a, b) =>
Date.parse(b.creator?._lastActive || '0') -
Date.parse(a.creator?._lastActive || '0'),
)
.map((item) => <CardListItem item={item} key={item._id} />)

const isListEmpty = displayItems.length === 0
const hasListLoaded = list
const results = `${displayItems.length} result${
displayItems.length == 1 ? '' : 's'
} in view`
const isListEmpty = list.length === 0
const results = `${list.length} result${list.length == 1 ? '' : 's'} in view`
const columnsCountBreakPoints =
props.columnsCountBreakPoints || DEFAULT_BREAKPOINTS

return (
<Flex
Expand All @@ -43,36 +41,25 @@ export const CardList = (props: IProps) => {
padding: 2,
}}
>
{!hasListLoaded && <Loader />}
{hasListLoaded && (
<>
<Flex
sx={{
justifyContent: 'space-between',
paddingX: 2,
paddingTop: 2,
fontSize: 2,
}}
>
<Text data-cy="list-results">{results}</Text>
<Flex sx={{ alignItems: 'center', gap: 1 }}>
<Text> Most recently active</Text>
<Icon glyph="arrow-full-down" />
</Flex>
</Flex>
{isListEmpty && EMPTY_LIST}
{!isListEmpty && (
<ResponsiveMasonry
columnsCountBreakPoints={
columnsCountBreakPoints
? columnsCountBreakPoints
: { 600: 1, 1100: 2, 1600: 3 }
}
>
<Masonry>{displayItems}</Masonry>
</ResponsiveMasonry>
)}
</>
<Flex
sx={{
justifyContent: 'space-between',
paddingX: 2,
paddingTop: 2,
fontSize: 2,
}}
>
<Text data-cy="list-results">{results}</Text>
<Flex sx={{ alignItems: 'center', gap: 1 }}>
<Text> Most recently active</Text>
<Icon glyph="arrow-full-down" />
</Flex>
</Flex>
{isListEmpty && EMPTY_LIST}
{!isListEmpty && (
<ResponsiveMasonry columnsCountBreakPoints={columnsCountBreakPoints}>
<Masonry>{displayItems}</Masonry>
</ResponsiveMasonry>
)}
</Flex>
)
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/Loader/Loader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const Loader = ({ label, sx }: Props) => {
/>
)}
<Text sx={{ width: '100%', textAlign: 'center' }}>
{label || 'loading...'}
{label || 'Loading...'}
</Text>
</Flex>
</>
Expand Down
19 changes: 13 additions & 6 deletions src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,19 @@ export const isProductionEnvironment = (): boolean => {
const firebaseConfigs: { [variant in siteVariants]: IFirebaseConfig } = {
/** Sandboxed dev site, all features available for interaction */
dev_site: {
apiKey: 'AIzaSyChVNSMiYxCkbGd9C95aChr9GxRJtW6NRA',
authDomain: 'precious-plastics-v4-dev.firebaseapp.com',
databaseURL: 'https://precious-plastics-v4-dev.firebaseio.com',
messagingSenderId: '174193431763',
projectId: 'precious-plastics-v4-dev',
storageBucket: 'precious-plastics-v4-dev.appspot.com',
apiKey: 'AIzaSyCjc22Q5wl6MEnel4qrSDQNjO5xczspVbk',

authDomain: 'onearmyworld.firebaseapp.com',

databaseURL: 'https://onearmyworld.firebaseio.com',

projectId: 'onearmyworld',

storageBucket: 'onearmyworld.appspot.com',

messagingSenderId: '95034788341',

appId: '1:95034788341:web:c9c75aa61378d740d478bc',
},
/** Sandboxed dev site, populated with copy of live site data (reset weekly) */
preview: {
Expand Down
142 changes: 0 additions & 142 deletions src/pages/Maps/Content/Controls/Controls.tsx

This file was deleted.

37 changes: 0 additions & 37 deletions src/pages/Maps/Content/Controls/GroupingFilterDesktop.tsx

This file was deleted.

Loading

0 comments on commit b98e20e

Please sign in to comment.