diff --git a/src/assets/check_ico.svg b/src/assets/check_ico.svg
new file mode 100644
index 0000000..e29170b
--- /dev/null
+++ b/src/assets/check_ico.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/src/components/generic/CodeShell.js b/src/components/generic/CodeShell.js
index 9172ac0..65b96cc 100644
--- a/src/components/generic/CodeShell.js
+++ b/src/components/generic/CodeShell.js
@@ -3,7 +3,8 @@ import {FlexColumn, Svg} from '../../utils/containers';
import styled from 'styled-components';
import theme from '../../utils/theme';
import copyIco from '../../assets/copy_ico.svg';
-import {Code} from '../../utils/fonts';
+import checkIco from '../../assets/check_ico.svg';
+import {Body, Code} from '../../utils/fonts';
const CodeShellStyle = styled(FlexColumn)`
position: relative;
@@ -14,6 +15,7 @@ const CodeShellStyle = styled(FlexColumn)`
border-radius: 4px;
width: 100%;
align-items: flex-start;
+ max-width: ${({maxWidth}) => maxWidth ? maxWidth : 'none'};
@media (min-width: ${({theme}) => theme.overMobile}) {
gap: 12px;
@@ -21,21 +23,48 @@ const CodeShellStyle = styled(FlexColumn)`
}
`;
+const CopiedMessageStyle = styled(Body)`
+ font-size: 16px;
+ position: absolute;
+ top: -24px;
+ right: -10px;
+ background-color: ${({theme}) => theme.colors.green};
+ color: ${({theme}) => theme.colors.white};
+ border-radius: 4px;
+ padding: 6px;
+`;
+
const CodeShell = (props) => {
+ const [ico, setIco] = React.useState(copyIco);
+
+ const clickCopyButton = () => {
+ let commands = '';
+ if (props.commands.length > 1) {
+ for (let command of props.commands)
+ commands += command + '\n';
+ }
+ navigator.clipboard.writeText(commands).then(r => console.log(r));
+ setIco(checkIco);
+ setTimeout(() => {
+ setIco(copyIco);
+ }, 3000);
+ };
+
const formatCommand = (command) => {
if (command[0] === '\t') {
return <> {formatCommand(command.slice(1))}>;
/* eslint-disable */
} else if (command[0] === '\s') {
return <> {formatCommand(command.slice(1))}>;
- } return command;
+ }
+ return command;
};
const renderCommands = () => {
return (
props.commands.map((command, index) => {
return (
-
{formatCommand(command)}
@@ -45,9 +74,10 @@ const CodeShell = (props) => {
};
return (
-
+
+ backgroundColor={theme.colors.white} src={ico} onClick={clickCopyButton}/>
+ {ico === checkIco ? copied! : ''}
{renderCommands()}
);
diff --git a/src/components/specific_challenge/HowTo.js b/src/components/specific_challenge/HowTo.js
index e81f75a..fc74ab8 100644
--- a/src/components/specific_challenge/HowTo.js
+++ b/src/components/specific_challenge/HowTo.js
@@ -6,12 +6,14 @@ import CodeShell from '../generic/CodeShell';
import cubeIcon from '../../assets/cube_ico.svg';
import theme from '../../utils/theme';
import {IS_MOBILE} from '../../utils/globals';
+import Media from 'react-media';
const HowTo = () => {
return (
-
+ gap={IS_MOBILE() ? '24px' : '48px'} alignmentX={IS_MOBILE() ? 'flex-start' : 'center'}
+ maxWidth={IS_MOBILE() ? '668px' : 'none'}>
+
Get challenge repo
@@ -19,7 +21,7 @@ const HowTo = () => {
You need to create empty repo with name:
-
+
yourID/challengeName
@@ -38,17 +40,18 @@ const HowTo = () => {
Make sure Gonito.net has access to your repo (e.g. by making it public).