Skip to content
Snippets Groups Projects
Unverified Commit a4969bed authored by Jed Fox's avatar Jed Fox
Browse files

Tweak sidebar appearance

parent 39ec761e
No related branches found
No related tags found
No related merge requests found
...@@ -33,6 +33,7 @@ import CheveronDown from '../svg/v1/CheveronDown'; ...@@ -33,6 +33,7 @@ import CheveronDown from '../svg/v1/CheveronDown';
import StoreFrontIcon from '../svg/v1/StoreFront'; import StoreFrontIcon from '../svg/v1/StoreFront';
import TuningIcon from '../svg/v1/Tuning'; import TuningIcon from '../svg/v1/Tuning';
import { useLocation } from 'react-router'; import { useLocation } from 'react-router';
import { RectButton } from 'react-native-gesture-handler';
export const SIDEBAR_WIDTH = 240; export const SIDEBAR_WIDTH = 240;
...@@ -41,59 +42,60 @@ export function Item({ ...@@ -41,59 +42,60 @@ export function Item({
icon, icon,
title, title,
style, style,
indent = 0,
to, to,
exact, exact,
onButtonPress onClick,
button
}) { }) {
const showButton = title === 'Accounts'; const linkStyle = [
{
...styles.mediumText,
paddingTop: 9,
paddingBottom: 9,
paddingLeft: 19 + indent,
paddingRight: 10,
textDecoration: 'none',
color: colors.n9
},
{ ':hover': { backgroundColor: colors.n2 } }
];
const content = (
<View
style={{
flexDirection: 'row',
alignItems: 'center',
height: 20
}}
>
{icon}
<Block style={{ marginLeft: 8 }}>{title}</Block>
<View style={{ flex: 1 }} />
{button}
</View>
);
return ( return (
<View style={style}> <View style={style}>
<AnchorLink {onClick ? (
style={[ <RectButton onClick={onClick}>
{ <View style={linkStyle}>{content}</View>
...styles.mediumText, </RectButton>
paddingTop: 9, ) : (
paddingBottom: 9, <AnchorLink
paddingLeft: 19, style={linkStyle}
paddingRight: 10, to={to}
textDecoration: 'none', exact={exact}
color: colors.n9 activeStyle={{
}, borderLeft: '4px solid ' + colors.p8,
{ ':hover': { backgroundColor: colors.n2 } } paddingLeft: 19 + indent - 4,
]} color: colors.p8
to={to}
exact={exact}
activeStyle={{
borderLeft: '4px solid ' + colors.p8,
paddingLeft: 19 - 4,
color: colors.p8
}}
>
<View
style={{
flexDirection: 'row',
alignItems: 'center',
height: 20
}} }}
> >
{icon} {content}
<Block style={{ marginLeft: 8 }}>{title}</Block> </AnchorLink>
<View style={{ flex: 1 }} /> )}
{showButton && (
<Button
bare
onClick={e => {
e.stopPropagation();
e.preventDefault();
onButtonPress();
}}
>
<Add width={12} height={12} style={{ color: colors.n6 }} />
</Button>
)}
</View>
</AnchorLink>
{children ? <View style={{ marginTop: 5 }}>{children}</View> : null} {children ? <View style={{ marginTop: 5 }}>{children}</View> : null}
</View> </View>
...@@ -442,35 +444,22 @@ function Tools() { ...@@ -442,35 +444,22 @@ function Tools() {
} }
}, [location.pathname]); }, [location.pathname]);
return ( return (
<> <View style={{ borderLeft: isOpen ? '4px solid ' + colors.n9 : '' }}>
<View <Item
style={{ title="Tools"
paddingTop: 4, icon={<Wrench width={15} height={15} style={{ color: 'inherit' }} />}
paddingBottom: 4, exact={true}
paddingRight: 10, onClick={onToggle}
paddingLeft: 19, indent={isOpen ? -4 : 0}
textTransform: 'uppercase', button={
color: colors.n6,
flexDirection: 'row',
alignItems: 'center'
}}
>
<Wrench
width={15}
height={15}
style={{ color: 'inherit', marginRight: 4 }}
/>
Tools
<div style={{ flex: 1 }} />
<Button className="hover-visible" bare onClick={onToggle}>
<ExpandOrCollapseIcon <ExpandOrCollapseIcon
width={13} width={12}
height={13} height={12}
// The margin is to make it the exact same size as the dots button style={{ color: colors.n6 }}
style={{ color: colors.n6, margin: 1 }}
/> />
</Button> }
</View> />
{isOpen && ( {isOpen && (
<> <>
<Item <Item
...@@ -483,6 +472,7 @@ function Tools() { ...@@ -483,6 +472,7 @@ function Tools() {
/> />
} }
to="/schedules" to="/schedules"
indent={12}
/> />
<Item <Item
title="Payees" title="Payees"
...@@ -494,6 +484,7 @@ function Tools() { ...@@ -494,6 +484,7 @@ function Tools() {
/> />
} }
to="/payees" to="/payees"
indent={12}
/> />
<Item <Item
title="Rules" title="Rules"
...@@ -501,10 +492,11 @@ function Tools() { ...@@ -501,10 +492,11 @@ function Tools() {
<TuningIcon width={15} height={15} style={{ color: 'inherit' }} /> <TuningIcon width={15} height={15} style={{ color: 'inherit' }} />
} }
to="/rules" to="/rules"
indent={12}
/> />
</> </>
)} )}
</> </View>
); );
} }
...@@ -617,7 +609,18 @@ export function Sidebar({ ...@@ -617,7 +609,18 @@ export function Sidebar({
to="/accounts" to="/accounts"
icon={<PiggyBank width={15} height={15} style={{ color: 'inherit' }} />} icon={<PiggyBank width={15} height={15} style={{ color: 'inherit' }} />}
exact={true} exact={true}
onButtonPress={onAddAccount} button={
<Button
bare
onClick={e => {
e.stopPropagation();
e.preventDefault();
onAddAccount();
}}
>
<Add width={12} height={12} style={{ color: colors.n6 }} />
</Button>
}
/> />
<Tools /> <Tools />
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment