Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(landing): ui tweaks #176

Merged
merged 3 commits into from
Nov 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions 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 All @@ -11,7 +11,7 @@
"build": "echo 1"
},
"dependencies": {
"@codesandbox/sandpack-react": "^0.6.0",
"@codesandbox/sandpack-react": "^0.7.1",
"@docusaurus/core": "2.0.0-beta.9",
"@docusaurus/utils-validation": "2.0.0-beta.9"
},
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
30 changes: 29 additions & 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 Expand Up @@ -149,6 +149,34 @@
outline: 0;
}

.sp-cm .cm-scroller::-webkit-scrollbar {
width: 10px;
height: 10px;
}

.sp-cm .cm-scroller::-webkit-scrollbar-track {
background-color: var(--sp-colors-bg-default);
}

.sp-cm .cm-scroller::-webkit-scrollbar-corner {
background-color: transparent;
}

/* Handle */
.sp-cm .cm-scroller::-webkit-scrollbar-thumb {
background-color: var(--sp-colors-fg-default);
border-radius: 9999px;
}

.sp-cm .cm-scroller::-webkit-scrollbar {
width: 12px;
height: 12px;
}

.sp-cm .cm-scroller::-webkit-scrollbar-track {
border-left: 1px solid var(--sp-colors-fg-inactive);
}

.sp-transpiled-code {
display: flex;
flex-direction: column;
Expand Down
2 changes: 1 addition & 1 deletion sandpack-react/src/themes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export const sandpackDark: SandpackTheme = {
defaultText: "#5a5a5a",
inactiveText: "#1a1a1a",
activeBackground: "#272727",
defaultBackground: "#131313",
defaultBackground: "#151515",
inputBackground: "#2e2e2e",
accent: "#90e86f",
errorBackground: "#dac1fb",
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/docs/src/scss/_code.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pre {
font: inherit;
background: #131313;
background: #151515;
}

code {
Expand Down
4 changes: 0 additions & 4 deletions website/docs/src/scss/_general.scss
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,3 @@ main {
aside {
border: 0 !important;
}

.sp-wrapper .sp-layout {
border: 1px solid var(--sandpack-border-color) !important;
}
3 changes: 2 additions & 1 deletion website/docs/src/scss/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,10 @@ html[data-theme="dark"] {
--sandpack-text-color: #ffffff;
--sandpack-text-secondary-color: #979993;

--sandpack-background-color: #111111;
--sandpack-background-color: #090909;
--sandpack-surface-color: #1a1a1a;
--sandpack-border-color: #242424;
--ifm-code-background: #1d1d1d;

--ifm-menu-color-background-active: rgba(111, 236, 91, 0.05);
--ifm-hover-overlay: rgba(111, 236, 91, 0.05);
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
Loading