Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
danilowoz committed Nov 25, 2021
1 parent 70bfc29 commit 90694b5
Show file tree
Hide file tree
Showing 20 changed files with 73 additions and 102 deletions.
2 changes: 1 addition & 1 deletion plugins/docusaurus/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@codesandbox/sandpack-docusaurus",
"private": true,
"version": "0.6.0",
"version": "0.7.1",
"description": "",
"main": "src/index.js",
"publishConfig": {
Expand Down
7 changes: 5 additions & 2 deletions sandpack-react/src/components/TranspiledCode/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ import { ErrorOverlay } from "../../common/ErrorOverlay";
import { LoadingOverlay } from "../../common/LoadingOverlay";
import { useSandpack } from "../../hooks/useSandpack";
import { useTranspiledCode } from "../../hooks/useTranspiledCode";
import type { CodeViewerProps } from "../CodeViewer";
import { SandpackCodeViewer } from "../CodeViewer";

export const SandpackTranspiledCode: React.FC = () => {
export const SandpackTranspiledCode: React.FC<CodeViewerProps> = (props) => {
const { sandpack } = useSandpack();
const transpiledCode = useTranspiledCode();
const c = useClasser("sp");
Expand All @@ -23,7 +24,9 @@ export const SandpackTranspiledCode: React.FC = () => {

return (
<div className={c("transpiled-code")}>
{transpiledCode ? <SandpackCodeViewer code={transpiledCode} /> : null}
{transpiledCode && (
<SandpackCodeViewer code={transpiledCode} {...props} />
)}
<iframe ref={hiddenIframeRef} style={{ display: "none" }} />
<ErrorOverlay />
<LoadingOverlay clientId="hidden" />
Expand Down
2 changes: 1 addition & 1 deletion sandpack-react/src/styles/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
font-family: var(--sp-font-mono);
font-size: var(--sp-font-size);
color: var(--sp-colors-fg-active);
line-height: 1.4;
line-height: var(--sp-line-height);
}

.sp-code-editor {
Expand Down
4 changes: 2 additions & 2 deletions website/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
"typecheck": "tsc"
},
"dependencies": {
"@codesandbox/sandpack-docusaurus": "^0.6.0",
"@codesandbox/sandpack-react": "^0.6.0",
"@codesandbox/sandpack-docusaurus": "^0.7.1",
"@codesandbox/sandpack-react": "^0.7.1",
"@docusaurus/core": "2.0.0-beta.9",
"@docusaurus/plugin-sitemap": "^2.0.0-beta.9",
"@docusaurus/preset-classic": "2.0.0-beta.9",
Expand Down
2 changes: 1 addition & 1 deletion website/landing/components/Features/Features.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export const Features: React.FC = () => {
transition: "opacity .5s cubic-bezier(0.770, 0.000, 0.175, 1.000)",

"@bp1": {
gap: "100px",
gap: "80px",
},

"@bp2": {
Expand Down
9 changes: 7 additions & 2 deletions website/landing/components/Intro/Examples.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,12 @@ export const Examples: React.FC = () => {
<div ref={sandpackRefSectionTop} />
<motion.div
ref={sandpackRefSectionHeight}
style={{ x, position: "sticky", top: "calc(50vh - 25%)" }}
style={{
x,
position: "sticky",
top: "calc(50vh - 25%)",
marginBottom: "calc(50vh - 15%)",
}}
>
<Box
css={{
Expand All @@ -89,7 +94,7 @@ export const Examples: React.FC = () => {
<motion.div
animate={{ opacity: visibility ? 0 : 1 }}
initial={{ opacity: 0 }}
style={{ position: "relative", zIndex: 1 }}
style={{ position: "relative", zIndex: visibility ? -1 : 1 }}
>
<SandpackExample />
</motion.div>
Expand Down
8 changes: 7 additions & 1 deletion website/landing/components/Intro/Sections/Custom.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
SandpackContainerMobile,
FadeAnimation,
THRESHOLD_VIEW,
Caption,
} from "./common";

const ORIGINAL_CODE = `<Sandpack
Expand Down Expand Up @@ -91,7 +92,10 @@ export const CustomExample: React.FC = () => {
<FadeAnimation>
<Row ref={ref}>
<Content>
<CardTitle>Easily customise the project to run</CardTitle>
<CardTitle>
Easily customise <br />
the project to run
</CardTitle>
<CardDescription>
Use the{" "}
<a
Expand All @@ -105,6 +109,7 @@ export const CustomExample: React.FC = () => {
</CardDescription>

<CodeWrapper>
<Caption>Code snippet</Caption>
<SandpackThemeProvider theme="sandpack-dark">
<SandpackCodeEditor ref={codeEditorRef} showTabs={false} />

Expand Down Expand Up @@ -132,6 +137,7 @@ export const CustomExample: React.FC = () => {
</Content>

<SandpackContainerMobile>
<Caption>Sandpack preview</Caption>
<SandpackPreview
options={{ customSetup: parseFromSandpackToJson(code) }}
/>
Expand Down
3 changes: 3 additions & 0 deletions website/landing/components/Intro/Sections/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
SandpackContainerMobile,
FadeAnimation,
THRESHOLD_VIEW,
Caption,
} from "./common";

const ORIGINAL_CODE = `<Sandpack
Expand Down Expand Up @@ -112,6 +113,7 @@ export const EditorExample: React.FC = () => {
</CardDescription>

<CodeWrapper>
<Caption>Code snippet</Caption>
<SandpackThemeProvider theme="sandpack-dark">
<SandpackCodeEditor ref={codeEditorRef} showTabs={false} />

Expand Down Expand Up @@ -140,6 +142,7 @@ export const EditorExample: React.FC = () => {
</Content>

<SandpackContainerMobile>
<Caption>Sandpack preview</Caption>
<SandpackPreview options={{ options: custom }} />
</SandpackContainerMobile>

Expand Down
4 changes: 3 additions & 1 deletion website/landing/components/Intro/Sections/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
SandpackContainerMobile,
FadeAnimation,
THRESHOLD_VIEW,
Caption,
} from "./common";

export const LayoutExample: React.FC = () => {
Expand Down Expand Up @@ -78,10 +79,10 @@ export const LayoutExample: React.FC = () => {
borderRadius: 0,
borderBottomLeftRadius: "16px",
borderBottomRightRadius: "16px",
padding: "0 15px",
},
}}
>
<Caption>Code snippet</Caption>
<SandpackThemeProvider theme="sandpack-dark">
<SandpackCodeEditor />
</SandpackThemeProvider>
Expand All @@ -91,6 +92,7 @@ export const LayoutExample: React.FC = () => {
<SandpackContainerPlaceholder />

<SandpackContainerMobile css={{ ".custom-layout": { height: "50vh" } }}>
<Caption>Sandpack preview</Caption>
<SandpackProvider
customSetup={{
files: layoutFiles,
Expand Down
4 changes: 2 additions & 2 deletions website/landing/components/Intro/Sections/LayoutContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ import "@codesandbox/sandpack-react/dist/index.css";
export default () => (
<SandpackProvider template="vanilla">
<SandpackThemeProvider>
<SandpackCodeEditor />
<SandpackTranspiledCode />
<SandpackCodeEditor showTabs={false} />
<SandpackTranspiledCode showTabs={false} />
</SandpackThemeProvider>
</SandpackProvider>
);
Expand Down
5 changes: 4 additions & 1 deletion website/landing/components/Intro/Sections/Template.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
SandpackContainerMobile,
FadeAnimation,
THRESHOLD_VIEW,
Caption,
} from "./common";

const frameworkOptions: SandpackPredefinedTemplate[] = [
Expand Down Expand Up @@ -83,6 +84,7 @@ export const TemplateExample: React.FC = () => {
</a>{" "}
prop to get started with Sandpack in a few lines of code.
</CardDescription>

<SnippetButton
ref={boxRef}
onClick={shuffleTemplate}
Expand Down Expand Up @@ -111,14 +113,15 @@ export const TemplateExample: React.FC = () => {
y: mousePosition.y,
}}
>
click to change
Click to change
</ToolTip>
</AnimatePresence>
)}
</div>
</Content>

<SandpackContainerMobile>
<Caption>Sandpack preview</Caption>
<SandpackPreview options={{ template }} />
</SandpackContainerMobile>

Expand Down
17 changes: 12 additions & 5 deletions website/landing/components/Intro/Sections/Theme.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
SandpackContainerMobile,
FadeAnimation,
THRESHOLD_VIEW,
Caption,
} from "./common";

const themeOptions: SandpackPredefinedTheme[] = [
Expand Down Expand Up @@ -73,18 +74,23 @@ export const ThemeExample: React.FC = () => {
<FadeAnimation>
<Row ref={ref}>
<Content>
<CardTitle>Set a theme, or create your own</CardTitle>
<CardTitle>
Set a theme, or
<br /> create your own
</CardTitle>
<CardDescription>
You can style Sandpack however you&apos;d like by applying a{" "}
You can style Sandpack however you&apos;d like! Use one of our
predefined{" "}
<a
href="https://sandpack.codesandbox.io/docs/getting-started/custom-ui#theming"
rel="noreferrer"
target="_blank"
>
<code>theme</code>
</a>
!
</a>{" "}
or apply your own.
</CardDescription>

<SnippetButton
ref={boxRef}
onClick={shuffleTheme}
Expand Down Expand Up @@ -113,14 +119,15 @@ export const ThemeExample: React.FC = () => {
y: mousePosition.y,
}}
>
click to change
Click to change
</ToolTip>
</AnimatePresence>
)}
</div>
</Content>

<SandpackContainerMobile>
<Caption>Sandpack preview</Caption>
<SandpackPreview options={{ theme }} />
</SandpackContainerMobile>

Expand Down
11 changes: 8 additions & 3 deletions website/landing/components/Intro/Sections/common.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,10 @@ export const Content = styled("div", {
alignItems: "center",
display: "flex",
flexDirection: "column",
gap: "20px",
gap: "10px",
width: "100%",

"@bp1": {
gap: "20px",
width: "384px",
},

Expand Down Expand Up @@ -201,11 +200,17 @@ export const FadeAnimation: React.FC = ({ children }) => {
export const CodeWrapper = styled("div", {
position: "relative",
width: "100%",
marginTop: "30px",

pre: { padding: 0 },

".sp-code-editor": {
borderRadius: "16px",
padding: "0 15px",
},
});

export const Caption = styled("p", {
"@bp1": {
display: "none",
},
});
2 changes: 1 addition & 1 deletion website/landing/components/Users/Users.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export const Users: React.FC = () => {
const { url, height, width } = user.logo;

return (
<ListItem key={user.name}>
<ListItem key={user.name} css={{ flex: "none" }}>
<UserLink
css={{
transitionDelay: inView
Expand Down
23 changes: 12 additions & 11 deletions website/landing/components/common/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,7 @@ export const Card = styled("div", {
size: {
small: {
gap: "10px",
width: "256px",

"@bp2": {
width: "240px",
},

"@bp3": {
width: "320px",
},
width: "100%",
},
},
},
Expand Down Expand Up @@ -83,10 +75,11 @@ export const CardDescription = styled("p", {

".external-link": {
color: "$$codeBlockForeground",
textDecoration: "underline",
textDecoration: "none",

"&:hover": {
textDecoration: "none",
textDecoration: "underline",
color: "$primary",
},
},

Expand All @@ -112,6 +105,14 @@ export const CardDescription = styled("p", {
background: "$$codeBlockBackground",
color: "$$codeBlockForeground",
transition: "all .2s ease",

"&:after": {
content: "↗",
display: "inline-block",
marginLeft: "8px",
position: "relative",
top: 1,
},
},
},

Expand Down
3 changes: 2 additions & 1 deletion website/landing/components/common/CodeBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ export const CodeBlock: React.FC<CodeBlockProps> = ({
<Box
css={{
width: "100%",
marginTop: "30px",
pre: { padding: 0 },

".cm-editor": {
borderRadius: oneLiner ? "78px" : "16px",
padding: "15px",
padding: "10px 5px",
},
}}
>
Expand Down
2 changes: 1 addition & 1 deletion website/landing/components/common/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ export const List = styled("ul", {
padding: 0,
});

export const ListItem = styled("li", {});
export const ListItem = styled("li", { flex: 1 });
2 changes: 1 addition & 1 deletion website/landing/components/common/Section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const SectionWrapper = styled("div", {
$$backgroundColor: palette.darkBackground,
$$primaryTextColor: palette.darkTextPrimary,
$$secondaryTextColor: palette.darkTextSecondary,
$$codeBlockBackground: palette.lightTextSecondary,
$$codeBlockBackground: "#1d1d1d",
$$codeBlockForeground: palette.lightBackground,

background: "$$backgroundColor",
Expand Down
Loading

0 comments on commit 90694b5

Please sign in to comment.