Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
feat: added embedded code
  • Loading branch information
jscodelover committed Nov 17, 2019
commit a30404103ca8bc8d8a83b8231773412f3426471a
10 changes: 5 additions & 5 deletions src/components/editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ function Editor(props) {
<EditorWrapper>
{loading ? <h2>Loading....</h2> : null}
<iframe
title='editor'
frameborder='0'
width='100%'
height='500px'
src='https://repl.it/@amasad/PitifulLastingWhoopingcrane?lite=true'
title="editor"
frameBorder="0"
width="100%"
height="500px"
src={props.src}
onLoad={handleOnLoad}
></iframe>
</EditorWrapper>
Expand Down
8 changes: 5 additions & 3 deletions src/components/find/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import CodePanel from '../../components/codepanel';
import { arrayMethod } from '../../utils/data';
import { Block, Box } from '../../components/Blocks';
import AnimationBox from '../../components/animationBox';
import { colorArray } from '../../utils/common';
import Editor from '../../components/editor';
import { colorArray, embeddLink } from '../../utils/common';
import { FindStyle } from './find.style';

function Find(props) {
Expand Down Expand Up @@ -76,7 +77,7 @@ function Find(props) {
<CodePanel>
<div dangerouslySetInnerHTML={{ __html: arrayMethod[find].data }} />
<div dangerouslySetInnerHTML={{ __html: arrayMethod[find].function }} />
<div className='or'>----OR----</div>
<div className="or">----OR----</div>
<div
dangerouslySetInnerHTML={{
__html: arrayMethod[find].alternative_function
Expand All @@ -96,12 +97,13 @@ function Find(props) {
{owner}
{floor && <span>{floor[index]}</span>}
</Box>
<div className='icon'></div>
<div className="icon"></div>
</div>
);
})}
</Block>
</AnimationBox>
<Editor src={embeddLink.find(item => item.method === find).link} />
</FindStyle>
);
}
Expand Down
6 changes: 4 additions & 2 deletions src/components/nav/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,10 @@ function Nav(props) {
}
function handleClick(data) {
showMenu && handleMenu(false);
handleSelect(data);
props.history.push(`/${data.value}`);
if (data.value !== arrayMethod.value) {
handleSelect(data);
props.history.push(`/${data.value}`);
}
}
const navItems = (
<ul>
Expand Down
14 changes: 8 additions & 6 deletions src/container/Filter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { arrayMethod } from '../../utils/data';
import { FilterStyle } from './filter.style';
import { Block, Box } from '../../components/Blocks';
import AnimationBox from '../../components/animationBox';
import { colorArray } from '../../utils/common';
import Editor from '../../components/editor';
import { colorArray, embeddLink } from '../../utils/common';

function Filter() {
const filterFn = useRef(null);
Expand Down Expand Up @@ -122,23 +123,24 @@ function Filter() {
handleClick={animateFilter}
className={play && 'disable-animate-btn'}
>
<Block fontSize={9} paddingLeft='6px'>
<Block fontSize={9} paddingLeft="6px">
{box(dataA)}
</Block>
<Block fontSize={9} paddingLeft='6px' marginTop='-50px'>
<Block fontSize={9} paddingLeft="6px" marginTop="-50px">
{box(dataA, refBlockA)}
</Block>
<div className='filterFn-container'>
<div ref={filterFn} className='filterFn rotate-zero'>
<div className="filterFn-container">
<div ref={filterFn} className="filterFn rotate-zero">
<span>Filter Function</span>
</div>
</div>
{boxHide && (
<Block fontSize={9} paddingLeft='6px'>
<Block fontSize={9} paddingLeft="6px">
{box(dataB, refBlockB)}
</Block>
)}
</AnimationBox>
<Editor src={embeddLink.find(item => item.method === 'filter').link} />
</FilterStyle>
);
}
Expand Down
18 changes: 10 additions & 8 deletions src/container/Map/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import React, { useRef, useState } from 'react';
import { TweenMax, Power0, TimelineMax } from 'gsap';
import CodePanel from '../../components/codepanel';
import { arrayMethod } from '../../utils/data';
import { createData } from '../../utils/common';
import { Block, Box } from '../../components/Blocks';
import { MapStyle } from './map.style';
import AnimationBox from '../../components/animationBox';
import Editor from '../../components/editor';
import { arrayMethod } from '../../utils/data';
import { createData, embeddLink } from '../../utils/common';
import { MapStyle } from './map.style';

function Map() {
const mapFn = useRef(null);
Expand Down Expand Up @@ -97,22 +98,23 @@ function Map() {
handleClick={animateMap}
className={play && 'disable-animate-btn'}
>
<Block fontSize={11} paddingLeft='3px'>
<Block fontSize={11} paddingLeft="3px">
{box(dataA)}
</Block>
<Block fontSize={11} paddingLeft='3px' marginTop='-50px'>
<Block fontSize={11} paddingLeft="3px" marginTop="-50px">
{box(dataA, refBlockA)}
</Block>
<div className='mapFn-container'>
<div ref={mapFn} className='mapFn' />
<div className="mapFn-container">
<div ref={mapFn} className="mapFn" />
<span>Map Function</span>
</div>
{boxHide && (
<Block fontSize={11} paddingLeft='1px' marginTop='-50px'>
<Block fontSize={11} paddingLeft="1px" marginTop="-50px">
{box(dataB, refBlockB)}
</Block>
)}
</AnimationBox>
<Editor src={embeddLink.find(item => item.method === 'map').link} />
</MapStyle>
);
}
Expand Down
16 changes: 9 additions & 7 deletions src/container/Reduce/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import React, { useRef, useState } from 'react';
import { TweenMax, TimelineMax, Sine } from 'gsap';
import CodePanel from '../../components/codepanel';
import AnimationBox from '../../components/animationBox';
import { arrayMethod } from '../../utils/data';
import { Block, Box } from '../../components/Blocks';
import { createData } from '../../utils/common';
import Editor from '../../components/editor';
import { createData, embeddLink } from '../../utils/common';
import { arrayMethod } from '../../utils/data';
import { ReduceStyle } from './reduce.style';

function Reduce() {
Expand Down Expand Up @@ -134,23 +135,24 @@ function Reduce() {
handleClick={animateReduce}
className={play && 'disable-animate-btn'}
>
<Block fontSize={9} paddingLeft='4px'>
<Block fontSize={9} paddingLeft="4px">
{box(dataA)}
</Block>
<Block fontSize={9} marginTop='-50px' paddingLeft='4px'>
<Block fontSize={9} marginTop="-50px" paddingLeft="4px">
{box(dataA, refBlockA)}
</Block>
<div className='reduceFn-container'>
<div ref={reduceFn} className='reduceFn'>
<div className="reduceFn-container">
<div ref={reduceFn} className="reduceFn">
<span>Reduce Function</span>
</div>
</div>
{boxHide && (
<Block fontSize={9} paddingLeft='4px' className='result-container'>
<Block fontSize={9} paddingLeft="4px" className="result-container">
{box(dataB, refBlockB, 'absolute')}
</Block>
)}
</AnimationBox>
<Editor src={embeddLink.find(item => item.method === 'reduce').link} />
</ReduceStyle>
);
}
Expand Down
10 changes: 6 additions & 4 deletions src/container/Sort/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import theme from 'styled-theming';
import defaultTheme from '../../style/themes';
import CodePanel from '../../components/codepanel';
import AnimationBox from '../../components/animationBox';
import { Block, Box } from '../../components/Blocks';
import Editor from '../../components/editor';
import { arrayMethod } from '../../utils/data';
import { colorArray } from '../../utils/common';
import { colorArray, embeddLink } from '../../utils/common';
import { SortStyle } from './sort.style';
import { Block, Box } from '../../components/Blocks';

function Sort() {
const block1 = useRef(null);
Expand Down Expand Up @@ -100,7 +101,7 @@ function Sort() {
<CodePanel>
<div dangerouslySetInnerHTML={{ __html: arrayMethod.sortA.data }} />
<div dangerouslySetInnerHTML={{ __html: arrayMethod.sortA.function }} />
<div className='or'>----OR----</div>
<div className="or">----OR----</div>
<div
dangerouslySetInnerHTML={{
__html: arrayMethod.sortA.alternative_function
Expand All @@ -123,7 +124,7 @@ function Sort() {
<CodePanel>
<div dangerouslySetInnerHTML={{ __html: arrayMethod.sortD.data }} />
<div dangerouslySetInnerHTML={{ __html: arrayMethod.sortD.function }} />
<div className='or'>----OR----</div>
<div className="or">----OR----</div>
<div
dangerouslySetInnerHTML={{
__html: arrayMethod.sortD.alternative_function
Expand All @@ -141,6 +142,7 @@ function Sort() {
</Block>
)}
</AnimationBox>
<Editor src={embeddLink.find(item => item.method === 'sort').link} />
</SortStyle>
);
}
Expand Down
14 changes: 14 additions & 0 deletions src/utils/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,17 @@ export const createData = (data, ele) => {
return arr;
}, []);
};

export const embeddLink = [
{ method: 'map', link: 'https://repl.it/@manisha1896/myMap?lite=true' },
{ method: 'find', link: 'https://repl.it/@manisha1896/myFind?lite=true' },
{
method: 'findIndex',
link: 'https://repl.it/@manisha1896/myFindIndex?lite=true'
},
{ method: 'filter', link: 'https://repl.it/@manisha1896/myFilter?lite=true' },
{ method: 'reduce', link: 'https://repl.it/@manisha1896/myReduce?lite=true' },
{ method: 'some', link: 'https://repl.it/@manisha1896/mySome?lite=true' },
{ method: 'every', link: 'https://repl.it/@manisha1896/myEvery?lite=true' },
{ method: 'sort', link: 'https://repl.it/@manisha1896/mySort?lite=true' }
];