Skip to content

Commit

Permalink
feat: implement responsive landing page
Browse files Browse the repository at this point in the history
  • Loading branch information
shadowusr committed Jun 9, 2024
1 parent bb92a86 commit 78e88c1
Show file tree
Hide file tree
Showing 51 changed files with 2,781 additions and 46 deletions.
75 changes: 53 additions & 22 deletions docusaurus.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { themes as prismThemes } from "prism-react-renderer";
import type { Config } from "@docusaurus/types";
import type * as Preset from "@docusaurus/preset-classic";
import { tailwindPlugin } from "./plugins/tailwind";
import { svgFixPlugin } from "./plugins/svg-fix";

const config: Config = {
title: "Testplane Docs",
Expand Down Expand Up @@ -54,23 +55,32 @@ const config: Config = {
],

themeConfig: {
colorMode: {
disableSwitch: true,
},
image: "img/docusaurus-social-card.jpg",
navbar: {
title: "testplane",
logo: {
alt: "Testplane Logo",
src: "img/logo.svg",
},
items: [
{
type: "docSidebar",
sidebarId: "mainSidebar",
position: "left",
label: "Tutorial",
label: "Docs",
},
{ to: "/blog", label: "Blog", position: "left" },
{
type: "docsVersionDropdown",
position: "right",
dropdownItemsAfter: [{ to: "/versions", label: "All versions" }],
dropdownActiveClassDisabled: true,
},
{
type: "localeDropdown",
position: "right",
},
{ to: "#", label: "Blog", position: "left" },
{
href: "https://github.com/facebook/docusaurus",
href: "https://github.com/gemini-testing/testplane",
label: "GitHub",
position: "right",
},
Expand All @@ -80,50 +90,71 @@ const config: Config = {
style: "dark",
links: [
{
title: "Docs",
title: "Quickstart",
items: [
{
label: "Configuration",
label: "Installation",
to: "#",
},
{
label: "Events",
label: "Writing your first tests",
to: "#",
},
{
label: "API reference",
label: "Why testplane?",
to: "#",
},
],
},
{
title: "Community",
title: "Core concepts",
items: [
{
label: "GitHub",
href: "https://github.com/gemini-testing/testplane",
label: "Browser commands",
href: "#",
},
{
label: "Stack Overflow",
href: "https://stackoverflow.com/questions/tagged/testplane",
label: "Testplane config",
href: "#",
},
{
label: "Testplane UI",
href: "#",
},
],
},
{
title: "More",
title: "Customization",
items: [
{
label: "Releases",
to: "https://github.com/gemini-testing/testplane/releases",
label: "Custom commands",
href: "#",
},
{
label: "Installation",
label: "Plugins and reporters",
href: "#",
},
{
label: "Usage in CI",
href: "#",
},
],
},
{
title: "Resources",
items: [
{
label: "Docs",
href: "#",
},
{
label: "First tests with testplane",
label: "Blog",
href: "#",
},
{
label: "Changelog",
to: "#",
},
],
},
],
Expand All @@ -135,7 +166,7 @@ const config: Config = {
},
} satisfies Preset.ThemeConfig,

plugins: ["docusaurus-plugin-sass", tailwindPlugin],
plugins: ["docusaurus-plugin-sass", tailwindPlugin, svgFixPlugin],
};

export default config;
5 changes: 5 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,10 @@ export default tseslint.config(
"no-unused-vars",
]),
},
{
rules: {
"react/prop-types": 0,
},
},
prettier,
);
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"not op_mini all"
],
"development": [
"last 3 chrome version",
"last 10 chrome version",
"last 3 firefox version",
"last 5 safari version"
]
Expand Down
56 changes: 56 additions & 0 deletions plugins/svg-fix.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import path from "path";
import { Plugin } from "@docusaurus/types";
import { RuleSetRule } from "webpack";
import { Config as SvgrConfig } from "@svgr/core";

// This plugin is used to fix duplicate IDs in svg styles.
// For more details, see: https://github.com/facebook/docusaurus/issues/8297
export function svgFixPlugin(): Plugin {
return {
name: "svg-fix",
configureWebpack(config) {
const svgRule = config.module?.rules?.find(r =>
(r as { test: RegExp }).test.test("file.svg"),
) as RuleSetRule | undefined;
if (!svgRule) {
console.warn("Failed to apply SVG fix, could not find SVG rule in webpack config!");
return {};
}
const svgrLoader = svgRule.oneOf?.find(
r =>
((r as RuleSetRule).use as object[] | undefined)?.length === 1 &&
((r as RuleSetRule).use as { loader: string }[])?.[0].loader.includes(
"@svgr/webpack",
),
);
if (!svgrLoader) {
console.warn(
"Failed to apply SVG fix, could not find svgr loader in webpack config!",
);
return {};
}

const svgoConfig = (svgrLoader.use as { options: SvgrConfig }[])[0].options.svgoConfig;
if (!svgoConfig?.plugins) {
console.warn(
"Failed to apply SVG fix, could not find svgo config in webpack config!",
);
return {};
}

svgoConfig.plugins.push({
name: "prefixIds",
params: {
delim: "_",
prefix: (element, file) => {
return path.basename(file?.path ?? "").split(".")[0];
},
prefixIds: true,
prefixClassNames: true,
},
});

return {};
},
};
}
35 changes: 35 additions & 0 deletions src/components/AnimatedAppear/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import React from "react";
import { animated, useInView } from "react-spring";

interface AnimatedAppearProps {
children: React.ReactNode;
className?: string;
onAppear?: () => void;
}

export function AnimatedAppear(props: AnimatedAppearProps) {
const [ref, styles] = useInView(
() => ({
from: {
opacity: 0,
y: 100,
},
to: {
opacity: 1,
y: 0,
},
onRest: () => {
props.onAppear?.();
},
}),
{
rootMargin: "100% 0% -10% 0%",
},
);

return (
<animated.div ref={ref} style={styles} className={props.className}>
{props.children}
</animated.div>
);
}
2 changes: 1 addition & 1 deletion src/components/AnimatedPlanet/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export function AnimatedPlanet(props: AnimatedPlanetProps) {
return (
<div
className={clsx(
"animated-planet flex aspect-square w-full items-center",
"animated-planet flex aspect-square w-full items-center overflow-hidden",
props.className,
)}
ref={boundingBoxRef}
Expand Down
13 changes: 13 additions & 0 deletions src/components/DemoStats/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
interface DemoStatsProps {
value: string;
description: string;
}

export function DemoStats(props: DemoStatsProps) {
return (
<div className="flex flex-col text-white">
<div className="text-center text-2xl font-bold">{props.value}</div>
<div className="text-center text-lg leading-tight">{props.description}</div>
</div>
);
}
52 changes: 52 additions & 0 deletions src/components/FeatureBlock/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { ReactNode } from "react";
import clsx from "clsx";
import TickIcon from "@site/static/icons/tick-bold.svg";

export enum FeatureBlockOrder {
PictureOnTheLeft,
PictureOnTheRight,
}

interface FeatureBlockProps {
heading: ReactNode;
description: string;
items: string[];
order: FeatureBlockOrder;
imgSrc: string;
className?: string;
}

export function FeatureBlock(props: FeatureBlockProps) {
console.log(props.imgSrc);
return (
<div
className={clsx(
"flex justify-between",
{ "flex-row-reverse": props.order === FeatureBlockOrder.PictureOnTheLeft },
props.className,
)}
>
<div className="flex flex-grow basis-1/2 flex-col justify-center overflow-hidden">
<div className="text-xl font-bold text-gray-700 sm:text-2xl">{props.heading}</div>
<img className="sm:hidden" src={props.imgSrc} alt="Feature Image" />
<div className="mt-4 text-lg font-medium text-gray-500">{props.description}</div>
<div className="mt-4 columns-2">
{props.items.map(item => (
<div
key={item}
className="mb-3 flex max-w-48 items-center text-lg font-medium text-gray-500"
>
<TickIcon className="mr-1 size-5 flex-shrink-0 fill-gray-500" />
{item}
</div>
))}
</div>
</div>
<img
className="hidden basis-1/2 overflow-hidden sm:block"
src={props.imgSrc}
alt="Feature Image"
/>
</div>
);
}
40 changes: 40 additions & 0 deletions src/components/FeatureCard/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import clsx from "clsx";
import { ReactNode } from "react";

export interface FeatureCardProps {
icon: ReactNode;
heading: string;
items: string[];
className?: string;
}

export function FeatureCard(props: FeatureCardProps) {
return (
<div
className={clsx(
"grid break-inside-avoid grid-flow-row grid-cols-[48px_auto] grid-rows-[auto_1fr]",
)}
>
<div className="flex items-center justify-center">
<div className="flex size-12 items-center justify-center rounded-full bg-indigo-200">
<div className="flex size-6 h-min flex-shrink-0 items-center justify-center fill-indigo-600">
{props.icon}
</div>
</div>
</div>
<div className="ml-3 flex items-center fill-indigo-600 text-xl font-medium text-gray-700">
{props.heading}
</div>
<div className="flex items-center justify-center pt-3">
<div className="h-full w-0.5 bg-gradient-to-b from-indigo-600 to-transparent"></div>
</div>
<div className="ml-3 pb-5 pt-1">
{props.items.map(item => (
<div className="mt-4 text-lg leading-6 text-gray-500" key={item}>
{item}
</div>
))}
</div>
</div>
);
}
2 changes: 1 addition & 1 deletion src/components/FeaturesDemo/AnimatedHeading.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ interface HeadingProps {
children: ReactNode;
}

function Heading(props: HeadingProps) {
export function Heading(props: HeadingProps) {
return (
<div className="text-center text-xl font-bold text-white xs:text-2xl sm:text-3xl 2xl:text-4xl">
{props.children}
Expand Down
7 changes: 6 additions & 1 deletion src/components/FeaturesDemo/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,12 @@ export function FeaturesDemo(props: { className?: string }) {
);

return (
<div className={clsx("features-demo flex h-[90vh] w-full flex-col", props.className)}>
<div
className={clsx(
"features-demo pointer-events-none flex w-full flex-col",
props.className,
)}
>
{headingMemo}
{windows}
</div>
Expand Down
Loading

0 comments on commit 78e88c1

Please sign in to comment.