Skip to content

Commit e5bf832

Browse files
timothyisMatthew Sweeney
and
Matthew Sweeney
authored
Add tabs component and test on a guide (#1619)
* Add tabs component and test on a guide * Update styling * Add new component to all guides * Add missing import * update text * remove as * fix paragraph line height * remove extra period * update buttons * Update sentence * Update guides * Minor changes and fixes * Remove extraneous text Co-authored-by: Matthew Sweeney <[email protected]>
1 parent a10c145 commit e5bf832

File tree

49 files changed

+561
-525
lines changed

Some content is hidden

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

49 files changed

+561
-525
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import Snippet from '~/components/snippet'
2+
import Caption from '~/components/text/caption'
3+
4+
export const Author = ({ name }) => <span>{name}</span>
5+
export const Type = ({ type }) => <span>{type}</span>
6+
7+
To create a [Preview Deployment](/docs/v2/platform/deployments#preview) for your <Author name={props.name} /> <Type type={props.type} /> with [Now CLI](/download), make sure you have navigated to the root directory of the project from your terminal.
8+
9+
Using [Now CLI](/download), deploy your <Type type={props.type} /> with **a single command**:
10+
11+
<Snippet dark text="now" />
12+
<Caption>Deploying your <Author name={props.name} /> <Type type={props.type} /> with Now CLI.</Caption>
13+
14+
After your project has been deployed, you will be provided with a link to the Preview Deployment, this can be shared immediately.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { IconCard } from '~/components/card'
2+
import { List } from '~/components/list'
3+
import BitbucketIcon from '~/components/icons/bitbucket'
4+
import GitLabIcon from '~/components/icons/gitlab'
5+
import GitHubIcon from '~/components/icons/github'
6+
7+
export const Author = ({ name }) => <span>{name}</span>
8+
export const Type = ({ type }) => <span>{type}</span>
9+
10+
To deploy your <Author name={props.name} /> <Type type={props.type} /> with a [ZEIT Now for Git Integration](/docs/v2/git-integrations), make sure your created project has been pushed to a Git repository.
11+
12+
[Import the project](/new) into ZEIT Now using your Git integration of choice:
13+
14+
<List columnsDesktop={3} columnsTablet={3} columnsMobile={1}>
15+
<IconCard label="GitHub" icon={<GitHubIcon />} href="/new?tab=github" plus />
16+
<IconCard label="GitLab" icon={<GitLabIcon />} href="/new?tab=gitlab" plus />
17+
<IconCard
18+
label="Bitbucket"
19+
icon={<BitbucketIcon />}
20+
href="/new?tab=bitbucket"
21+
plus
22+
/>
23+
</List>
24+
25+
After your project has been imported, all subsequent pushes to branches will generate [Preview Deployments](/docs/v2/platform/deployments#preview), and all changes made to the default branch (commonly "master") will result in a [Production Deployment](/docs/v2/platform/deployments#production).
+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import GitDeploy from './git-deploy.mdx'
2+
import CLIDeploy from './cli-deploy.mdx'
3+
import Tabs from '~/components/tabs'
4+
import Link from '~/components/text/link'
5+
import { DeployButton } from '~/components/buttons'
6+
7+
export default function DeploySection({ meta }) {
8+
return (
9+
<>
10+
<p>
11+
There are two ways to deploy with ZEIT Now. We recommend using a{' '}
12+
<Link href="/docs/v2/git-integrations">
13+
<a>ZEIT Now for Git Integration</a>
14+
</Link>{' '}
15+
for ease-of-use. Alternatively,{' '}
16+
<Link href="/download">
17+
<a>Now CLI</a>
18+
</Link>{' '}
19+
can be used to generate a manual{' '}
20+
<Link href="/docs/v2/platform/deployments#preview">
21+
<a>Preview Deployment</a>
22+
</Link>
23+
.
24+
</p>
25+
{meta.demo && (
26+
<p>
27+
Once deployed, you will get a URL to see your {meta.type} live, such
28+
as the following: <Link href={meta.demo}>{meta.demo}</Link>
29+
</p>
30+
)}
31+
<br />
32+
<Tabs tabs={['With Git', 'Manually']}>
33+
<GitDeploy name={meta.name} type={meta.type} />
34+
<CLIDeploy name={meta.name} type={meta.type} />
35+
</Tabs>
36+
{meta.demo && (
37+
<>
38+
<p>
39+
Set up a {meta.name} {meta.type} with a few clicks using the Deploy
40+
button, and create a Git repository for it in the process for
41+
automatic deployments for your updates.
42+
</p>
43+
<DeployButton url={meta.example} />
44+
</>
45+
)}
46+
<style jsx>{`
47+
p {
48+
line-height: 1.6;
49+
}
50+
`}</style>
51+
</>
52+
)
53+
}

components/icons/bitbucket.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ const Bitbucket = () => (
2323
y2="23.4645"
2424
gradientUnits="userSpaceOnUse"
2525
>
26-
<stop offset="0.18" stop-color="#0052CC" />
27-
<stop offset="1" stop-color="#2684FF" />
26+
<stop offset="0.18" stopColor="#0052CC" />
27+
<stop offset="1" stopColor="#2684FF" />
2828
</linearGradient>
2929
</defs>
3030
</svg>

components/icons/github.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ const GitLab = () => (
77
xmlns="http://www.w3.org/2000/svg"
88
>
99
<path
10-
fill-rule="evenodd"
11-
clip-rule="evenodd"
10+
fillRule="evenodd"
11+
clipRule="evenodd"
1212
d="M16.0001 2.66669C8.63341 2.66669 2.66675 8.78427 2.66675 16.3373C2.66675 22.3865 6.48341 27.4959 11.7834 29.3072C12.4501 29.4269 12.7001 29.0167 12.7001 28.6579C12.7001 28.3332 12.6834 27.2567 12.6834 26.1117C9.33342 26.744 8.46675 25.2744 8.20008 24.5054C8.05008 24.1124 7.40008 22.8992 6.83342 22.5745C6.36675 22.3182 5.70008 21.6859 6.81675 21.6688C7.86675 21.6517 8.61675 22.6599 8.86675 23.07C10.0667 25.1377 11.9834 24.5567 12.7501 24.1979C12.8667 23.3093 13.2167 22.7112 13.6001 22.3694C10.6334 22.0277 7.53341 20.8486 7.53341 15.6196C7.53341 14.1329 8.05008 12.9025 8.90008 11.9456C8.76675 11.6038 8.30008 10.2026 9.03341 8.32289C9.03341 8.32289 10.1501 7.96404 12.7001 9.72413C13.7667 9.41654 14.9001 9.26274 16.0334 9.26274C17.1667 9.26274 18.3001 9.41654 19.3667 9.72413C21.9167 7.94695 23.0334 8.32289 23.0334 8.32289C23.7668 10.2026 23.3001 11.6038 23.1667 11.9456C24.0167 12.9025 24.5334 14.1158 24.5334 15.6196C24.5334 20.8657 21.4167 22.0277 18.4501 22.3694C18.9334 22.7966 19.3501 23.6169 19.3501 24.8985C19.3501 26.7269 19.3334 28.1965 19.3334 28.6579C19.3334 29.0167 19.5834 29.4439 20.2501 29.3072C22.897 28.3911 25.197 26.6469 26.8265 24.3202C28.4559 21.9936 29.3327 19.2016 29.3334 16.3373C29.3334 8.78427 23.3667 2.66669 16.0001 2.66669Z"
1313
fill="#121314"
1414
/>

components/tabs/index.js

+131
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
import { Children, useState } from 'react'
2+
import PropTypes from 'prop-types'
3+
import cn from 'classnames'
4+
5+
const Tabs = ({
6+
children,
7+
tabs,
8+
disabled,
9+
selected,
10+
defaultSelected = 0,
11+
onChange
12+
}) => {
13+
let [activeTab, setActiveTab] = useState(defaultSelected)
14+
// override if it exists
15+
activeTab = selected || activeTab
16+
17+
return (
18+
<div className={cn('tabs', { disabled })}>
19+
<div className="tabs-row">
20+
{tabs.map((tabName, index) => (
21+
<button
22+
key={'tab-' + index}
23+
className="tab"
24+
disabled={index === activeTab}
25+
onClick={() => {
26+
if (disabled) return
27+
if (typeof selected === 'undefined') {
28+
setActiveTab(index)
29+
}
30+
onChange && onChange(index)
31+
}}
32+
>
33+
{tabName}
34+
</button>
35+
))}
36+
</div>
37+
{children
38+
? Children.map(children, (tab, index) =>
39+
index === activeTab ? tab : null
40+
)
41+
: null}
42+
<style jsx>{`
43+
.tab {
44+
height: 34px;
45+
padding: 0 24px;
46+
user-select: none;
47+
color: #999;
48+
font-size: 16px;
49+
overflow: hidden;
50+
transition: border 0.2s ease, background 0.2s ease, color 0.2s ease;
51+
border-radius: 0;
52+
white-space: nowrap;
53+
text-decoration: none;
54+
text-transform: capitalize;
55+
line-height: 0;
56+
appearance: none;
57+
outline: none;
58+
cursor: pointer;
59+
border: 0;
60+
position: relative;
61+
z-index: 1;
62+
border-bottom: 1px solid var(--accents-2);
63+
}
64+
65+
.tab::after {
66+
position: absolute;
67+
bottom: -1px;
68+
left: 0;
69+
width: 100%;
70+
height: 1px;
71+
background: var(--accents-2);
72+
content: '';
73+
transition: background 0.12s ease;
74+
}
75+
76+
.tab[disabled] {
77+
position: relative;
78+
z-index: 1;
79+
color: var(--geist-foreground);
80+
background: var(--geist-background);
81+
border-color: var(--geist-foreground);
82+
cursor: default;
83+
}
84+
85+
.tab[disabled]::after {
86+
height: 2px;
87+
background: var(--geist-foreground);
88+
}
89+
90+
.tabs :global(._fieldset) {
91+
border-top-left-radius: 0;
92+
overflow: hidden;
93+
}
94+
95+
.tabs.disabled {
96+
pointer-events: none;
97+
}
98+
99+
.tabs.disabled .tab {
100+
background: var(--accents-1);
101+
color: #999;
102+
border-bottom: 1px solid var(--accents-1);
103+
}
104+
105+
.tabs-row {
106+
white-space: nowrap;
107+
overflow-y: hidden;
108+
overflow-x: auto;
109+
position: relative;
110+
margin-bottom: 32px;
111+
}
112+
113+
.tabs-row::after {
114+
height: 1px;
115+
width: 100%;
116+
position: absolute;
117+
content: '';
118+
bottom: 0;
119+
left: 0;
120+
background: var(--accents-2);
121+
}
122+
`}</style>
123+
</div>
124+
)
125+
}
126+
127+
Tabs.propTypes = {
128+
children: PropTypes.array.isRequired
129+
}
130+
131+
export default Tabs

0 commit comments

Comments
 (0)