Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update theme to 0.2.x #402

Merged
merged 22 commits into from
Dec 16, 2022
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions gatsby-browser.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
/* eslint-env node */
require('./src/styles/global.css')
import React from 'react'

import ModesProvider from './src/components/organisms/SwitchableMode/Provider'

export const wrapRootElement = ({ element }) => (
<ModesProvider>{element}</ModesProvider>
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it'd be better to just wrap our components in the normal React area in this rather than use the wrapRootElement escape hatch.

3 changes: 1 addition & 2 deletions gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ const plugins = [
{
resolve: '@dvcorg/gatsby-theme-iterative',
options: {
remark: true,
cssBase: path.join('src', 'components', 'organisms', 'Page', 'base.css')
glossaryInstanceName: false
}
},
{
Expand Down
7 changes: 7 additions & 0 deletions gatsby-ssr.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import React from 'react'

import ModesProvider from './src/components/organisms/SwitchableMode/Provider'

export const wrapRootElement = ({ element }) => (
<ModesProvider>{element}</ModesProvider>
)
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"node": "^16 || ^18"
},
"dependencies": {
"@dvcorg/gatsby-theme-iterative": "^0.1.23",
"@dvcorg/gatsby-theme-iterative": "^0.2.6",
"@dvcorg/websites-server": "^0.0.13",
"@emotion/react": "^11.10.4",
"@emotion/styled": "^11.10.4",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import React, { useEffect, useState } from 'react'
import Promise from 'promise-polyfill'
import { loadResource } from '@dvcorg/gatsby-theme-iterative/src/utils/front/resources'

import * as styles from '@dvcorg/gatsby-theme-iterative/src/components/Documentation/Layout/SearchForm/styles.module.css'

declare global {
// eslint-disable-next-line @typescript-eslint/naming-convention
interface Window {
docsearch?: (opts: object) => void
}
}

const apiKey = '3e17d424c7a90fede27b848fb01c0dc2'
const appId = '1O03WAGL0D'
const indexName = 'cml'

const SearchForm: React.FC = props => {
const [searchAvailable, setSearchAvailable] = useState<boolean>(false)
useEffect(() => {
console.log({ window, docSearch: window?.docsearch })
if (window) {
if (!window.docsearch) {
Promise.all([
loadResource(
'https://cdn.jsdelivr.net/npm/[email protected]/dist/cdn/docsearch.min.css'
),
loadResource(
'https://cdn.jsdelivr.net/npm/[email protected]/dist/cdn/docsearch.min.js'
)
]).then(() => {
if (window.docsearch) {
window.docsearch({
appId,
apiKey,
indexName,
inputSelector: '#doc-search',
debug: false // Set to `true` if you want to inspect the dropdown
})
setSearchAvailable(true)
}
})
} else {
window.docsearch({
appId,
apiKey,
indexName,
inputSelector: '#doc-search',
debug: false // Set to `true` if you want to inspect the dropdown
})
setSearchAvailable(true)
}
}
}, [])

return (
<div className={styles.searchArea}>
<div className={styles.container}>
<input
className={styles.input}
type="text"
id="doc-search"
placeholder="Search docs"
disabled={!searchAvailable}
{...props}
/>
</div>
</div>
)
}

export default SearchForm
Comment on lines +1 to +72
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll have to follow up on making this more reusable

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we have had this pending for a while

Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react'

import { Box, Container, Flex, Heading } from '@theme-ui/components'
import SiteLogo from '../../molecules/SiteLogo'
import SmartLink from '../../atoms/SmartLink'
import SiteLogo from '../../../../components/molecules/SiteLogo'
import SmartLink from '../../../../components/atoms/SmartLink'

import { ReactComponent as DiscordIcon } from '@media/icons/discord.svg'
import { ReactComponent as TwitterIcon } from '@media/icons/twitter.svg'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react'
import SmartLink from '../../../atoms/SmartLink'
import SmartLink from '../../../../../components/atoms/SmartLink'
import * as styles from './styles.module.css'

const Alert: React.FC = () => (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be able to drop the Alert component and let the theme control it now.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react'
import { Flex, Box, Container, Button } from '@theme-ui/components'
import InstallPopup from '../../molecules/InstallPopup'
import SmartLink from '../../atoms/SmartLink'
import SiteLogo from '../../molecules/SiteLogo'
import InstallPopup from '../../../../components/molecules/InstallPopup'
import SmartLink from '../../../../components/atoms/SmartLink'
import SiteLogo from '../../../../components/molecules/SiteLogo'
import Alert from './Alert'

import { ReactComponent as DiscordIcon } from '@media/icons/discord.svg'
Expand All @@ -20,11 +20,11 @@ import {
HamburgerMenu,
HamburgerButton,
useHamburgerMenu
} from '../../molecules/HamburgerMenu'
} from '../../../../components/molecules/HamburgerMenu'

import * as styles from './styles.module.css'
import usePopup from '../../../utils/hooks/usePopup'
import onSelectKey from '../../../utils/onSelectKey'
import usePopup from '../../../../utils/hooks/usePopup'
import onSelectKey from '../../../../utils/onSelectKey'

interface IHeaderProps {
isMain?: boolean
Expand Down Expand Up @@ -155,7 +155,9 @@ const Header: React.FC<IHeaderProps> = ({ isMain }) => {
variant="layout.Header"
className={isMain ? '' : styles.headerForDoc}
sx={
isMain ? { backgroundColor: 'transparent' } : { position: 'sticky' }
isMain
? { backgroundColor: 'transparent' }
: { position: 'fixed', width: '100%' }
}
>
{isMain && <Alert />}
Expand Down Expand Up @@ -265,22 +267,22 @@ const Header: React.FC<IHeaderProps> = ({ isMain }) => {
</Flex>
</Box>
</Container>
{!isMain && (
<>
<HamburgerButton
opened={opened}
collapsed={collapsed}
handleClick={handleToggle}
/>
<HamburgerMenu
opened={opened}
collapsed={collapsed}
handleToggle={handleToggle}
handleItemClick={handleItemClick}
/>
</>
)}
</Box>
{!isMain && (
<>
<HamburgerButton
opened={opened}
collapsed={collapsed}
handleClick={handleToggle}
/>
<HamburgerMenu
opened={opened}
collapsed={collapsed}
handleToggle={handleToggle}
handleItemClick={handleItemClick}
/>
</>
)}
</>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,21 @@
z-index: 7;

& > div {
height: var(--layout-header-height);
padding-top: 10px;
padding-bottom: 10px;

@media (--sm-scr) {
height: var(--layout-header-height-mobile);
@media screen(sm) {
@apply h-14;
}

& > nav {
width: 100%;

& > div {
@media (--sm-scr) {
display: none;
display: none;

@media screen(sm) {
display: flex;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
@tailwind base;
@tailwind components;
@tailwind utilities;

:root {
--color-black: #24292e;
--color-gray-light: #b0b8c5;
Expand Down Expand Up @@ -34,7 +38,8 @@ html {
}

body {
font-family: var(--font-sans);
@apply font-sans;

font-weight: 400;
line-height: 1.5;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { useEffect } from 'react'
import { useLocation } from '@reach/router'

import { handleFrontRedirect } from '../../../utils/shared/redirects'
import { scrollIntoLayout, getScrollNode } from '../../../utils/front/scroll'
import safeQuerySelector from '../../../utils/front/safeQuerySelector'
import { handleFrontRedirect } from '../../../../utils/shared/redirects'
import { scrollIntoLayout, getScrollNode } from '../../../../utils/front/scroll'
import safeQuerySelector from '../../../../utils/front/safeQuerySelector'

import * as styles from './styles.module.css'

Expand Down

This file was deleted.

4 changes: 2 additions & 2 deletions src/components/layouts/MainLayout/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useEffect } from 'react'

import { IPageProps } from '../../organisms/Page'
import { ILayoutComponentProps } from '@dvcorg/gatsby-theme-iterative/src/components/MainLayout'
import { handleFirstTab } from '../../../utils/front/accessibility'

import * as styles from './styles.module.css'
Expand All @@ -20,7 +20,7 @@ interface IMainLayoutProps {
}

export type LayoutComponent = React.FC<
IMainLayoutProps & IPageProps & ILayoutModifiable
IMainLayoutProps & ILayoutComponentProps & ILayoutModifiable
>

const MainLayout: LayoutComponent = ({ className, children }) => {
Expand Down
18 changes: 0 additions & 18 deletions src/components/layouts/WrappedLayout/index.tsx

This file was deleted.

Loading