Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
29 changes: 12 additions & 17 deletions src/components/shared/code/code-group.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import PropTypes from 'prop-types';
import React, { useState } from 'react';
import { getRandomKey } from 'utils';

import Code from './code';
import styles from './code-group.module.scss';

const CodeGroup = ({ children, labels, lineNumbers, heightTogglers }) => {
const [currentIndex, setCurrentIndex] = useState(0);
const randomKey = getRandomKey();
return (
<div className={styles.wrapper}>
<div className={styles.header}>
Expand All @@ -26,21 +24,18 @@ const CodeGroup = ({ children, labels, lineNumbers, heightTogglers }) => {
</div>
))}
</div>
<style>
{`.${styles.itemsContainer}.${randomKey} > div:nth-child(${
currentIndex + 1
}) { display: block; }`}
</style>
<div className={`${styles.itemsContainer} ${randomKey}`}>
{React.Children.map(children, (child, i) => (
<Code
showLineNumbers={lineNumbers[i]}
key={i}
showHeightToggler={heightTogglers[i]}
>
{child.props.children}
</Code>
))}
<div className={`${styles.itemsContainer}`}>
{React.Children.map(children, (child, i) =>
i === currentIndex ? (
<Code
showLineNumbers={lineNumbers[i]}
key={i}
showHeightToggler={heightTogglers[i]}
>
{child.props.children}
</Code>
) : null,
)}
</div>
</div>
);
Expand Down
6 changes: 0 additions & 6 deletions src/components/shared/code/code-group.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,3 @@
.code-tab_active {
color: #fff;
}

.items-container {
> div {
display: none;
}
}
29 changes: 21 additions & 8 deletions src/components/shared/code/code.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,20 @@ const Code = ({ children, showLineNumbers, showHeightToggler }) => {
};
}

const declaredLang = getLanguageDeclaration(children.props?.className);
let copyBtnContent =
children.props?.children ?? 'Sorry, nothing to copy here';

if (declaredLang === 'bash') {
copyBtnContent = copyBtnContent.replace(/^\$\s/gm, '');
}

return (
<WithCopyButton dataToCopy={children.props?.children}>
<WithCopyButton dataToCopy={copyBtnContent}>
<Highlight
{...defaultProps}
code={children.props?.children}
language={getLanguageDeclaration(children.props?.className)}
language={declaredLang}
>
{({ className, tokens, getLineProps, getTokenProps }) => (
<pre
Expand All @@ -84,12 +92,17 @@ const Code = ({ children, showLineNumbers, showHeightToggler }) => {
<span className={styles.lineNumber}>{i + 1}</span>
)}
<span className={styles.lineContent}>
{line.map((token, key) => (
<span
{...getTokenProps({ token, key })}
style={undefined}
/>
))}
{line.map((token, key) => {
return (
<span
{...getTokenProps({
token,
key,
})}
style={undefined}
/>
);
})}
</span>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ title: 'Installation'
### Debian/Ubuntu

```bash
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 379CE192D401AB61
echo "deb https://dl.bintray.com/loadimpact/deb stable main" | sudo tee -a /etc/apt/sources.list
sudo apt-get update
sudo apt-get install k6
$ sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 379CE192D401AB61
$ echo "deb https://dl.bintray.com/loadimpact/deb stable main" | sudo tee -a /etc/apt/sources.list
$ sudo apt-get update
$ sudo apt-get install k6
```

> #### ⚠️ If you are behind a firewall or proxy
Expand All @@ -20,23 +20,23 @@ sudo apt-get install k6
> alternative approach instead:
>
> ```bash
> wget -q -O - https://bintray.com/user/downloadSubjectPublicKey?username=bintray | sudo apt-key add -
> $ wget -q -O - https://bintray.com/user/downloadSubjectPublicKey?username=bintray | sudo apt-key add -
> ```

### Red Hat/CentOS

```bash
wget https://bintray.com/loadimpact/rpm/rpm -O bintray-loadimpact-rpm.repo
sudo mv bintray-loadimpact-rpm.repo /etc/yum.repos.d/
sudo yum install k6
$ wget https://bintray.com/loadimpact/rpm/rpm -O bintray-loadimpact-rpm.repo
$ sudo mv bintray-loadimpact-rpm.repo /etc/yum.repos.d/
$ sudo yum install k6
```

## Mac (brew)

<CodeGroup labels={['Brew']}>

```bash
brew install k6
$ brew install k6
```

</CodeGroup>
Expand All @@ -55,7 +55,7 @@ Install the binary in your `PATH` to run **k6** from any location.
<CodeGroup labels={['Docker']}>

```bash
docker pull loadimpact/k6
$ docker pull loadimpact/k6
```

</CodeGroup>