Fix casing 2

This commit is contained in:
jeffvli
2022-10-26 16:23:57 -07:00
parent 8258bbe5b3
commit 9204cdbe6a
5 changed files with 71 additions and 52 deletions
@@ -1,52 +0,0 @@
import { ReactNode } from 'react';
import { css } from '@emotion/react';
import styled from '@emotion/styled';
import { motion } from 'framer-motion';
import { Link, LinkProps } from 'react-router-dom';
import { fontInter } from '../../../styles';
interface ListItemProps {
children: ReactNode;
icon?: ReactNode;
}
const StyledListItem = styled(motion.div)`
${fontInter(600)}
display: flex;
align-items: center;
justify-content: space-between;
`;
const ItemStyle = css`
display: flex;
gap: 1rem;
align-items: center;
width: 100%;
padding: 0.5rem 1rem;
color: var(--sidebar-btn-color);
transition: color 0.2s ease-in-out;
&:hover {
color: var(--sidebar-btn-color-hover);
}
`;
const Box = styled.div`
${ItemStyle}
`;
const ItemLink = styled(Link)<LinkProps>`
${ItemStyle}
`;
export const ListItem = ({ icon, children, ...rest }: ListItemProps) => {
return <StyledListItem {...rest}>{children}</StyledListItem>;
};
ListItem.Box = Box;
ListItem.Link = ItemLink;
ListItem.defaultProps = {
icon: <></>,
};
@@ -0,0 +1,71 @@
import { ReactNode } from 'react';
import { css } from '@emotion/react';
import styled from '@emotion/styled';
import { Link, LinkProps } from 'react-router-dom';
interface ListItemProps {
children: ReactNode;
disabled?: boolean;
to?: string;
}
const StyledItem = styled.div`
display: flex;
width: 100%;
&:focus-visible {
border: 1px solid var(--primary-color);
}
`;
const ItemStyle = css`
display: flex;
width: 100%;
padding: 0.5rem 1rem;
color: var(--sidebar-btn-color);
border: 1px transparent solid;
transition: color 0.2s ease-in-out;
&:hover {
color: var(--sidebar-btn-color-hover);
}
`;
const Box = styled.div`
${ItemStyle}
`;
const ItemLink = styled(Link)<LinkProps & { disabled?: boolean }>`
opacity: ${(props) => props.disabled && 0.6};
pointer-events: ${(props) => props.disabled && 'none'};
&:focus-visible {
border: 1px solid var(--primary-color);
}
${ItemStyle}
`;
export const SidebarItem = ({ to, children, ...rest }: ListItemProps) => {
if (to) {
return (
<ItemLink to={to} {...rest}>
{children}
</ItemLink>
);
}
return (
<StyledItem tabIndex={0} {...rest}>
{children}
</StyledItem>
);
};
SidebarItem.Box = Box;
SidebarItem.Link = ItemLink;
SidebarItem.defaultProps = {
disabled: false,
to: undefined,
};