Skip to content

Commit d40d3dc

Browse files
christianalfoniSaraVieira
authored andcommitted
refactored share modal to useOvermind (codesandbox#3178)
* refactored share modal * fix typecheck
1 parent 14f70fd commit d40d3dc

File tree

8 files changed

+388
-401
lines changed

8 files changed

+388
-401
lines changed

packages/app/src/app/pages/common/Modals/ShareModal/Title.js

-33
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import React, { useState } from 'react';
2+
import Down from 'react-icons/lib/fa/angle-down';
3+
import Right from 'react-icons/lib/fa/angle-right';
4+
import { Spring, animated } from 'react-spring/renderprops';
5+
6+
import { Title as TitleElement } from './elements';
7+
8+
interface Props {
9+
title: string;
10+
open?: boolean;
11+
}
12+
13+
export const Title: React.FC<Props> = ({ open, title, children }) => {
14+
const [isOpen, setOpen] = useState(open || false);
15+
16+
function toggleShow() {
17+
setOpen(!isOpen);
18+
}
19+
20+
return (
21+
<>
22+
<TitleElement onClick={() => toggleShow()}>
23+
{isOpen ? <Down /> : <Right />}
24+
{title}
25+
</TitleElement>
26+
<Spring
27+
from={{ height: 'auto' }}
28+
to={{
29+
height: isOpen ? 'auto' : 0,
30+
overflow: 'hidden',
31+
}}
32+
>
33+
{props => <animated.div style={props}>{children}</animated.div>}
34+
</Spring>
35+
</>
36+
);
37+
};

packages/app/src/app/pages/common/Modals/ShareModal/getCode.js renamed to packages/app/src/app/pages/common/Modals/ShareModal/getCode.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { getSandboxName } from '@codesandbox/common/lib/utils/get-sandbox-name';
21
import { getModulePath } from '@codesandbox/common/lib/sandbox/modules';
2+
import { getSandboxName } from '@codesandbox/common/lib/utils/get-sandbox-name';
33
import {
4+
embedUrl,
45
optionsToParameterizedUrl,
56
protocolAndHost,
67
sandboxUrl,
7-
embedUrl,
88
} from '@codesandbox/common/lib/utils/url-generator';
99
import { escapeHtml } from 'app/utils/escape';
1010

@@ -50,6 +50,7 @@ const getOptionsUrl = (sandbox, mainModule, state) => {
5050
sandbox.directories,
5151
defaultModule
5252
);
53+
// @ts-ignore
5354
options.module = modulePath;
5455
}
5556

0 commit comments

Comments
 (0)