Skip to content

Commit 91a60fd

Browse files
author
joachimzeelmaekers
committed
style: fix navbar styling and make the search always light mode
1 parent af131eb commit 91a60fd

File tree

4 files changed

+39
-26
lines changed

4 files changed

+39
-26
lines changed

components/HomeSearchBar.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Button } from '@datacamp/waffles/button';
33
import { mediaQuery } from '@datacamp/waffles/helpers';
44
import { Search } from '@datacamp/waffles/icon';
55
import { Input } from '@datacamp/waffles/input';
6+
import { lightThemeStyle } from '@datacamp/waffles/theme';
67
import { tokens } from '@datacamp/waffles/tokens';
78
import styled from '@emotion/styled';
89
import { ChangeEvent } from 'react';
@@ -31,7 +32,14 @@ export default function HomeSearchBar({ onChange, value }: Props) {
3132
const p = PLACEHOLDERS[Math.floor(Math.random() * PLACEHOLDERS.length)];
3233

3334
return (
34-
<Wrapper>
35+
<Wrapper
36+
css={{
37+
'&, &[data-theme="light"] *': {
38+
...lightThemeStyle,
39+
},
40+
}}
41+
data-theme={'light'}
42+
>
3543
<Input
3644
iconLeft={<Search aria-label="Search all packages and functions" />}
3745
onChange={onChange}

components/Navbar.tsx

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/** @jsxImportSource @emotion/react */
12
import { DataCampLogo } from '@datacamp/waffles/brand';
23
import { Button } from '@datacamp/waffles/button';
34
import { Heading } from '@datacamp/waffles/heading';
@@ -12,7 +13,6 @@ import {
1213
} from '@datacamp/waffles/theme';
1314
import { tokens } from '@datacamp/waffles/tokens';
1415
import styled from '@emotion/styled';
15-
import Link from 'next/link';
1616
import { useRouter } from 'next/router';
1717
import { useContext, useState } from 'react';
1818
import { FaGithub } from 'react-icons/fa';
@@ -96,25 +96,33 @@ export default function Navbar() {
9696
return (
9797
<Header data-theme={theme}>
9898
<nav>
99-
<Link href="/">
100-
<LogoWrapper>
101-
<Heading style={{ color: themeTokens.text.main }}>
102-
RDocumentation
99+
<LogoWrapper>
100+
<a href="/">
101+
<Heading css={{ color: themeTokens.text.main, margin: 0 }}>
102+
Rdocumentation
103103
</Heading>
104-
<div>
105-
<VerticalDivider />
106-
</div>
107-
<div style={{ display: 'flex', flexDirection: 'column' }}>
108-
<Paragraph
109-
style={{ color: themeTokens.text.secondary }}
110-
variant="secondary"
111-
>
112-
powered by
113-
</Paragraph>
114-
<DataCampLogo />
115-
</div>
116-
</LogoWrapper>
117-
</Link>
104+
</a>
105+
106+
<div>
107+
<VerticalDivider />
108+
</div>
109+
<a
110+
css={{ display: 'flex', flexDirection: 'column' }}
111+
href="https://www.datacamp.com"
112+
>
113+
<Paragraph
114+
size="small"
115+
style={{
116+
color: themeTokens.text.secondary,
117+
marginBottom: 0,
118+
}}
119+
variant="secondary"
120+
>
121+
powered by
122+
</Paragraph>
123+
<DataCampLogo css={{ flexShrink: 0, height: 18, width: 86 }} />
124+
</a>
125+
</LogoWrapper>
118126
</nav>
119127

120128
<RightContainer>

pages/index.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,14 @@ import { tokens } from '@datacamp/waffles/tokens';
66
import styled from '@emotion/styled';
77
import { GetServerSideProps } from 'next';
88
import { useRouter } from 'next/router';
9-
import { useContext, useState } from 'react';
9+
import { useState } from 'react';
1010

1111
import AutoComplete from '../components/Autocomplete';
1212
import { HomePageLinks } from '../components/HomePageLinks';
1313
import HomeSearchBar from '../components/HomeSearchBar';
1414
import Layout from '../components/Layout';
1515
import { API_URL } from '../lib/utils';
1616

17-
import { ThemeContext } from './_app';
18-
1917
const SearchWrapper = styled.div({
2018
margin: `${tokens.spacing.large} 0`,
2119
width: `100%`,
@@ -28,7 +26,6 @@ const SearchWrapper = styled.div({
2826
export default function HomePage({ packageCount }: { packageCount?: number }) {
2927
const [searchInput, setSearchInput] = useState('');
3028
const router = useRouter();
31-
const { theme } = useContext(ThemeContext);
3229

3330
function handleChangeSearchInput(e) {
3431
setSearchInput(e.target.value);
@@ -53,7 +50,7 @@ export default function HomePage({ packageCount }: { packageCount?: number }) {
5350
description="Easily search the documentation for every version of every R package on CRAN and Bioconductor."
5451
title="Home"
5552
>
56-
<SearchWrapper data-theme={theme}>
53+
<SearchWrapper>
5754
<Heading as="h2" size="xlarge" style={{ color: themeTokens.text.main }}>
5855
{`Search from ${numberOfPackages} R packages on CRAN and Bioconductor`}
5956
</Heading>

pages/packages/[package]/versions/[version]/topics/[topic].tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ export default function TopicPage({ topicData }: Props) {
135135
<section>
136136
{sections.map((section) => {
137137
if (section.description.length < 1) {
138-
return;
138+
return null;
139139
}
140140
return (
141141
<div key={section.name}>

0 commit comments

Comments
 (0)