-
-
Notifications
You must be signed in to change notification settings - Fork 389
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add profile types filtering to new map
- Loading branch information
Showing
19 changed files
with
506 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { CardButton } from './CardButton' | ||
|
||
import type { Meta, StoryFn } from '@storybook/react' | ||
|
||
export default { | ||
title: 'Components/CardButton', | ||
component: CardButton, | ||
} as Meta<typeof CardButton> | ||
|
||
export const Basic: StoryFn<typeof CardButton> = () => ( | ||
<div style={{ width: '300px' }}> | ||
<CardButton> | ||
<div style={{ padding: '20px' }}>Basic Implementation</div> | ||
</CardButton> | ||
</div> | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { Card } from 'theme-ui' | ||
|
||
import type { BoxProps, ThemeUIStyleObject } from 'theme-ui' | ||
|
||
export interface IProps extends BoxProps { | ||
children: React.ReactNode | ||
extraSx?: ThemeUIStyleObject | undefined | ||
} | ||
|
||
export const CardButton = (props: IProps) => { | ||
const { children, extraSx } = props | ||
|
||
return ( | ||
<Card | ||
sx={{ | ||
alignItems: 'center', | ||
alignContent: 'center', | ||
marginTop: '2px', | ||
borderRadius: 2, | ||
padding: 0, | ||
transition: 'borderBottom 0.2s, transform 0.2s', | ||
'&:hover': { | ||
animationSpeed: '0.3s', | ||
cursor: 'pointer', | ||
marginTop: '0', | ||
borderBottom: '4px solid', | ||
transform: 'translateY(-2px)', | ||
borderColor: 'black', | ||
}, | ||
'&:active': { | ||
transform: 'translateY(1px)', | ||
borderBottom: '3px solid', | ||
borderColor: 'grey', | ||
transition: 'borderBottom 0.2s, transform 0.2s, borderColor 0.2s', | ||
}, | ||
...extraSx, | ||
}} | ||
{...props} | ||
> | ||
{children} | ||
</Card> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
107 changes: 107 additions & 0 deletions
107
packages/components/src/FilterList/FilterList.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
import { useState } from 'react' | ||
|
||
import { FilterList } from './FilterList' | ||
|
||
import type { Meta, StoryFn } from '@storybook/react' | ||
import type { ProfileTypeName } from 'oa-shared' | ||
|
||
export default { | ||
title: 'Components/FilterList', | ||
component: FilterList, | ||
} as Meta<typeof FilterList> | ||
|
||
const availableFilters = [ | ||
{ | ||
label: 'Workspace', | ||
type: 'workspace' as ProfileTypeName, | ||
}, | ||
{ | ||
label: 'Machine Builder', | ||
type: 'machine-builder' as ProfileTypeName, | ||
}, | ||
{ | ||
label: 'Collection Point', | ||
type: 'collection-point' as ProfileTypeName, | ||
}, | ||
{ | ||
label: 'Want to get started', | ||
type: 'member' as ProfileTypeName, | ||
}, | ||
] | ||
|
||
export const Basic: StoryFn<typeof FilterList> = () => { | ||
const [activeFilters, setActiveFilters] = useState<string[]>([]) | ||
|
||
const onFilterChange = (label: string) => { | ||
const filter = label.toLowerCase() | ||
const isFilterPresent = !!activeFilters.find( | ||
(existing) => existing === filter, | ||
) | ||
if (isFilterPresent) { | ||
return setActiveFilters(activeFilters.filter((f) => f !== filter)) | ||
} | ||
return setActiveFilters((existing) => [...existing, filter]) | ||
} | ||
|
||
return ( | ||
<div style={{ maxWidth: '500px' }}> | ||
<FilterList | ||
activeFilters={activeFilters} | ||
availableFilters={availableFilters} | ||
onFilterChange={onFilterChange} | ||
/> | ||
</div> | ||
) | ||
} | ||
|
||
export const OnlyOne: StoryFn<typeof FilterList> = () => { | ||
const [activeFilters, setActiveFilters] = useState<string[]>([]) | ||
|
||
const onFilterChange = (label: string) => { | ||
const filter = label.toLowerCase() | ||
const isFilterPresent = !!activeFilters.find( | ||
(existing) => existing === filter, | ||
) | ||
if (isFilterPresent) { | ||
return setActiveFilters(activeFilters.filter((f) => f !== filter)) | ||
} | ||
return setActiveFilters((existing) => [...existing, filter]) | ||
} | ||
|
||
return ( | ||
<div style={{ maxWidth: '500px' }}> | ||
<FilterList | ||
activeFilters={activeFilters} | ||
availableFilters={[availableFilters[0]]} | ||
onFilterChange={onFilterChange} | ||
/> | ||
(Shouldn't see anything, only renders for two or more) | ||
</div> | ||
) | ||
} | ||
|
||
export const OnlyTwo: StoryFn<typeof FilterList> = () => { | ||
const [activeFilters, setActiveFilters] = useState<string[]>([]) | ||
|
||
const onFilterChange = (label: string) => { | ||
const filter = label.toLowerCase() | ||
const isFilterPresent = !!activeFilters.find( | ||
(existing) => existing === filter, | ||
) | ||
if (isFilterPresent) { | ||
return setActiveFilters(activeFilters.filter((f) => f !== filter)) | ||
} | ||
return setActiveFilters((existing) => [...existing, filter]) | ||
} | ||
|
||
return ( | ||
<div style={{ maxWidth: '500px' }}> | ||
<FilterList | ||
activeFilters={activeFilters} | ||
availableFilters={[availableFilters[0], availableFilters[1]]} | ||
onFilterChange={onFilterChange} | ||
/> | ||
(No buttons rendered) | ||
</div> | ||
) | ||
} |
Oops, something went wrong.