-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add svg theme wrapper, update project filters stories
- Loading branch information
Showing
6 changed files
with
314 additions
and
189 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,39 @@ | ||
import { Box, SxProps, SvgIcon } from '@mui/material'; | ||
|
||
export default function SvgThemeWrapper({ | ||
src, | ||
sx, | ||
color, | ||
}: { | ||
src: string; | ||
sx: SxProps; | ||
color: string; | ||
}) { | ||
// TODO: support svg react components | ||
return ( | ||
// <Box | ||
// sx={{ | ||
// maskImage: `url(${src})`, | ||
// maskSize: 'contain', | ||
// maskRepeat: 'no-repeat', | ||
// maskPosition: 'center', | ||
// boxSizing: 'border-box', | ||
// width: '30px', | ||
// height: '30px', | ||
// background: color, | ||
// ...sx, | ||
// }} | ||
// /> | ||
<SvgIcon sx={sx}> | ||
<mask id="mask_123"> | ||
<image | ||
href={src} | ||
style={{ filter: 'brightness(10)' }} | ||
height="100%" | ||
width="100%" | ||
/> | ||
</mask> | ||
<rect mask="url(#mask_123)" width="100%" height="100%" fill={color} /> | ||
</SvgIcon> | ||
); | ||
} |
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
204 changes: 198 additions & 6 deletions
204
web-components/src/components/organisms/ProjectFilters/ProjectFilters.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 |
---|---|---|
@@ -1,16 +1,208 @@ | ||
import { Box } from '@mui/material'; | ||
import { Meta, StoryFn } from '@storybook/react'; | ||
|
||
import ProjectFilters from './ProjectFilters'; | ||
import SvgThemeWrapper from '../../icons/SvgThemeWrapper'; | ||
import RegionIndicatorIcon, { | ||
Region, | ||
} from '../../icons/terassos/ColombiaRegionIndicatorIcon'; | ||
import ProjectFilters, { Filter, FilterOptions } from './ProjectFilters'; | ||
|
||
export default { | ||
title: 'Organisms/ProjectFilters', | ||
component: ProjectFilters, | ||
} as Meta; | ||
|
||
const Template: StoryFn = args => <ProjectFilters {...args} />; | ||
const activeFilters = ['AMAZON', 'TROPICAL_VERY_HUMID_FOREST']; | ||
|
||
export const Default = Template.bind({}); | ||
Default.args = {}; | ||
export function ComplianceBadge() { | ||
return ( | ||
<Box | ||
display="flex" | ||
alignItems="center" | ||
justifyContent="center" | ||
width="24px" | ||
height="24px" | ||
padding="3px" | ||
borderRadius="50%" | ||
fontSize="12px" | ||
fontWeight={700} | ||
sx={{ | ||
borderRadius: '40px', | ||
border: '1px dashed var(--surface-stroke, #D2D5D9)', | ||
background: 'var(--surface-selected-item-background, #EFEFEF)', | ||
ml: 2, | ||
}} | ||
> | ||
ha. | ||
</Box> | ||
); | ||
} | ||
|
||
const Template: StoryFn = args => ( | ||
<ProjectFilters | ||
{...args} | ||
filters={args.filters} | ||
activeFilterIds={activeFilters} | ||
/> | ||
); | ||
// add another component | ||
|
||
const ecosystemIconSx = { | ||
width: '30px', | ||
height: '30px', | ||
mr: 2, | ||
}; | ||
|
||
const ecosystemTags: FilterOptions[] = [ | ||
{ | ||
name: 'Tropical very humid forest', | ||
id: 'TROPICAL_VERY_HUMID_FOREST', | ||
icon: ( | ||
<SvgThemeWrapper | ||
src="/tag/forest.svg" | ||
sx={ecosystemIconSx} | ||
color="#A5A4A4" | ||
/> | ||
), | ||
}, | ||
{ | ||
name: 'Tropical humid forest', | ||
id: 'TROPICAL_HUMID_FOREST', | ||
icon: ( | ||
<SvgThemeWrapper | ||
src="/tag/forest.svg" | ||
sx={ecosystemIconSx} | ||
color="#A5A4A4" | ||
/> | ||
), | ||
}, | ||
{ | ||
name: 'Tropical dry forest', | ||
id: 'TROPICAL_DRY_FOREST', | ||
icon: ( | ||
<SvgThemeWrapper | ||
src="/tag/forest.svg" | ||
sx={ecosystemIconSx} | ||
color="#A5A4A4" | ||
/> | ||
), | ||
}, | ||
{ | ||
name: 'Premontane humid forest', | ||
id: 'PREMONTANE_HUMID_FOREST', | ||
icon: ( | ||
<SvgThemeWrapper | ||
src="/tag/forest.svg" | ||
sx={ecosystemIconSx} | ||
color="#A5A4A4" | ||
/> | ||
), | ||
}, | ||
{ | ||
name: 'Low montane very humid forest', | ||
id: 'LOW_MONTANE_VERY_HUMID_FOREST', | ||
icon: ( | ||
<SvgThemeWrapper | ||
src="/tag/forest.svg" | ||
sx={ecosystemIconSx} | ||
color="#A5A4A4" | ||
/> | ||
), | ||
}, | ||
]; | ||
|
||
export const WithCustomProps = Template.bind({}); | ||
WithCustomProps.args = {}; | ||
const regionTags: FilterOptions[] = [ | ||
{ | ||
name: 'Amazon', | ||
id: 'AMAZON', | ||
icon: ( | ||
<RegionIndicatorIcon | ||
isSelected={activeFilters.includes('AMAZON')} | ||
region={'AMAZON'} | ||
/> | ||
), | ||
}, | ||
{ | ||
name: 'Pacific', | ||
id: 'PACIFIC', | ||
icon: ( | ||
<RegionIndicatorIcon | ||
isSelected={activeFilters.includes('PACIFIC')} | ||
region="PACIFIC" | ||
/> | ||
), | ||
}, | ||
{ | ||
name: 'Orinoco', | ||
id: 'ORINOCO', | ||
icon: ( | ||
<RegionIndicatorIcon | ||
isSelected={activeFilters.includes('ORINOCO')} | ||
region="ORINOCO" | ||
/> | ||
), | ||
}, | ||
{ | ||
name: 'Caribbean', | ||
id: 'CARIBBEAN', | ||
icon: ( | ||
<RegionIndicatorIcon | ||
isSelected={activeFilters.includes('CARIBBEAN')} | ||
region="CARIBBEAN" | ||
/> | ||
), | ||
}, | ||
{ | ||
name: 'Andean', | ||
id: 'ANDEAN', | ||
icon: ( | ||
<RegionIndicatorIcon | ||
isSelected={activeFilters.includes('ANDEAN')} | ||
region="ANDEAN" | ||
/> | ||
), | ||
}, | ||
]; | ||
|
||
const marketCheckboxes = [ | ||
{ | ||
name: 'Voluntary', | ||
id: 'VOLUNTARY', | ||
icon: ( | ||
<Box | ||
component="img" | ||
sx={{ width: '24px', ml: 2 }} | ||
src="/logos/tebu-badge.png" | ||
alt="Tebu" | ||
/> | ||
), | ||
}, | ||
{ | ||
name: 'Compliance', | ||
id: 'COMPLIANCE', | ||
icon: <ComplianceBadge />, | ||
}, | ||
]; | ||
|
||
const filters: Filter[] = [ | ||
{ | ||
displayType: 'tag', | ||
title: 'Region', | ||
options: regionTags, | ||
}, | ||
{ | ||
displayType: 'tag', | ||
title: 'Ecosystem', | ||
options: ecosystemTags, | ||
}, | ||
{ | ||
displayType: 'checkbox', | ||
title: 'Market', | ||
options: marketCheckboxes, | ||
}, | ||
]; | ||
|
||
export const Default = Template.bind({}); | ||
Default.args = { | ||
filters: filters, | ||
}; |
Oops, something went wrong.