Skip to content

Commit 94f60af

Browse files
authored
feat: use sc v6 beta (#901)
* feat: use sc v6 beta * chore: fix stories to work with v6 * chore: update test snaps
1 parent b904e80 commit 94f60af

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1732
-1136
lines changed

components/DocsLayout.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class DocsLayout extends Component {
5252
onRouteChange={this.onRouteChange}
5353
/>
5454

55-
<Content moveRight={!isSideFolded} data-e2e-id="content">
55+
<Content $moveRight={!isSideFolded} data-e2e-id="content">
5656
<Title>{title}</Title>
5757

5858
{children}

components/Footer/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const FooterContent = styled(Content)`
4242
const Footer = () => (
4343
<>
4444
<Wrapper>
45-
<FooterContent hero>
45+
<FooterContent $hero>
4646
{' '}
4747
{'Hosted on '}
4848
<FooterLink inline href="https://vercel.com">

components/Image.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ const Caption = styled.p`
6060

6161
const ImageWrapper = styled.div`
6262
position: relative;
63-
padding-bottom: ${props => props.aspectRatio};
63+
padding-bottom: ${props => props.$aspectRatio};
6464
`;
6565

6666
class Image extends Component {
@@ -77,7 +77,7 @@ class Image extends Component {
7777
return (
7878
<Figure margin={margin}>
7979
<Main width={width}>
80-
<ImageWrapper aspectRatio={aspectRatio}>{renderImage && renderImage(rest)}</ImageWrapper>
80+
<ImageWrapper $aspectRatio={aspectRatio}>{renderImage && renderImage(rest)}</ImageWrapper>
8181

8282
{caption && <Caption captionSpacing={captionSpacing}>{caption}</Caption>}
8383
</Main>

components/Layout.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ export const Content = styled.div`
2828
2929
${mobile(css`
3030
padding: ${rem(100)} ${rem(20)} ${rem(30)} ${rem(20)};
31-
transform: translateX(${p => (p.moveRight ? rem(sidebarWidth) : 0)});
31+
transform: translateX(${p => (p.$moveRight ? rem(sidebarWidth) : 0)});
3232
`)};
3333
3434
${p =>
35-
p.hero &&
35+
p.$hero &&
3636
css`
3737
font-family: ${headerFont};
3838
width: 75rem;

components/Nav/Logo.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const Logo = styled.div`
1111
background-size: contain;
1212
1313
${p =>
14-
p.compact
14+
p.$compact
1515
? css`
1616
background-image: url(/icon.png);
1717
width: ${rem(100)};

components/Nav/MobileNavbar.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const SecondaryMenu = styled.div`
3030
right: 0;
3131
3232
${p =>
33-
p.isOpen
33+
p.$isOpen
3434
? css`
3535
height: ${rem(navbarHeight)};
3636
`
@@ -65,7 +65,7 @@ const ArrowWrapper = styled.div`
6565
transition: transform 0.2s;
6666
6767
${p =>
68-
p.shouldRotate &&
68+
p.$shouldRotate &&
6969
css`
7070
transform-origin: center center;
7171
transform: rotate(180deg);
@@ -89,27 +89,27 @@ const MobileNavbar = props => {
8989
return (
9090
<Wrapper>
9191
{showSideNav !== false && (
92-
<NavButton active={!isSideFolded} onClick={onSideToggle}>
92+
<NavButton $active={!isSideFolded} onClick={onSideToggle}>
9393
{isSideFolded ? <FoldIcon /> : <CloseIcon />}
9494
</NavButton>
9595
)}
9696

9797
<LogoLink>
98-
<Logo compact />
98+
<Logo $compact />
9999
</LogoLink>
100100
<div>
101101
<NavButton onClick={onSearchButtonClick}>
102102
<StyledIcon as={Search} size={28} />
103103
</NavButton>
104104

105-
<NavButton onClick={onMobileNavToggle} active={!isMobileNavFolded}>
106-
<ArrowWrapper shouldRotate={!isMobileNavFolded}>
105+
<NavButton onClick={onMobileNavToggle} $active={!isMobileNavFolded}>
106+
<ArrowWrapper $shouldRotate={!isMobileNavFolded}>
107107
<StyledIcon as={KeyboardArrowDown} size={36} />
108108
</ArrowWrapper>
109109
</NavButton>
110110
</div>
111111

112-
<SecondaryMenu isOpen={!isMobileNavFolded}>
112+
<SecondaryMenu $isOpen={!isMobileNavFolded}>
113113
<NavLinks />
114114
<SecondaryMenuItem>
115115
<Social />

components/Nav/NavButton.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { resetInput } from '../../utils/form';
66

77
const NavButton = styled.button`
88
${resetInput};
9-
background: ${p => (p.active ? 'rgba(0, 0, 0, 0.07)' : 'none')};
9+
background: ${p => (p.$active ? 'rgba(0, 0, 0, 0.07)' : 'none')};
1010
cursor: pointer;
1111
flex: 0 0 auto;
1212
height: ${rem(navbarHeight)};

components/Nav/Navbar.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const Wrapper = styled.nav`
2525
font-family: ${headerFont};
2626
font-size: ${rem(15)};
2727
font-weight: 500;
28-
background: ${props => (props.transparent ? 'transparent' : blmGrey)};
28+
background: ${props => (props.$transparent ? 'transparent' : blmGrey)};
2929
transition: background 300ms ease-out;
3030
color: white;
3131
padding: 0;
@@ -82,7 +82,7 @@ const AlgoliaModalHeader = styled.div`
8282
color: currentColor;
8383
8484
${mobile(css`
85-
display: ${props => (props.isOpen ? 'block' : 'none')};
85+
display: ${props => (props.$isOpen ? 'block' : 'none')};
8686
8787
button {
8888
cursor: pointer;
@@ -107,7 +107,7 @@ const AlgoliaModalOverlay = styled.div`
107107
right: 0;
108108
z-index: ${baseZ};
109109
left: 0;
110-
display: ${props => (props.isOpen ? 'block' : 'none')};
110+
display: ${props => (props.$isOpen ? 'block' : 'none')};
111111
background: ${paleGrey};
112112
overflow-y: auto;
113113
margin: 0;
@@ -135,12 +135,12 @@ class ModalContainer extends PureComponent {
135135
render() {
136136
return (
137137
<>
138-
<AlgoliaModalHeader isOpen={this.props.isOpen}>
138+
<AlgoliaModalHeader $isOpen={this.props.isOpen}>
139139
<button onClick={this.onCloseButtonClick}>
140140
<StyledModalCloseIcon />
141141
</button>
142142
</AlgoliaModalHeader>
143-
<AlgoliaModalOverlay onClick={this.onModalOverlayClick} isOpen={this.props.isOpen}>
143+
<AlgoliaModalOverlay onClick={this.onModalOverlayClick} $isOpen={this.props.isOpen}>
144144
<AlgoliaModal ref={this.modalElement}>
145145
<div>{this.props.children}</div>
146146
</AlgoliaModal>
@@ -169,7 +169,7 @@ class Navbar extends PureComponent {
169169
const { onSideToggle, onMobileNavToggle, isSideFolded, isMobileNavFolded, showSideNav, transparent } = this.props;
170170

171171
return (
172-
<Wrapper transparent={transparent}>
172+
<Wrapper $transparent={transparent}>
173173
<NormalNavbar>
174174
<StartWrapper>
175175
<LogoLink>

components/Nav/Sidebar.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const Sidebar = styled.nav`
2727
2828
${mobile(css`
2929
${p =>
30-
p.isFolded
30+
p.$isFolded
3131
? css`
3232
transform: translateX(${rem(-sidebarWidth)});
3333
`

components/Nav/SidebarMenus.js

Lines changed: 37 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { useCallback, useState, useEffect } from 'react';
22
import styled from 'styled-components';
3-
import { withRouter } from 'next/router';
3+
import { useRouter, withRouter } from 'next/router';
44

55
import rem from '../../utils/rem';
66
import titleToDash from '../../utils/titleToDash';
@@ -89,47 +89,44 @@ function getSectionPath(parentPathname, title) {
8989

9090
function isFolderOpen(currentHref, { pathname, title, sections }) {
9191
return (
92-
sections.reduce((sum, v) => sum || window.location.href.endsWith(getSectionPath(pathname, v.title)), false) ||
93-
window.location.href.endsWith(pathname || '#' + titleToDash(title))
92+
sections.reduce((sum, v) => sum || currentHref.endsWith(getSectionPath(pathname, v.title)), false) ||
93+
currentHref.endsWith(pathname || '#' + titleToDash(title))
9494
);
9595
}
9696

97-
export const SimpleSidebarMenu = ({ onRouteChange, pages = [] }) => (
98-
<MenuInner>
99-
{pages.map(({ title, pathname, sections, href }) => {
100-
if (!sections) {
97+
export const SimpleSidebarMenu = ({ onRouteChange, pages = [] }) => {
98+
const router = useRouter();
99+
100+
return (
101+
<MenuInner>
102+
{pages.map(({ title, pathname, sections, href }, idx) => {
103+
if (!sections) {
104+
return (
105+
<TopLevelLink key={idx}>
106+
<StyledLink href={pathname || '#' + (href || titleToDash(title))}>{title}</StyledLink>
107+
</TopLevelLink>
108+
);
109+
}
110+
101111
return (
102-
<TopLevelLink key={title}>
103-
<StyledLink href={pathname || '#' + (href || titleToDash(title))}>{title}</StyledLink>
104-
</TopLevelLink>
112+
<Folder key={idx} isOpenDefault={isFolderOpen(router.asPath, { title, pathname, sections })}>
113+
{({ rootProps, toggleSubSections, isOpen }) => (
114+
<Section {...rootProps} onClick={onRouteChange}>
115+
<SectionTitle onClick={toggleSubSections}>
116+
<Link href={pathname || '#' + titleToDash(title)}>{title}</Link>
117+
</SectionTitle>
118+
119+
{isOpen &&
120+
sections.map(({ title }) => (
121+
<SubSection key={title}>
122+
<StyledLink href={getSectionPath(pathname, title)}>{title}</StyledLink>
123+
</SubSection>
124+
))}
125+
</Section>
126+
)}
127+
</Folder>
105128
);
106-
}
107-
108-
return (
109-
<Folder
110-
key={title}
111-
isOpenDefault={
112-
typeof window !== 'undefined' && isFolderOpen(window.location.href, { title, pathname, sections })
113-
}
114-
>
115-
{({ rootProps, toggleSubSections, isOpen }) => (
116-
<Section {...rootProps} onClick={onRouteChange}>
117-
<SectionTitle onClick={toggleSubSections}>
118-
<Link href={pathname || '#' + titleToDash(title)}>{title}</Link>
119-
</SectionTitle>
120-
121-
{isOpen &&
122-
sections.map(({ title }) => (
123-
<SubSection key={title}>
124-
<StyledLink unstyled href={getSectionPath(pathname, title)}>
125-
{title}
126-
</StyledLink>
127-
</SubSection>
128-
))}
129-
</Section>
130-
)}
131-
</Folder>
132-
);
133-
})}
134-
</MenuInner>
135-
);
129+
})}
130+
</MenuInner>
131+
);
132+
};

0 commit comments

Comments
 (0)