Skip to content

Commit

Permalink
don't hard-code active color; pass as a prop throughout header
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholeuf committed Feb 13, 2024
1 parent 37e6f42 commit 92a393e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/components/Header/HeaderLogo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import { constants } from '@/app/styles/theme';
interface HeaderLogoProps {
width: string;
color: string;
activeColor: string;
}

const HeaderLogo: React.FC<HeaderLogoProps> = ({ width, color }) => {
const HeaderLogo: React.FC<HeaderLogoProps> = ({ width, color, activeColor }) => {

Check warning on line 13 in src/components/Header/HeaderLogo.tsx

View check run for this annotation

Codecov / codecov/patch

src/components/Header/HeaderLogo.tsx#L13

Added line #L13 was not covered by tests
return (
<Box
sx={{
Expand All @@ -32,7 +33,7 @@ const HeaderLogo: React.FC<HeaderLogoProps> = ({ width, color }) => {
textDecoration: 'none',
color,
'&:hover': {
color: 'primary.main',
color: activeColor,
},
}}
component={NextLink}
Expand Down
7 changes: 4 additions & 3 deletions src/components/Header/Navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ const links = [work, about, contact];

interface NavigationProps {
color: string;
activeColor: string;
}

const Navigation: React.FC<NavigationProps> = ({ color }) => {
const Navigation: React.FC<NavigationProps> = ({ color, activeColor }) => {
const pathname = usePathname();

Check warning on line 20 in src/components/Header/Navigation.tsx

View check run for this annotation

Codecov / codecov/patch

src/components/Header/Navigation.tsx#L19-L20

Added lines #L19 - L20 were not covered by tests
return (
<nav>
Expand All @@ -29,7 +30,7 @@ const Navigation: React.FC<NavigationProps> = ({ color }) => {
const isActive = pathname === href;

Check warning on line 30 in src/components/Header/Navigation.tsx

View check run for this annotation

Codecov / codecov/patch

src/components/Header/Navigation.tsx#L30

Added line #L30 was not covered by tests

const borderBottom = isActive
? `${constants.spacing.xs} solid ${constants.colors.guava}`
? `${constants.spacing.xs} solid ${activeColor}`
: '';

Check warning on line 34 in src/components/Header/Navigation.tsx

View check run for this annotation

Codecov / codecov/patch

src/components/Header/Navigation.tsx#L33-L34

Added lines #L33 - L34 were not covered by tests

return (
Expand All @@ -53,7 +54,7 @@ const Navigation: React.FC<NavigationProps> = ({ color }) => {
color,
borderBottom,
'&:hover': {
color: constants.colors.guava
color: activeColor
},
}}
>
Expand Down
4 changes: 3 additions & 1 deletion src/components/Header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { constants } from '@/app/styles/theme';

const Header = () => {
const color = constants.colors.carob;
const activeColor = constants.colors.guava;

Check warning on line 10 in src/components/Header/index.tsx

View check run for this annotation

Codecov / codecov/patch

src/components/Header/index.tsx#L8-L10

Added lines #L8 - L10 were not covered by tests
return (
<AppBar
position='fixed'
Expand All @@ -27,8 +28,9 @@ const Header = () => {
// width === height of header to make logo a box
width={constants.header.height}
color={color}
activeColor={activeColor}
/>
<Navigation color={color} />
<Navigation color={color} activeColor={activeColor} />
</AppBar>
);
};
Expand Down

0 comments on commit 92a393e

Please sign in to comment.