Skip to content

Commit

Permalink
Update 4 files
Browse files Browse the repository at this point in the history
  • Loading branch information
danilowoz committed Apr 7, 2023
1 parent 052c8e3 commit 5d4a324
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 56 deletions.
8 changes: 7 additions & 1 deletion website/landing/components/Hero/Hero.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import { SandpackProvider } from "@codesandbox/sandpack-react";
import { sandpackDark } from "@codesandbox/sandpack-themes";

import { useBreakpoint } from "../common/useBreakpoint";

import { HeroDesktop } from "./HeroDesktop";
import { files } from "./HeroDesktop/heroSandpackFiles";
import { HeroMobile } from "./HeroMobile";

const CUSTOM_CLASSES_MAP = {
"sp-stack": "custom-stack__hero",
};

export const Hero: React.FC = () => {
const isDesktop = useBreakpoint("bp2");

Expand All @@ -16,8 +21,9 @@ export const Hero: React.FC = () => {
entry: "/index.js",
}}
files={files}
options={{ initMode: "immediate" }}
options={{ initMode: "immediate", classes: CUSTOM_CLASSES_MAP }}
template="react"
theme={sandpackDark}
>
<HeroDesktop />{" "}
</SandpackProvider>
Expand Down
43 changes: 16 additions & 27 deletions website/landing/components/Hero/HeroDesktop/HeroDesktop.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,16 @@
import type { CodeEditorRef } from "@codesandbox/sandpack-react";
import {
ClasserProvider,
SandpackCodeEditor,
SandpackPreview,
SandpackThemeProvider,
useSandpack,
} from "@codesandbox/sandpack-react";
import { sandpackDark } from "@codesandbox/sandpack-themes";
import { useTransform, useViewportScroll } from "framer-motion";
import { useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";

import { AnimatedBox, Box, Clipboard, Resources, Text } from "../../common";

import { SandpackTitle } from "./SandpackTitle";

const CUSTOM_CLASSES_MAP = {
"sp-stack": "custom-stack__hero",
};

export const HeroDesktop: React.FC = () => {
const { scrollY } = useViewportScroll();
const { sandpack } = useSandpack();
Expand Down Expand Up @@ -268,26 +261,22 @@ export const HeroDesktop: React.FC = () => {
},
}}
>
<SandpackThemeProvider theme={sandpackDark}>
<ClasserProvider classes={CUSTOM_CLASSES_MAP}>
<SandpackCodeEditor ref={editorRef} />
<Box
css={{
opacity: "$sandpack-preview-opacity",
position: "absolute",
top: 0,
transform: "translateX(100%)",
transition: "opacity 300ms",

".custom-stack__hero": {
border: "none !important",
},
}}
>
<SandpackPreview />
</Box>
</ClasserProvider>
</SandpackThemeProvider>
<SandpackCodeEditor ref={editorRef} />
<Box
css={{
opacity: "$sandpack-preview-opacity",
position: "absolute",
top: 0,
transform: "translateX(100%)",
transition: "opacity 300ms",

".custom-stack__hero": {
border: "none !important",
},
}}
>
<SandpackPreview />
</Box>
</Box>

<Box
Expand Down
25 changes: 10 additions & 15 deletions website/landing/components/Intro/Examples.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import {
ClasserProvider,
SandpackLayout,
SandpackPreview,
SandpackProvider,
SandpackThemeProvider,
} from "@codesandbox/sandpack-react";
import { styled } from "@stitches/react";
import { motion, useTransform, useViewportScroll } from "framer-motion";
Expand Down Expand Up @@ -114,22 +112,19 @@ export const Examples: React.FC = () => {
dependencies: { "@codesandbox/sandpack-react": "latest" },
}}
files={layoutFiles}
options={{ initMode: "user-visible" }}
template="react"
>
<ClasserProvider
classes={{
options={{
initMode: "user-visible",
classes: {
"sp-layout": "custom-layout",
"sp-stack": "custom-stack",
"sp-wrapper": "custom-wrapper",
}}
>
<SandpackThemeProvider>
<SandpackLayout>
<SandpackPreview />
</SandpackLayout>
</SandpackThemeProvider>
</ClasserProvider>
},
}}
template="react"
>
<SandpackLayout>
<SandpackPreview />
</SandpackLayout>
</SandpackProvider>
</motion.div>
</SandpackContainer>
Expand Down
22 changes: 9 additions & 13 deletions website/landing/components/Intro/Sections/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
SandpackThemeProvider,
useActiveCode,
SandpackProvider,
ClasserProvider,
SandpackPreview,
SandpackLayout,
useSandpack,
Expand Down Expand Up @@ -107,21 +106,18 @@ export const LayoutExample: React.FC = () => {
dependencies: { "@codesandbox/sandpack-react": "latest" },
}}
files={layoutFiles}
template="react"
>
<ClasserProvider
classes={{
options={{
classes: {
"sp-layout": "custom-layout",
"sp-stack": "custom-stack",
"sp-wrapper": "custom-wrapper",
}}
>
<SandpackThemeProvider>
<SandpackLayout>
<SandpackPreview />
</SandpackLayout>
</SandpackThemeProvider>
</ClasserProvider>
},
}}
template="react"
>
<SandpackLayout>
<SandpackPreview />
</SandpackLayout>
</SandpackProvider>
</SandpackContainerMobile>

Expand Down

0 comments on commit 5d4a324

Please sign in to comment.