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

[PoC] Embed preview of all pages in Gatsby Admin #25637

Closed
wants to merge 2 commits into from
Closed
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
5 changes: 5 additions & 0 deletions packages/gatsby-admin/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
packages/*/*.js
packages/gatsby-link/index.js
packages/gatsby-legacy-polyfills/dist/**
../gatsby-link/index.js
../gatsby-legacy-polyfills/dist/**
22 changes: 22 additions & 0 deletions packages/gatsby-admin/src/components/pageembed.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/* @jsx jsx */
import { jsx } from "theme-ui"

const PageEmbed: React.FC<{ src: string; height: number }> = props => (
<iframe
src={props.src}
scrolling="no"
sx={{
border: `none`,
boxShadow: `floating`,
borderRadius: 2,
// NOTE(@mxstbr): This is a really hacky way to scale an iframe. Maybe there's a better one?
width: `200%`,
height: `${props.height}px`,
marginBottom: `-${props.height / 2}px`,
transform: `scale(0.5)`,
transformOrigin: `0 0`,
}}
/>
)

export default PageEmbed
1 change: 1 addition & 0 deletions packages/gatsby-admin/src/components/providers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const theme = {
"500": 500,
},
borders: {
none: `none`,
default: `1px solid ${baseTheme.colors.whiteFade[20]}`,
sixtywhite: `1px solid ${baseTheme.colors.whiteFade[40]}`,
white: `1px solid ${baseTheme.colors.white}`,
Expand Down
33 changes: 32 additions & 1 deletion packages/gatsby-admin/src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
ButtonProps,
InputFieldLabel,
} from "gatsby-interface"
import PageEmbed from "../components/pageembed"

const SecondaryButton: React.FC<ButtonProps> = props => (
<Button
Expand Down Expand Up @@ -130,7 +131,12 @@ const PluginCard: React.FC<{
<Flex
flexDirection="column"
gap={6}
sx={{ backgroundColor: `ui.background`, padding: 5, borderRadius: 2 }}
sx={{
backgroundColor: `ui.background`,
padding: 5,
borderRadius: 2,
boxShadow: `floating`,
}}
>
<Heading as="h2" sx={{ fontWeight: `500`, fontSize: 3 }}>
{plugin.name}
Expand All @@ -157,6 +163,11 @@ const Index: React.FC<{}> = () => {
shadowableFiles
}
}
allGatsbyPage {
nodes {
path
}
}
}
`,
})
Expand All @@ -167,6 +178,26 @@ const Index: React.FC<{}> = () => {

return (
<Flex gap={7} flexDirection="column" sx={{ paddingY: 7, paddingX: 6 }}>
{!window ||
(!window.frameElement && (
<Flex gap={7} flexDirection="column">
<SectionHeading>Pages</SectionHeading>
<Grid gap={6} columns={[1, 1, 1, 2, 3]}>
{data.allGatsbyPage.nodes
.filter(page => page.path.indexOf(`/dev-404-page/`) !== 0)
.map(page => (
<Flex
gap={5}
flexDirection="column"
sx={{ width: `100%`, textAlign: `center` }}
>
<PageEmbed height={400} src={page.path} />
<Text sx={{ color: `text.secondary` }}>{page.path}</Text>
</Flex>
))}
</Grid>
</Flex>
))}
<SectionHeading>Plugins</SectionHeading>
<Grid gap={6} columns={[1, 1, 1, 2, 3]}>
{data.allGatsbyPlugin.nodes
Expand Down