Change sort and filter chip style, Add seperator (#1222)

- change sort filter chip style & seperator
This commit is contained in:
brendanlaschke
2023-08-15 22:40:42 +02:00
committed by GitHub
parent 4e654654da
commit 1ca41021cf
2 changed files with 35 additions and 6 deletions

View File

@ -75,6 +75,22 @@ const StyledFilterContainer = styled.div`
display: flex; display: flex;
`; `;
const StyledSeperatorContainer = styled.div`
align-items: flex-start;
align-self: stretch;
display: flex;
padding-bottom: ${({ theme }) => theme.spacing(2)};
padding-left: ${({ theme }) => theme.spacing(1)};
padding-right: ${({ theme }) => theme.spacing(1)};
padding-top: ${({ theme }) => theme.spacing(2)};
`;
const StyledSeperator = styled.div`
align-self: stretch;
background: ${({ theme }) => theme.background.quaternary};
width: 1px;
`;
function SortAndFilterBar<SortField>({ function SortAndFilterBar<SortField>({
context, context,
sorts, sorts,
@ -141,10 +157,16 @@ function SortAndFilterBar<SortField>({
<IconArrowNarrowUp size={theme.icon.size.md} /> <IconArrowNarrowUp size={theme.icon.size.md} />
) )
} }
isSort
onRemove={() => onRemoveSort(sort.key)} onRemove={() => onRemoveSort(sort.key)}
/> />
); );
})} })}
{sorts.length && filtersWithDefinition.length && (
<StyledSeperatorContainer>
<StyledSeperator />
</StyledSeperatorContainer>
)}
{filtersWithDefinition.map((filter) => { {filtersWithDefinition.map((filter) => {
return ( return (
<SortOrFilterChip <SortOrFilterChip

View File

@ -10,18 +10,24 @@ type OwnProps = {
labelValue: string; labelValue: string;
icon: ReactNode; icon: ReactNode;
onRemove: () => void; onRemove: () => void;
isSort?: boolean;
}; };
const StyledChip = styled.div` type StyledChipProps = {
isSort?: boolean;
};
const StyledChip = styled.div<StyledChipProps>`
align-items: center; align-items: center;
background-color: ${({ theme }) => theme.background.secondary}; background-color: ${({ theme }) => theme.accent.quaternary};
border: 1px solid ${({ theme }) => theme.border.color.medium}; border: 1px solid ${({ theme }) => theme.accent.tertiary};
border-radius: 50px; border-radius: 4px;
color: ${({ theme }) => theme.color.blue}; color: ${({ theme }) => theme.color.blue};
display: flex; display: flex;
flex-direction: row; flex-direction: row;
flex-shrink: 0; flex-shrink: 0;
font-size: ${({ theme }) => theme.font.size.sm}; font-size: ${({ theme }) => theme.font.size.sm};
font-weight: ${({ isSort }) => (isSort ? 'bold' : 'normal')};
padding: ${({ theme }) => theme.spacing(1) + ' ' + theme.spacing(2)}; padding: ${({ theme }) => theme.spacing(1) + ' ' + theme.spacing(2)};
`; `;
const StyledIcon = styled.div` const StyledIcon = styled.div`
@ -39,7 +45,7 @@ const StyledDelete = styled.div`
margin-top: 1px; margin-top: 1px;
user-select: none; user-select: none;
&:hover { &:hover {
background-color: ${({ theme }) => theme.background.tertiary}; background-color: ${({ theme }) => theme.accent.secondary};
border-radius: ${({ theme }) => theme.border.radius.sm}; border-radius: ${({ theme }) => theme.border.radius.sm};
} }
`; `;
@ -54,10 +60,11 @@ function SortOrFilterChip({
labelValue, labelValue,
icon, icon,
onRemove, onRemove,
isSort,
}: OwnProps) { }: OwnProps) {
const theme = useTheme(); const theme = useTheme();
return ( return (
<StyledChip> <StyledChip isSort={isSort}>
<StyledIcon>{icon}</StyledIcon> <StyledIcon>{icon}</StyledIcon>
{labelKey && <StyledLabelKey>{labelKey}</StyledLabelKey>} {labelKey && <StyledLabelKey>{labelKey}</StyledLabelKey>}
{labelValue} {labelValue}