Improved onboarding (#292)

* Only show the Example Jobs list when you have 1 job

* Updated the logic for displaying the different information depending on the no. of jobs you have

* Removed some unnecessary markup

* Clicking on a radio option toggles the content

* Improved the centering of the help panel

* Conetent updates to the 2 onboarding paths

* Added a prompt so you click through to run your job

* More content updates to the help panel

* Only show the prompt if the Job has never been run

* Added back in the help panel which shows the examples table if you have > 0 jobs

* Added a dialog for the I am Stuck button

* Added the new ‘new-next-app’ text for the cli command

* Refactored the ternary logic so it’s simpler

* Removed I’m stuck button and cleaned up imports

* Added in feedback button

* Added margin bottom to the Callout on the Test popover

* WIP adding a new radio button variant that takes an icon

* Added a new step to create a new next app

* The state of the tabs is stored as a URL param

* Small shadow tweak to the side panel

* Added a Discord button to the feedback menu

* Added new icons to the Named icons component

* Added a gradient to the background of the jobs page

* Made the icons take on color outside of component

* Added another NamedIcon for tree

* Fixed number

* Improved some of the typography styles

* Updated the icons

* Fixed issue with radio buttons alignment

* Added a missing step to the new next app onboarding

* Refactored example code and added all the examples to the panel

* Small icon update

* Made the title white again

* Added an icon to the storybook radiogroup

* Added a badges storybook

* Chevron table cell now takes children

* import cleanup

* Changed the background image from an arbirary value to an import

* Added a NEW badge which shows if you have a new job

* Improved the copy on the Examples help panel and updated some of the layout

* Removed defaultOpen on the help panel

* Stop the icons getting smaller

---------

Co-authored-by: D-K-P <dkp.github@pm.me>
This commit is contained in:
James Ritchie
2023-08-09 15:00:08 +01:00
committed by GitHub
parent 321378db4f
commit 645643ea41
19 changed files with 994 additions and 303 deletions
@@ -0,0 +1,161 @@
export function OneTreeIcon({ className }: { className?: string }) {
return (
<svg
className={className}
width="20"
height="20"
viewBox="0 0 20 20"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<g clipPath="url(#clip0_4914_58397)">
<g filter="url(#filter0_d_4914_58397)">
<path
d="M9 14H11C11 14 11 15 11 17C11 19 11.5 20 11.5 20H8.5C8.5 20 9 19 9 17C9 15 9 14 9 14Z"
fill="url(#paint0_linear_4914_58397)"
/>
</g>
<g filter="url(#filter1_d_4914_58397)">
<circle cx="5.5" cy="8.5" r="3.5" fill="currentColor" />
</g>
<g filter="url(#filter2_d_4914_58397)">
<circle cx="8" cy="12" r="3" fill="currentColor" />
</g>
<circle cx="13" cy="11" r="4" fill="currentColor" />
<circle cx="15.5" cy="7.5" r="2.5" fill="currentColor" />
<g filter="url(#filter3_d_4914_58397)">
<circle cx="9" cy="6" r="4" fill="currentColor" />
</g>
<circle cx="12.5" cy="5.5" r="3.5" fill="currentColor" />
</g>
<defs>
<filter
id="filter0_d_4914_58397"
x="4.5"
y="14"
width="11"
height="14"
filterUnits="userSpaceOnUse"
colorInterpolationFilters="sRGB"
>
<feFlood floodOpacity="0" result="BackgroundImageFix" />
<feColorMatrix
in="SourceAlpha"
type="matrix"
values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0"
result="hardAlpha"
/>
<feOffset dy="4" />
<feGaussianBlur stdDeviation="2" />
<feComposite in2="hardAlpha" operator="out" />
<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0" />
<feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_4914_58397" />
<feBlend
mode="normal"
in="SourceGraphic"
in2="effect1_dropShadow_4914_58397"
result="shape"
/>
</filter>
<filter
id="filter1_d_4914_58397"
x="-2"
y="5"
width="15"
height="15"
filterUnits="userSpaceOnUse"
colorInterpolationFilters="sRGB"
>
<feFlood floodOpacity="0" result="BackgroundImageFix" />
<feColorMatrix
in="SourceAlpha"
type="matrix"
values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0"
result="hardAlpha"
/>
<feOffset dy="4" />
<feGaussianBlur stdDeviation="2" />
<feComposite in2="hardAlpha" operator="out" />
<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0" />
<feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_4914_58397" />
<feBlend
mode="normal"
in="SourceGraphic"
in2="effect1_dropShadow_4914_58397"
result="shape"
/>
</filter>
<filter
id="filter2_d_4914_58397"
x="1"
y="9"
width="14"
height="14"
filterUnits="userSpaceOnUse"
colorInterpolationFilters="sRGB"
>
<feFlood floodOpacity="0" result="BackgroundImageFix" />
<feColorMatrix
in="SourceAlpha"
type="matrix"
values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0"
result="hardAlpha"
/>
<feOffset dy="4" />
<feGaussianBlur stdDeviation="2" />
<feComposite in2="hardAlpha" operator="out" />
<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0" />
<feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_4914_58397" />
<feBlend
mode="normal"
in="SourceGraphic"
in2="effect1_dropShadow_4914_58397"
result="shape"
/>
</filter>
<filter
id="filter3_d_4914_58397"
x="1"
y="-2"
width="16"
height="16"
filterUnits="userSpaceOnUse"
colorInterpolationFilters="sRGB"
>
<feFlood floodOpacity="0" result="BackgroundImageFix" />
<feColorMatrix
in="SourceAlpha"
type="matrix"
values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0"
result="hardAlpha"
/>
<feOffset />
<feGaussianBlur stdDeviation="2" />
<feComposite in2="hardAlpha" operator="out" />
<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0" />
<feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_4914_58397" />
<feBlend
mode="normal"
in="SourceGraphic"
in2="effect1_dropShadow_4914_58397"
result="shape"
/>
</filter>
<linearGradient
id="paint0_linear_4914_58397"
x1="10"
y1="14"
x2="10"
y2="20"
gradientUnits="userSpaceOnUse"
>
<stop stopColor="#402309" />
<stop offset="1" stopColor="#713F12" />
</linearGradient>
<clipPath id="clip0_4914_58397">
<rect width="20" height="20" fill="white" />
</clipPath>
</defs>
</svg>
);
}
@@ -0,0 +1,137 @@
export function SaplingIcon({ className }: { className?: string }) {
return (
<svg
className={className}
width="20"
height="20"
viewBox="0 0 20 20"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<g clipPath="url(#clip0_4906_23816)">
<path
d="M4.39538 17.7403C7.25332 16.3563 13.2867 16.4291 15.5096 17.7403C16.6666 18.4227 17.2938 19.0069 17.6294 19.4103C17.8542 19.6806 17.651 20 17.2994 20H2.34215C2.151 20 1.9749 19.8835 2.01519 19.6967C2.09465 19.3281 2.53308 18.6421 4.39538 17.7403Z"
fill="url(#paint0_linear_4906_23816)"
/>
<g filter="url(#filter0_d_4906_23816)">
<path
d="M9.37762 9.80872C7.43627 7.16364 3.49903 8.13783 2.43836 8.66818C2.26159 9.02174 3.32907 8.80396 4.08851 10.8279C4.84794 12.8519 7.63503 13.1864 8.74087 12.0806C9.27121 11.5502 9.69141 10.2363 9.37762 9.80872Z"
fill="currentColor"
/>
</g>
<g filter="url(#filter1_d_4906_23816)">
<path
d="M9.03577 9.94522L9.99862 9.80223C9.99862 9.80223 10.0387 16.2908 10.9485 16.8179C11.8582 17.345 8.47933 17.1309 8.92618 16.8179C9.37303 16.505 9.03577 9.94522 9.03577 9.94522Z"
fill="currentColor"
/>
</g>
<g filter="url(#filter2_d_4906_23816)">
<path
d="M9.36235 10.1127C9.36235 5.78131 13.3229 4.41473 15.9395 4.00389C16.1892 3.96468 16.3818 4.22916 16.2961 4.46698C16.0763 5.07608 15.7914 6.09975 15.6717 7.46762C15.5019 9.40897 14.8971 10.3478 14.3613 10.962C13.3664 12.1026 9.36235 12.2341 9.36235 10.1127Z"
fill="currentColor"
/>
</g>
</g>
<defs>
<filter
id="filter0_d_4906_23816"
x="-1.58107"
y="8.04684"
width="15.0664"
height="12.6571"
filterUnits="userSpaceOnUse"
colorInterpolationFilters="sRGB"
>
<feFlood floodOpacity="0" result="BackgroundImageFix" />
<feColorMatrix
in="SourceAlpha"
type="matrix"
values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0"
result="hardAlpha"
/>
<feOffset dy="4" />
<feGaussianBlur stdDeviation="2" />
<feComposite in2="hardAlpha" operator="out" />
<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0" />
<feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_4906_23816" />
<feBlend
mode="normal"
in="SourceGraphic"
in2="effect1_dropShadow_4906_23816"
result="shape"
/>
</filter>
<filter
id="filter1_d_4906_23816"
x="4.88525"
y="9.80223"
width="10.2195"
height="15.3357"
filterUnits="userSpaceOnUse"
colorInterpolationFilters="sRGB"
>
<feFlood floodOpacity="0" result="BackgroundImageFix" />
<feColorMatrix
in="SourceAlpha"
type="matrix"
values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0"
result="hardAlpha"
/>
<feOffset dy="4" />
<feGaussianBlur stdDeviation="2" />
<feComposite in2="hardAlpha" operator="out" />
<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0" />
<feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_4906_23816" />
<feBlend
mode="normal"
in="SourceGraphic"
in2="effect1_dropShadow_4906_23816"
result="shape"
/>
</filter>
<filter
id="filter2_d_4906_23816"
x="5.36235"
y="4"
width="14.9544"
height="15.7756"
filterUnits="userSpaceOnUse"
colorInterpolationFilters="sRGB"
>
<feFlood floodOpacity="0" result="BackgroundImageFix" />
<feColorMatrix
in="SourceAlpha"
type="matrix"
values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0"
result="hardAlpha"
/>
<feOffset dy="4" />
<feGaussianBlur stdDeviation="2" />
<feComposite in2="hardAlpha" operator="out" />
<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0" />
<feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_4906_23816" />
<feBlend
mode="normal"
in="SourceGraphic"
in2="effect1_dropShadow_4906_23816"
result="shape"
/>
</filter>
<linearGradient
id="paint0_linear_4906_23816"
x1="10"
y1="16.7294"
x2="10"
y2="20"
gradientUnits="userSpaceOnUse"
>
<stop offset="0.291667" stopColor="#402309" />
<stop offset="1" stopColor="#713F12" />
</linearGradient>
<clipPath id="clip0_4906_23816">
<rect width="20" height="20" fill="white" />
</clipPath>
</defs>
</svg>
);
}
@@ -0,0 +1,44 @@
export function TwoTreesIcon({ className }: { className?: string }) {
return (
<svg
className={className}
width="20"
height="20"
viewBox="0 0 20 20"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<g clipPath="url(#clip0_4906_58417)">
<path
d="M10 20V17"
stroke="currentColor"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
/>
<path
fillRule="evenodd"
clipRule="evenodd"
d="M17.7239 16.3L14.8274 13H15.1171C15.3061 12.9973 15.4901 12.9371 15.6464 12.8271C15.8027 12.717 15.9243 12.5619 15.9963 12.3808C16.0683 12.1998 16.0873 12.001 16.0512 11.8088C16.015 11.6167 15.9252 11.4398 15.7929 11.3L12.8965 8H13.0896C13.2868 8.01843 13.4847 7.97361 13.6565 7.87162C13.8282 7.76963 13.9656 7.6154 14.0499 7.42984C14.1342 7.24428 14.1614 7.03636 14.1278 6.83425C14.0942 6.63215 14.0014 6.44564 13.862 6.3L10 2L7.29699 5.0096C8.25755 5.0792 9.16726 5.48607 9.85673 6.16512C10.5124 6.81087 10.9224 7.65741 11.023 8.56163C11.6295 8.91846 12.136 9.42887 12.4856 10.0473C12.9492 10.8671 13.1066 11.8229 12.9286 12.7472C12.7507 13.6714 12.2496 14.5014 11.5168 15.0945C10.8041 15.6712 9.91568 15.9888 8.99914 15.999V18H17.0481C17.237 17.9973 17.4211 17.9371 17.5774 17.8271C17.7337 17.717 17.8553 17.5618 17.9273 17.3808C17.9992 17.1998 18.0183 17.001 17.9822 16.8088C17.946 16.6167 17.8562 16.4398 17.7239 16.3ZM7.99914 18V15.9991H6.00231V18H7.99914ZM4.97036 15.9991H5.00231L5.00231 18H2.95193C2.76296 17.9973 2.57892 17.9371 2.42263 17.8271C2.26635 17.717 2.14468 17.5618 2.07272 17.3808C2.00076 17.1998 1.98168 17.001 2.01783 16.8088C2.05398 16.6167 2.14377 16.4398 2.27609 16.3L3.01417 15.4591C3.59927 15.795 4.26325 15.9821 4.94587 15.9988C4.95403 15.999 4.9622 15.9991 4.97036 15.9991ZM3.69171 14.6872C4.08702 14.8804 4.52307 14.9881 4.97036 14.9991H8.93032C9.64375 15.0045 10.3365 14.7632 10.8877 14.3171C11.4389 13.871 11.8137 13.2485 11.9466 12.5581C12.0796 11.8678 11.9623 11.1534 11.6151 10.5395C11.268 9.9256 10.7131 9.45119 10.0472 9.19898V8.99898C10.0472 8.20331 9.7263 7.44023 9.15504 6.87761C8.58378 6.31499 7.80899 5.99891 7.00111 5.99891C6.77881 5.99891 6.55901 6.02285 6.34528 6.06926L6.13804 6.3C5.99864 6.44564 5.90584 6.63215 5.87222 6.83425C5.8386 7.03636 5.86579 7.24428 5.9501 7.42984C6.03441 7.6154 6.17176 7.76963 6.34354 7.87162C6.51533 7.97361 6.71323 8.01843 6.91043 8H7.10353L4.20706 11.3C4.07475 11.4398 3.98496 11.6167 3.94881 11.8088C3.91266 12.001 3.93174 12.1998 4.0037 12.3808C4.07566 12.5619 4.19732 12.717 4.35361 12.8271C4.5099 12.9371 4.69394 12.9973 4.88291 13H5.17255L3.69171 14.6872Z"
fill="currentColor"
/>
<path
d="M7 20L7 13.9814"
stroke="currentColor"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
/>
<path
d="M10.0472 9V9.2C10.7131 9.4522 11.268 9.92661 11.6151 10.5405C11.9623 11.1544 12.0796 11.8687 11.9466 12.5591C11.8137 13.2494 11.4389 13.8719 10.8877 14.318C10.3365 14.7641 9.64374 15.0054 8.93032 15H4.97036C4.26546 14.9827 3.58847 14.7251 3.05487 14.2712C2.52126 13.8172 2.1641 13.195 2.0443 12.5106C1.92449 11.8263 2.04946 11.1222 2.3979 10.5185C2.74634 9.91474 3.29666 9.44875 3.95499 9.2V9C3.95499 8.20435 4.27592 7.44129 4.84718 6.87868C5.41843 6.31607 6.19323 6 7.00111 6C7.80899 6 8.58378 6.31607 9.15504 6.87868C9.7263 7.44129 10.0472 8.20435 10.0472 9Z"
fill="currentColor"
/>
</g>
<defs>
<clipPath id="clip0_4906_58417">
<rect width="20" height="20" fill="white" />
</clipPath>
</defs>
</svg>
);
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 181 KiB

+34 -6
View File
@@ -20,6 +20,8 @@ import {
} from "./primitives/Select";
import { Sheet, SheetBody, SheetContent, SheetHeader, SheetTrigger } from "./primitives/Sheet";
import { TextArea } from "./primitives/TextArea";
import { DiscordIcon } from "@trigger.dev/companyicons";
import { ChevronRightIcon } from "@heroicons/react/24/solid";
type FeedbackProps = {
button: ReactNode;
@@ -55,14 +57,15 @@ export function Feedback({ button, defaultValue = "bug" }: FeedbackProps) {
<SheetContent size="sm">
<SheetHeader className="justify-between">Help & feedback</SheetHeader>
<SheetBody>
<Paragraph variant="small" className="mb-4">
Use this form to ask for help or give us feedback. We read every message and will get
<DiscordBanner />
<Paragraph variant="small" className="mb-4 border-t border-slate-800 pt-3">
Or use this form to ask for help or give us feedback. We read every message and will get
back to you as soon as we can.
</Paragraph>
<Form method="post" action="/resources/feedback" {...form.props}>
<Fieldset>
<Fieldset className="max-w-full">
<input value={location.pathname} {...conform.input(path, { type: "hidden" })} />
<InputGroup>
<InputGroup className="max-w-full">
<Label>How can we help?</Label>
<SelectGroup>
<Select {...conform.input(feedbackType)} defaultValue={defaultValue}>
@@ -80,14 +83,14 @@ export function Feedback({ button, defaultValue = "bug" }: FeedbackProps) {
</SelectGroup>
<FormError id={feedbackType.errorId}>{feedbackType.error}</FormError>
</InputGroup>
<InputGroup>
<InputGroup className="max-w-full">
<Label>Message</Label>
<TextArea {...conform.textarea(message)} />
<FormError id={message.errorId}>{message.error}</FormError>
</InputGroup>
<FormError>{form.error}</FormError>
<FormButtons
className="max-w-md"
className="w-full"
confirmButton={
<Button type="submit" variant="primary/medium">
Send
@@ -101,3 +104,28 @@ export function Feedback({ button, defaultValue = "bug" }: FeedbackProps) {
</Sheet>
);
}
function DiscordBanner() {
return (
<a
href="https://discord.gg/aYUfEqBP"
target="_blank"
className="group mb-4 flex w-full items-center justify-between rounded-md border border-slate-600 bg-gradient-to-br from-blue-400/30 to-indigo-400/50 p-4 transition hover:border-indigo-400"
>
<div className="flex flex-col gap-y-2">
<DiscordIcon className="h-8 w-8" />
<h2 className="font-title text-2xl text-bright transition group-hover:text-white">
Join the Trigger.dev
<br />
Discord community
</h2>
<Paragraph variant="small">
Get help or answer questions from the Trigger.dev community.
</Paragraph>
</div>
<div className="h-full">
<ChevronRightIcon className="h-5 w-5 text-slate-400 transition group-hover:translate-x-1 group-hover:text-indigo-400" />
</div>
</a>
);
}
@@ -1,4 +1,6 @@
import { Link } from "@remix-run/react";
import { ChatBubbleLeftRightIcon } from "@heroicons/react/20/solid";
import { Link, useSearchParams } from "@remix-run/react";
import invariant from "tiny-invariant";
import { Paragraph } from "~/components/primitives/Paragraph";
import { StepNumber } from "~/components/primitives/StepNumber";
import { useAppOrigin } from "~/hooks/useAppOrigin";
@@ -8,6 +10,7 @@ import { useOrganization } from "~/hooks/useOrganizations";
import { useProject } from "~/hooks/useProject";
import { IntegrationIcon } from "~/routes/_app.orgs.$organizationSlug.projects.$projectParam.integrations/route";
import { jobTestPath } from "~/utils/pathBuilder";
import { Feedback } from "../Feedback";
import { CodeBlock } from "../code/CodeBlock";
import { InlineCode } from "../code/InlineCode";
import { EnvironmentLabel } from "../environments/EnvironmentLabel";
@@ -23,132 +26,199 @@ import {
ClientTabsTrigger,
} from "../primitives/ClientTabs";
import { ClipboardField } from "../primitives/ClipboardField";
import { Header2 } from "../primitives/Headers";
import { Header1, Header2 } from "../primitives/Headers";
import { NamedIcon } from "../primitives/NamedIcon";
import { RadioGroup, RadioGroupItem } from "../primitives/RadioButton";
import { TextLink } from "../primitives/TextLink";
import integrationButton from "./integration-button.png";
import selectEnvironment from "./select-environment.png";
import selectExample from "./select-example.png";
import gradientBackground from "~/assets/images/gradient-background.png";
const existingProjectValue = "use-existing-project";
const newProjectValue = "create-new-next-app";
export function HowToSetupYourProject() {
const devEnvironment = useDevEnvironment();
const appOrigin = useAppOrigin();
return (
<>
<StepNumber stepNumber="1" title="Run the CLI 'init' command in a Next.js project" />
<StepContentContainer>
<ClientTabs defaultValue="npm">
<ClientTabsList>
<ClientTabsTrigger value={"npm"}>npm</ClientTabsTrigger>
<ClientTabsTrigger value={"pnpm"}>pnpm</ClientTabsTrigger>
<ClientTabsTrigger value={"yarn"}>yarn</ClientTabsTrigger>
</ClientTabsList>
<ClientTabsContent value={"npm"}>
<ClipboardField
variant="primary/medium"
className="mb-4"
secure={`npx @trigger.dev/cli@latest init -k ••••••••• -t ${appOrigin}`}
value={`npx @trigger.dev/cli@latest init -k ${devEnvironment?.apiKey} -t ${appOrigin}`}
/>
</ClientTabsContent>
<ClientTabsContent value={"pnpm"}>
<ClipboardField
variant="primary/medium"
className="mb-4"
secure={`pnpm dlx @trigger.dev/cli@latest init -k ••••••••• -t ${appOrigin}`}
value={`pnpm dlx @trigger.dev/cli@latest init -k ${devEnvironment?.apiKey} -t ${appOrigin}`}
/>
</ClientTabsContent>
<ClientTabsContent value={"yarn"}>
<ClipboardField
variant="primary/medium"
className="mb-4"
secure={`yarn dlx @trigger.dev/cli@latest init -k ••••••••• -t ${appOrigin}`}
value={`yarn dlx @trigger.dev/cli@latest init -k ${devEnvironment?.apiKey} -t ${appOrigin}`}
/>
</ClientTabsContent>
</ClientTabs>
<Paragraph spacing>
Youll notice a new folder in your project called 'jobs'. Weve added a very simple
example Job in <InlineCode>examples.ts</InlineCode> to help you get started.
</Paragraph>
</StepContentContainer>
<StepNumber stepNumber="2" title="Run your Next.js app" />
<StepContentContainer>
<Paragraph>Ensure your app is running locally.</Paragraph>
<ClientTabs defaultValue="npm">
<ClientTabsList>
<ClientTabsTrigger value={"npm"}>npm</ClientTabsTrigger>
<ClientTabsTrigger value={"pnpm"}>pnpm</ClientTabsTrigger>
<ClientTabsTrigger value={"yarn"}>yarn</ClientTabsTrigger>
</ClientTabsList>
<ClientTabsContent value={"npm"}>
<ClipboardField variant="primary/medium" className="mb-4" value={`npm run dev`} />
</ClientTabsContent>
<ClientTabsContent value={"pnpm"}>
<ClipboardField variant="primary/medium" className="mb-4" value={`pnpm run dev`} />
</ClientTabsContent>
<ClientTabsContent value={"yarn"}>
<ClipboardField variant="primary/medium" className="mb-4" value={`yarn run dev`} />
</ClientTabsContent>
</ClientTabs>
</StepContentContainer>
<StepNumber stepNumber="3" title="Run the CLI 'dev' command" />
<StepContentContainer>
<Paragraph spacing>
In a <strong className="text-bright">separate terminal window or tab</strong> run:
</Paragraph>
<ClientTabs defaultValue="npm">
<ClientTabsList>
<ClientTabsTrigger value={"npm"}>npm</ClientTabsTrigger>
<ClientTabsTrigger value={"pnpm"}>pnpm</ClientTabsTrigger>
<ClientTabsTrigger value={"yarn"}>yarn</ClientTabsTrigger>
</ClientTabsList>
<ClientTabsContent value={"npm"}>
<ClipboardField
variant="primary/medium"
className="mb-4"
value={`npx @trigger.dev/cli@latest dev`}
/>
</ClientTabsContent>
<ClientTabsContent value={"pnpm"}>
<ClipboardField
variant="primary/medium"
className="mb-4"
value={`pnpm dlx @trigger.dev/cli@latest dev`}
/>
</ClientTabsContent>
<ClientTabsContent value={"yarn"}>
<ClipboardField
variant="primary/medium"
className="mb-4"
value={`yarn dlx @trigger.dev/cli@latest dev`}
/>
</ClientTabsContent>
</ClientTabs>
<Paragraph spacing variant="small">
If youre not running on port 3000 you can specify the port by adding{" "}
<InlineCode>--port 3001</InlineCode> to the end.
</Paragraph>
<Paragraph spacing variant="small">
You should leave the <InlineCode>dev</InlineCode> command running when you're developing.
</Paragraph>
</StepContentContainer>
<StepNumber stepNumber="4" title="Check for Jobs" />
<StepContentContainer>
<Paragraph>
Once you've run the CLI command, click Refresh to view your example Job in the list.
</Paragraph>
<Button
variant="primary/medium"
className="mt-4"
LeadingIcon="refresh"
onClick={() => window.location.reload()}
const [searchQuery, setSearchQuery] = useSearchParams();
const selectedValue = searchQuery.get("selectedValue");
invariant(devEnvironment, "devEnvironment is required");
return (
<div
className="-ml-4 -mt-4 h-full w-[calc(100%+32px)] bg-cover bg-no-repeat pt-20"
style={{ backgroundImage: `url("${gradientBackground}")` }}
>
<div className="mx-auto max-w-3xl">
<div className="flex items-center justify-between">
<Header1 spacing className="text-bright">
Get setup in {selectedValue === newProjectValue ? "5" : "2"} minutes
</Header1>
<Feedback
button={
<Button variant="secondary/small" LeadingIcon={ChatBubbleLeftRightIcon}>
I'm stuck!
</Button>
}
defaultValue="help"
/>
</div>
<RadioGroup
className="mb-4 flex gap-x-2"
onValueChange={(value) => setSearchQuery({ selectedValue: value })}
>
Refresh
</Button>
</StepContentContainer>
</>
<RadioGroupItem
label="Use an existing Next.js project"
description="Use Trigger.dev in an existing Next.js project in less than 2 mins."
value={existingProjectValue}
checked={selectedValue === existingProjectValue}
variant="icon"
data-action={existingProjectValue}
icon={<NamedIcon className="h-12 w-12 text-green-600" name={"tree"} />}
/>
<RadioGroupItem
label="Create a new Next.js project"
description="This is the quickest way to try out Trigger.dev in a new Next.js project and takes 5 mins."
value={newProjectValue}
checked={selectedValue === newProjectValue}
variant="icon"
data-action={newProjectValue}
icon={<NamedIcon className="h-8 w-8 text-green-600" name={"sapling"} />}
/>
</RadioGroup>
{selectedValue && (
<>
{selectedValue === newProjectValue ? (
<>
<StepNumber stepNumber="1" title="Create a new Next.js project" />
<StepContentContainer>
<ClientTabs defaultValue="npm">
<ClientTabsList>
<ClientTabsTrigger value={"npm"}>npm</ClientTabsTrigger>
<ClientTabsTrigger value={"pnpm"}>pnpm</ClientTabsTrigger>
<ClientTabsTrigger value={"yarn"}>yarn</ClientTabsTrigger>
</ClientTabsList>
<ClientTabsContent value={"npm"}>
<ClipboardField
variant="primary/medium"
className="mb-4"
value={`npx create-next-app@latest`}
/>
</ClientTabsContent>
<ClientTabsContent value={"pnpm"}>
<ClipboardField
variant="primary/medium"
className="mb-4"
value={`pnpm create next-app`}
/>
</ClientTabsContent>
<ClientTabsContent value={"yarn"}>
<ClipboardField
variant="primary/medium"
className="mb-4"
value={`yarn create next-app`}
/>
</ClientTabsContent>
</ClientTabs>
<Paragraph spacing variant="small">
Trigger.dev works with either the Pages or App Router configuration.
</Paragraph>
</StepContentContainer>
<StepNumber stepNumber="2" title="Navigate to your new Next.js project" />
<StepContentContainer>
<Paragraph spacing>
You have now created a new Next.js project. Lets <InlineCode>cd</InlineCode>{" "}
into it using the project name you just provided:
</Paragraph>
<ClipboardField
value={"cd [replace with your project name]"}
variant={"primary/medium"}
></ClipboardField>
</StepContentContainer>
<StepNumber
stepNumber="3"
title="Run the CLI 'init' command in your new Next.js project"
/>
<StepContentContainer>
<InitCommand appOrigin={appOrigin} apiKey={devEnvironment.apiKey} />
<Paragraph spacing variant="small">
Youll notice a new folder in your project called 'jobs'. Weve added a very
simple example Job in <InlineCode variant="extra-small">examples.ts</InlineCode>{" "}
to help you get started.
</Paragraph>
</StepContentContainer>
<StepNumber stepNumber="4" title="Run your Next.js app" />
<StepContentContainer>
<NextDevCommand />
</StepContentContainer>
<StepNumber stepNumber="5" title="Run the CLI 'dev' command" />
<StepContentContainer>
<TriggerDevStep />
</StepContentContainer>
<StepNumber stepNumber="6" title="Check for Jobs" />
<StepContentContainer>
<Paragraph>
Once you've run the CLI command, click Refresh to view your example Job in the
list.
</Paragraph>
<Button
variant="primary/medium"
className="mt-4"
LeadingIcon="refresh"
onClick={() => window.location.reload()}
>
Refresh
</Button>
</StepContentContainer>
</>
) : (
<>
<StepNumber
stepNumber="1"
title="Run the CLI 'init' command in an existing Next.js project"
/>
<StepContentContainer>
<InitCommand appOrigin={appOrigin} apiKey={devEnvironment.apiKey} />
<Paragraph spacing variant="small">
Youll notice a new folder in your project called 'jobs'. Weve added a very
simple example Job in <InlineCode variant="extra-small">examples.ts</InlineCode>{" "}
to help you get started.
</Paragraph>
</StepContentContainer>
<StepNumber stepNumber="2" title="Run your Next.js app" />
<StepContentContainer>
<NextDevCommand />
</StepContentContainer>
<StepNumber stepNumber="3" title="Run the CLI 'dev' command" />
<StepContentContainer>
<TriggerDevStep />
</StepContentContainer>
<StepNumber stepNumber="4" title="Check for Jobs" />
<StepContentContainer>
<Paragraph>
Once you've run the CLI command, click Refresh to view your example Job in the
list.
</Paragraph>
<Button
variant="primary/medium"
className="mt-4"
LeadingIcon="refresh"
onClick={() => window.location.reload()}
>
Refresh
</Button>
</StepContentContainer>
</>
)}
</>
)}
</div>
</div>
);
}
@@ -391,3 +461,112 @@ export function HowToUseApiKeysAndEndpoints() {
function StepContentContainer({ children }: { children: React.ReactNode }) {
return <div className="mb-6 ml-9 mt-1">{children}</div>;
}
function InitCommand({ appOrigin, apiKey }: { appOrigin: string; apiKey: string }) {
return (
<ClientTabs defaultValue="npm">
<ClientTabsList>
<ClientTabsTrigger value={"npm"}>npm</ClientTabsTrigger>
<ClientTabsTrigger value={"pnpm"}>pnpm</ClientTabsTrigger>
<ClientTabsTrigger value={"yarn"}>yarn</ClientTabsTrigger>
</ClientTabsList>
<ClientTabsContent value={"npm"}>
<ClipboardField
variant="primary/medium"
className="mb-4"
secure={`npx @trigger.dev/cli@latest init -k ••••••••• -t ${appOrigin}`}
value={`npx @trigger.dev/cli@latest init -k ${apiKey} -t ${appOrigin}`}
/>
</ClientTabsContent>
<ClientTabsContent value={"pnpm"}>
<ClipboardField
variant="primary/medium"
className="mb-4"
secure={`pnpm dlx @trigger.dev/cli@latest init -k ••••••••• -t ${appOrigin}`}
value={`pnpm dlx @trigger.dev/cli@latest init -k ${apiKey} -t ${appOrigin}`}
/>
</ClientTabsContent>
<ClientTabsContent value={"yarn"}>
<ClipboardField
variant="primary/medium"
className="mb-4"
secure={`yarn dlx @trigger.dev/cli@latest init -k ••••••••• -t ${appOrigin}`}
value={`yarn dlx @trigger.dev/cli@latest init -k ${apiKey} -t ${appOrigin}`}
/>
</ClientTabsContent>
</ClientTabs>
);
}
function NextDevCommand() {
return (
<ClientTabs defaultValue="npm">
<ClientTabsList>
<ClientTabsTrigger value={"npm"}>npm</ClientTabsTrigger>
<ClientTabsTrigger value={"pnpm"}>pnpm</ClientTabsTrigger>
<ClientTabsTrigger value={"yarn"}>yarn</ClientTabsTrigger>
</ClientTabsList>
<ClientTabsContent value={"npm"}>
<ClipboardField variant="primary/medium" className="mb-4" value={`npm run dev`} />
</ClientTabsContent>
<ClientTabsContent value={"pnpm"}>
<ClipboardField variant="primary/medium" className="mb-4" value={`pnpm run dev`} />
</ClientTabsContent>
<ClientTabsContent value={"yarn"}>
<ClipboardField variant="primary/medium" className="mb-4" value={`yarn run dev`} />
</ClientTabsContent>
</ClientTabs>
);
}
function TriggerDevCommand() {
return (
<ClientTabs defaultValue="npm">
<ClientTabsList>
<ClientTabsTrigger value={"npm"}>npm</ClientTabsTrigger>
<ClientTabsTrigger value={"pnpm"}>pnpm</ClientTabsTrigger>
<ClientTabsTrigger value={"yarn"}>yarn</ClientTabsTrigger>
</ClientTabsList>
<ClientTabsContent value={"npm"}>
<ClipboardField
variant="primary/medium"
className="mb-4"
value={`npx @trigger.dev/cli@latest dev`}
/>
</ClientTabsContent>
<ClientTabsContent value={"pnpm"}>
<ClipboardField
variant="primary/medium"
className="mb-4"
value={`pnpm dlx @trigger.dev/cli@latest dev`}
/>
</ClientTabsContent>
<ClientTabsContent value={"yarn"}>
<ClipboardField
variant="primary/medium"
className="mb-4"
value={`yarn dlx @trigger.dev/cli@latest dev`}
/>
</ClientTabsContent>
</ClientTabs>
);
}
function TriggerDevStep() {
return (
<>
<Paragraph spacing>
In a <span className="text-amber-400">separate terminal window or tab</span> run:
</Paragraph>
<TriggerDevCommand />
<Paragraph spacing variant="small">
If youre not running on port 3000 you can specify the port by adding{" "}
<InlineCode variant="extra-small">--port 3001</InlineCode> to the end.
</Paragraph>
<Paragraph spacing variant="small">
You should leave the <InlineCode variant="extra-small">dev</InlineCode> command running when
you're developing.
</Paragraph>
</>
);
}
+12 -2
View File
@@ -20,6 +20,7 @@ import { useProject } from "~/hooks/useProject";
import { useOrganization } from "~/hooks/useOrganizations";
import { JobRunStatus } from "~/models/job.server";
import { cn } from "~/utils/cn";
import { Badge } from "../primitives/Badge";
export function JobsTable({ jobs, noResultsText }: { jobs: ProjectJob[]; noResultsText: string }) {
const organization = useOrganization();
@@ -44,7 +45,10 @@ export function JobsTable({ jobs, noResultsText }: { jobs: ProjectJob[]; noResul
return (
<TableRow
key={job.id}
className={cn(job.hasIntegrationsRequiringAction && "bg-rose-500/30")}
className={cn(
(job.hasIntegrationsRequiringAction && "bg-rose-500/20") ||
(job.lastRun === undefined && "bg-green-500/20")
)}
>
<TableCell to={path}>
<span className="flex items-center gap-2">
@@ -141,7 +145,13 @@ export function JobsTable({ jobs, noResultsText }: { jobs: ProjectJob[]; noResul
<LabelValueStack label={"Never run"} value={""} />
)}
</TableCell>
<TableCellChevron to={path} />
<TableCellChevron to={path}>
{job.lastRun === undefined && (
<Badge className="mr-4" variant="green">
New Job!
</Badge>
)}
</TableCellChevron>
</TableRow>
);
})
@@ -6,12 +6,18 @@ const variants = {
"grid place-items-center rounded-full px-2 h-5 tracking-wider text-xxs bg-slate-700 text-bright uppercase whitespace-nowrap",
outline:
"grid place-items-center rounded-sm px-1 h-5 tracking-wider text-xxs border border-dimmed text-dimmed uppercase whitespace-nowrap",
green:
"grid place-items-center rounded-sm px-1.5 h-5 tracking-wider outline-offset-1 outline outline-1 outline-green-600 text-xxs bg-green-500 text-slate-900 uppercase whitespace-nowrap",
};
type BadgeProps = React.HTMLAttributes<HTMLDivElement> & {
variant?: keyof typeof variants;
};
export function Badge({ className, variant = "default", ...props }: BadgeProps) {
return <div className={cn(variants[variant], className)} {...props} />;
export function Badge({ className, variant = "default", children, ...props }: BadgeProps) {
return (
<div className={cn(variants[variant], className)} {...props}>
<span className="-mb-0.5">{children}</span>
</div>
);
}
@@ -1,5 +1,5 @@
import { cn } from "~/utils/cn";
import { Paragraph, ParagraphVariant } from "./Paragraph";
import { Paragraph } from "./Paragraph";
import { ArrowTopRightOnSquareIcon } from "@heroicons/react/20/solid";
import { SimpleTooltip } from "./Tooltip";
@@ -58,6 +58,9 @@ import { WebhookIcon } from "~/assets/icons/WebhookIcon";
import { cn } from "~/utils/cn";
import { LogoIcon } from "../LogoIcon";
import { Spinner } from "./Spinner";
import { SaplingIcon } from "~/assets/icons/SaplingIcon";
import { TwoTreesIcon } from "~/assets/icons/TwoTreesIcon";
import { OneTreeIcon } from "~/assets/icons/OneTreeIcon";
const icons = {
account: (className: string) => <UserCircleIcon className={cn("text-slate-400", className)} />,
@@ -128,6 +131,7 @@ const icons = {
property: (className: string) => <Cog8ToothIcon className={cn("text-slate-600", className)} />,
"qr-code": (className: string) => <QrCodeIcon className={cn("text-amber-400", className)} />,
refresh: (className: string) => <ArrowPathIcon className={cn("text-bright", className)} />,
sapling: (className: string) => <SaplingIcon className={cn("text-green-500", className)} />,
search: (className: string) => <MagnifyingGlassIcon className={cn("text-dimmed", className)} />,
settings: (className: string) => <Cog8ToothIcon className={cn("text-slate-600", className)} />,
spinner: (className: string) => <Spinner className={className} color="blue" />,
@@ -135,6 +139,8 @@ const icons = {
star: (className: string) => <StarIcon className={cn("text-yellow-500", className)} />,
stop: (className: string) => <StopIcon className={cn("text-rose-500", className)} />,
team: (className: string) => <UserGroupIcon className={cn("text-blue-500", className)} />,
tree: (className: string) => <OneTreeIcon className={cn("text-green-500", className)} />,
trees: (className: string) => <TwoTreesIcon className={cn("text-green-500", className)} />,
trigger: (className: string) => <BoltIcon className={cn("text-orange-500", className)} />,
user: (className: string) => <UserIcon className={cn("text-blue-600", className)} />,
warning: (className: string) => (
@@ -11,12 +11,14 @@ const variants = {
label: "text-sm text-bright mt-0.5 select-none",
description: "text-dimmed",
inputPosition: "mt-1",
icon: "w-8 h-8 mb-2",
},
simple: {
button: "w-fit pr-4 data-[disabled]:opacity-70",
label: "text-bright select-none",
description: "text-dimmed",
inputPosition: "mt-1",
icon: "w-8 h-8 mb-2",
},
"button/small": {
button:
@@ -24,6 +26,7 @@ const variants = {
label: "text-sm text-bright select-none",
description: "text-dimmed",
inputPosition: "mt-0",
icon: "w-8 h-8 mb-2",
},
button: {
button:
@@ -31,6 +34,7 @@ const variants = {
label: "text-bright select-none",
description: "text-dimmed",
inputPosition: "mt-1",
icon: "w-8 h-8 mb-2",
},
description: {
button:
@@ -38,6 +42,15 @@ const variants = {
label: "text-bright font-semibold -mt-1 text-left",
description: "text-dimmed -mt-0 text-left",
inputPosition: "mt-0",
icon: "w-8 h-8 mb-2",
},
icon: {
button:
"w-full p-2.5 pb-4 hover:bg-slate-850 transition data-[disabled]:opacity-70 data-[state=checked]:bg-slate-850 border-slate-800 border rounded-sm",
label: "text-bright font-semibold -mt-1 text-left",
description: "text-dimmed -mt-0 text-left",
inputPosition: "mt-0",
icon: "mb-3",
},
};
@@ -57,53 +70,60 @@ type RadioGroupItemProps = Omit<
description?: string;
badges?: string[];
className?: string;
icon?: React.ReactNode;
};
export const RadioGroupItem = React.forwardRef<
React.ElementRef<typeof RadioGroupPrimitive.Item>,
RadioGroupItemProps
>(({ className, children, variant = "simple", label, description, badges, ...props }, ref) => {
const variation = variants[variant];
>(
(
{ className, children, variant = "simple", label, description, badges, icon, ...props },
ref
) => {
const variation = variants[variant];
return (
<RadioGroupPrimitive.Item
ref={ref}
className={cn(
"group flex cursor-pointer items-start gap-x-2 transition",
variation.button,
className
)}
{...props}
>
<div
return (
<RadioGroupPrimitive.Item
ref={ref}
className={cn(
"aspect-square h-4 w-4 shrink-0 overflow-hidden rounded-sm border border-slate-700 ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
variation.inputPosition
"group flex cursor-pointer items-start gap-x-2 transition",
variation.button,
className
)}
{...props}
>
<RadioGroupPrimitive.Indicator className="flex h-full w-full items-center justify-center bg-indigo-700">
<Circle className="h-1.5 w-1.5 fill-white text-white" />
</RadioGroupPrimitive.Indicator>
</div>
<div>
<div className="flex items-center gap-x-2">
<label htmlFor={props.id} className={cn("cursor-pointer", variation.label)}>
{label}
</label>
{badges && (
<span className="-mr-2 flex gap-x-1.5">
{badges.map((badge) => (
<Badge key={badge}>{badge}</Badge>
))}
</span>
<div
className={cn(
"aspect-square h-4 w-4 shrink-0 overflow-hidden rounded-sm border border-slate-700 ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
variation.inputPosition
)}
>
<RadioGroupPrimitive.Indicator className="flex h-full w-full items-center justify-center bg-indigo-700">
<Circle className="h-1.5 w-1.5 fill-white text-white" />
</RadioGroupPrimitive.Indicator>
</div>
<div className={cn(icon ? "flex h-full flex-col justify-end" : "")}>
{variant === "icon" && <div className={variation.icon}>{icon}</div>}
<div className="flex items-center gap-x-2">
<label htmlFor={props.id} className={cn("cursor-pointer", variation.label)}>
{label}
</label>
{badges && (
<span className="-mr-2 flex gap-x-1.5">
{badges.map((badge) => (
<Badge key={badge}>{badge}</Badge>
))}
</span>
)}
</div>
{(variant === "description" || variant === "icon") && (
<Paragraph variant="small" className={cn("mt-0.5", variation.description)}>
{description}
</Paragraph>
)}
</div>
{variant === "description" && (
<Paragraph variant="small" className={cn("mt-0.5", variation.description)}>
{description}
</Paragraph>
)}
</div>
</RadioGroupPrimitive.Item>
);
});
</RadioGroupPrimitive.Item>
);
}
);
@@ -51,7 +51,7 @@ const SheetOverlay = React.forwardRef<
SheetOverlay.displayName = SheetPrimitive.Overlay.displayName;
const sheetVariants = cva(
"fixed z-50 scale-100 gap-4 bg-midnight-900 shadow-lg shadow-indigo-900 opacity-100 border-l border-y border-slate-800",
"fixed z-50 scale-100 gap-4 bg-midnight-900 shadow-lg shadow-white/10 opacity-100 border-l border-y border-slate-800",
{
variants: {
position: {
@@ -2,6 +2,7 @@ import { ChevronRightIcon } from "@heroicons/react/24/solid";
import { Link } from "@remix-run/react";
import { ReactNode, forwardRef } from "react";
import { cn } from "~/utils/cn";
import { Badge } from "./Badge";
type TableProps = {
containerClassName?: string;
@@ -172,12 +173,14 @@ export const TableCellChevron = forwardRef<
{
className?: string;
to?: string;
children?: ReactNode;
onClick?: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
}
>(({ className, to, onClick }, ref) => {
>(({ className, to, children, onClick }, ref) => {
return (
<TableCell className={className} to={to} onClick={onClick} ref={ref} alignment="right">
<ChevronRightIcon className="h-4 w-4 text-slate-700 transition group-hover:text-bright" />
{children}
<ChevronRightIcon className="h-4 w-4 text-dimmed transition group-hover:text-bright" />
</TableCell>
);
});
@@ -325,7 +325,7 @@ function RerunPopover({
<Form method="post" action={`/resources/runs/${runId}/rerun`} {...form.props}>
<input {...conform.input(successRedirect, { type: "hidden" })} defaultValue={runsPath} />
{environmentType === "PRODUCTION" && (
<Callout variant="warning">
<Callout variant="warning" className="mb-2">
This will rerun this Job in your Production environment.
</Callout>
)}
@@ -0,0 +1,26 @@
import type { Meta, StoryObj } from "@storybook/react";
import { withDesign } from "storybook-addon-designs";
import { Badge } from "../primitives/Badge";
const meta: Meta = {
title: "Primitives/Badges",
decorators: [withDesign],
};
export default meta;
type Story = StoryObj<typeof BadgesExample>;
export const Basic: Story = {
render: () => <BadgesExample />,
};
function BadgesExample() {
return (
<div className="flex flex-col items-start gap-y-8 p-8">
<Badge>Default</Badge>
<Badge variant="outline">Outline</Badge>
<Badge variant="green">Green</Badge>
</div>
);
}
@@ -3,6 +3,7 @@ import { withDesign } from "storybook-addon-designs";
import { useState } from "react";
import { Button } from "../primitives/Buttons";
import { RadioGroup, RadioGroupItem } from "../primitives/RadioButton";
import { NamedIcon } from "../primitives/NamedIcon";
const meta: Meta = {
title: "Primitives/RadioGroup",
@@ -42,6 +43,14 @@ function RadioGroupExample() {
value={"5"}
variant="description"
/>
<RadioGroupItem
id="r7"
label="This is an icon label"
description="This is a description"
value={"6"}
variant="icon"
icon={<NamedIcon name="tree" className="h-8 w-8" />}
/>
</RadioGroup>
</form>
</div>
@@ -1,13 +1,18 @@
import { ArrowUpIcon } from "@heroicons/react/24/solid";
import { LoaderArgs } from "@remix-run/server-runtime";
import { GitHubLightIcon, OpenAILightIcon, ResendIcon } from "@trigger.dev/companyicons";
import { CalendarDaysIcon, ClockIcon, SlackIcon } from "lucide-react";
import useWindowSize from "react-use/lib/useWindowSize";
import { typedjson, useTypedLoaderData } from "remix-typedjson";
import Confetti from "react-confetti";
import { HowToSetupYourProject } from "~/components/helpContent/HelpContentText";
import { JobsTable } from "~/components/jobs/JobsTable";
import { PageBody, PageContainer } from "~/components/layout/AppLayout";
import { BreadcrumbLink } from "~/components/navigation/NavBar";
import { Callout } from "~/components/primitives/Callout";
import { Header2 } from "~/components/primitives/Headers";
import { Help, HelpContent, HelpTrigger } from "~/components/primitives/Help";
import { Input } from "~/components/primitives/Input";
import { NamedIcon } from "~/components/primitives/NamedIcon";
import {
PageHeader,
PageInfoGroup,
@@ -17,24 +22,19 @@ import {
PageTitleRow,
} from "~/components/primitives/PageHeader";
import { Paragraph } from "~/components/primitives/Paragraph";
import { TextLink } from "~/components/primitives/TextLink";
import { useFilterJobs } from "~/hooks/useFilterJobs";
import { useOrganization } from "~/hooks/useOrganizations";
import { useProject } from "~/hooks/useProject";
import { JobListPresenter } from "~/presenters/JobListPresenter.server";
import { requireUserId } from "~/services/session.server";
import { cn } from "~/utils/cn";
import { Handle } from "~/utils/handle";
import useWindowSize from "react-use/lib/useWindowSize";
import {
docsPath,
ProjectParamSchema,
projectIntegrationsPath,
trimTrailingSlash,
ProjectParamSchema,
} from "~/utils/pathBuilder";
import { BreadcrumbLink } from "~/components/navigation/NavBar";
import { requireUserId } from "~/services/session.server";
import { JobListPresenter } from "~/presenters/JobListPresenter.server";
import { TextLink } from "~/components/primitives/TextLink";
import { GitHubLightIcon, OpenAILightIcon, ResendIcon } from "@trigger.dev/companyicons";
import { ClockIcon, CalendarDaysIcon, SlackIcon } from "lucide-react";
export const loader = async ({ request, params }: LoaderArgs) => {
const userId = await requireUserId(request);
@@ -101,76 +101,51 @@ export default function Page() {
"rgb(217 70 239)",
]}
/> */}
<Help defaultOpen={jobs.length === 0}>
<Help>
{(open) => (
<div className={cn("grid h-fit gap-4", open ? "grid-cols-2" : "grid-cols-1")}>
<div>
{jobs.length > 0 && jobs.some((j) => j.hasIntegrationsRequiringAction) && (
<Callout
variant="error"
to={projectIntegrationsPath(organization, project)}
className="mb-2"
>
Some of your Jobs have Integrations that have not been configured.
</Callout>
)}
<div className="mb-2 flex items-center justify-between gap-x-2">
{jobs.length === 0 ? (
<Header2>Jobs</Header2>
) : (
<Input
placeholder="Search Jobs"
variant="tertiary"
icon="search"
fullWidth={true}
value={filterText}
onChange={(e) => setFilterText(e.target.value)}
/>
)}
<HelpTrigger title="How do I add Trigger.dev to my Next.js app?" />
</div>
{jobs.length === 0 ? (
<div>
<div
className={
"flex w-full flex-col justify-center gap-x-4 rounded-md border border-dashed border-indigo-800 px-5 py-8"
}
>
<Paragraph variant="small">Your Jobs will appear here.</Paragraph>
</div>
</div>
) : (
<div className={cn("grid gap-4", open ? "h-full grid-cols-2" : " h-full grid-cols-1")}>
<div className="h-full">
{jobs.length > 0 ? (
<>
{jobs.some((j) => j.hasIntegrationsRequiringAction) && (
<Callout
variant="error"
to={projectIntegrationsPath(organization, project)}
className="mb-2"
>
Some of your Jobs have Integrations that have not been configured.
</Callout>
)}
<div className="mb-2 flex flex-col">
<Header2 spacing>Jobs</Header2>
<div className="flex w-full">
<Input
placeholder="Search Jobs"
variant="tertiary"
icon="search"
fullWidth={true}
value={filterText}
onChange={(e) => setFilterText(e.target.value)}
/>
<HelpTrigger title="Example Jobs and inspiration" />
</div>
</div>
<JobsTable
jobs={filteredItems}
noResultsText={`No Jobs match ${filterText}. Try a different search
query.`}
query.`}
/>
{jobs.length === 1 ? (
<>
<Callout
variant="docs"
to={docsPath("documentation/guides/create-a-job")}
className="my-3"
>
Create your first Job in code
</Callout>
<ExampleJobs />
</>
) : (
<Callout
variant="docs"
to={docsPath("documentation/guides/create-a-job")}
className="my-3"
>
Create another Job
</Callout>
{jobs.length === 1 && jobs.every((r) => r.lastRun === undefined) && (
<RunYourJobPrompt />
)}
</>
) : (
<HowToSetupYourProject />
)}
</div>
<HelpContent title="How to add Trigger.dev to your Next.js app (3 mins)">
<HowToSetupYourProject />
<HelpContent title="Example Jobs and inspiration">
<ExampleJobs />
</HelpContent>
</div>
)}
@@ -180,69 +155,155 @@ export default function Page() {
);
}
function ExampleJobs() {
function RunYourJobPrompt() {
return (
<div className="mt-6 flex w-full flex-col gap-y-2 rounded bg-slate-900 p-4">
<Header2 className="text-slate-300">Example Jobs</Header2>
<Paragraph variant="small">
If you want more inspiration or just want to dig into the code of a Job, check out our{" "}
<TextLink href="https://github.com/triggerdotdev/examples">examples repo</TextLink>.
<div className="mt-2 flex w-full gap-x-2 rounded border border-slate-800 bg-slate-900 p-4 pl-6">
<ArrowUpIcon className="h-5 w-5 animate-bounce text-green-500" />
<Paragraph variant="small" className="text-green-500">
Your Job is ready to run! Click it to run it now.
</Paragraph>
<div className="h-[1px] w-full bg-slate-800" />
<div className="flex gap-1.5">
<ClockIcon className="h-4 w-4 pt-0.5 text-slate-100" />
<Paragraph variant="small">
<TextLink href="https://github.com/triggerdotdev/examples/tree/main/delays">
Delays
</TextLink>{" "}
- Using delays inside Jobs
</Paragraph>
</div>
<div className="flex gap-1.5">
<CalendarDaysIcon className="h-4 w-4 pt-0.5 text-slate-100" />
<Paragraph variant="small">
<TextLink href="https://github.com/triggerdotdev/examples/tree/main/scheduled">
Scheduled
</TextLink>{" "}
- Interval and cron scheduled Jobs
</Paragraph>
</div>
<div className="flex gap-1.5">
<GitHubLightIcon className="ml-0.5 h-4 w-4 pt-0.5" />
<Paragraph variant="small">
<TextLink href="https://github.com/triggerdotdev/examples/tree/main/github">
GitHub
</TextLink>{" "}
- When a new GitHub issue is opened it adds a Bug label to it.
</Paragraph>
</div>
<div className="flex gap-1.5">
<OpenAILightIcon className="ml-0.5 h-4 w-4 pt-0.5" />
<Paragraph variant="small">
<TextLink href="https://github.com/triggerdotdev/examples/tree/main/openai">
OpenAI
</TextLink>{" "}
- Generate images and jokes from a prompt
</Paragraph>
</div>
<div className="flex gap-1.5">
<ResendIcon className="ml-0.5 h-4 w-4 pt-0.5" />
<Paragraph variant="small">
<TextLink href="https://github.com/triggerdotdev/examples/tree/main/resend">
Resend
</TextLink>{" "}
- Sends an email by submitting a form in the Next.js app
</Paragraph>
</div>{" "}
<div className="flex gap-1.5">
<SlackIcon className="ml-0.5 h-4 w-4 pt-0.5" />
<Paragraph variant="small">
<TextLink href="https://github.com/triggerdotdev/examples/tree/main/slack">
Slack
</TextLink>{" "}
- Sends a Slack message when an event is received
</Paragraph>
</div>
</div>
);
}
function ExampleJobs() {
return (
<>
<Header2 spacing>Video walk-through</Header2>
<Paragraph spacing variant="small">
Watch Matt, CEO of Trigger.dev create a GitHub issue reminder in Slack using Trigger.dev.
(10 mins)
</Paragraph>
<iframe
src="https://www.youtube.com/embed/uocBQt2HeQo?&showinfo=0&rel=0&modestbranding=1"
title="Trigger.dev explainer video"
width="400"
height="250"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
allowFullScreen
className="mb-4 w-full border-b border-slate-800"
/>
<Header2 spacing>How to create a Job</Header2>
<Paragraph variant="small" spacing>
Our docs are a great way to learn how to create Jobs with each type of Trigger, from
webhooks, to delays, to triggering Jobs on a schedule.{" "}
</Paragraph>
<a
href="https://trigger.dev/docs/documentation/guides/create-a-job"
className="mb-4 flex w-full items-center rounded border-b border-slate-800 py-2 transition hover:border-transparent hover:bg-slate-800"
>
<NamedIcon name={"external-link"} className={iconStyles} />
<Paragraph variant="small" className="font-semibold text-bright">
How to create a Job
</Paragraph>
</a>
<Header2 spacing>Check out some example Jobs in code</Header2>
<Paragraph spacing variant="small">
If you're looking for inspiration for your next Job, check out our{" "}
<TextLink href="https://github.com/triggerdotdev/examples">examples repo</TextLink>. Or jump
straight into an example repo from the list below:
</Paragraph>
<div className="flex w-full flex-col">
{examples.map((example) => (
<a
href={example.codeLink}
key={example.title}
className="flex w-full items-center rounded border-b border-slate-800 py-2 transition hover:border-transparent hover:bg-slate-800"
>
{example.icon}
<Paragraph variant="small">
<span className="font-semibold text-bright">{example.title}</span> -{" "}
{example.description}
</Paragraph>
</a>
))}
</div>
</>
);
}
const iconStyles = "h-7 w-7 mr-2 pl-2 min-w-[28px]";
const examples = [
{
icon: <NamedIcon name={"clock"} className={iconStyles} />,
title: "Basic delay",
description: "Logs a message to the console, waits 5 minutes, and then logs another message.",
codeLink: "https://github.com/triggerdotdev/examples/blob/main/delays/src/jobs/delayJob.ts",
},
{
icon: <NamedIcon name="calendar" className={iconStyles} />,
title: "Basic interval",
description: "This Job runs every 60 seconds, starting 60 seconds after it is first indexed.",
codeLink: "https://github.com/triggerdotdev/examples/blob/main/scheduled/src/jobs/interval.ts",
},
{
icon: <NamedIcon name="calendar" className={iconStyles} />,
title: "Cron scheduled interval",
description: "A scheduled Job which runs at 2:30pm every Monday.",
codeLink:
"https://github.com/triggerdotdev/examples/blob/main/scheduled/src/jobs/cronScheduled.ts",
},
{
icon: <NamedIcon name="openai" className={iconStyles} />,
title: "OpenAI text summarizer",
description:
"Summarizes a block of text, pulling out the most unique / helpful points using OpenAI.",
codeLink:
"https://github.com/triggerdotdev/examples/blob/main/openai-text-summarizer/src/jobs/textSummarizer.ts",
},
{
icon: <NamedIcon name="openai" className={iconStyles} />,
title: "Tell me a joke using OpenAI",
description: "Generates a random joke using OpenAI GPT 3.5.",
codeLink: "https://github.com/triggerdotdev/examples/blob/main/openai/src/jobs/tellMeAJoke.ts",
},
{
icon: <NamedIcon name="openai" className={iconStyles} />,
title: "Generate a random image using OpenAI",
description: "Generates a random image of a hedgehog using OpenAI DALL-E.",
codeLink:
"https://github.com/triggerdotdev/examples/blob/main/openai/src/jobs/generateHedgehogImages.ts",
},
{
icon: <NamedIcon name="resend" className={iconStyles} />,
title: "Send an email using Resend",
description: "Send a basic email using Resend.",
codeLink:
"https://github.com/triggerdotdev/examples/blob/main/resend/src/jobs/resendBasicEmail.ts",
},
{
icon: <NamedIcon name="github" className={iconStyles} />,
title: "GitHub issue reminder",
description: "Sends a Slack message if a GitHub issue is left for 24h.",
codeLink:
"https://github.com/triggerdotdev/examples/blob/main/github-issue-reminder/jobs/githubIssue.ts",
},
{
icon: <NamedIcon name="github" className={iconStyles} />,
title: "Github new star alert in Slack",
description: "When a repo is starred, a message is sent to a Slack.",
codeLink:
"https://github.com/triggerdotdev/examples/blob/main/github/src/jobs/newStarToSlack.ts",
},
{
icon: <NamedIcon name="github" className={iconStyles} />,
title: "Add a custom label to a GitHub issue",
description: "When a new GitHub issue is opened it adds a “Bug” label to it.",
codeLink:
"https://github.com/triggerdotdev/examples/blob/main/github/src/jobs/onIssueOpened.ts",
},
{
icon: <NamedIcon name="github" className={iconStyles} />,
title: "GitHub new star alert",
description: "When a repo is starred a message is logged with the new Stargazers count.",
codeLink: "https://github.com/triggerdotdev/examples/blob/main/github/src/jobs/newStarAlert.ts",
},
{
icon: <NamedIcon name="slack" className={iconStyles} />,
title: "Send a Slack message",
description: "Sends a Slack message to a specific channel when an event is received.",
codeLink:
"https://github.com/triggerdotdev/examples/blob/main/slack/src/jobs/sendSlackMessage.ts",
},
];
+1 -1
View File
@@ -1,4 +1,4 @@
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@100;200;300;400;500;600;700;800;900&family=Roboto+Mono:wght@300;400;500;600;700&display=swap");
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@100;200;300;400;500;600;700;800;900&family=Roboto+Mono:wght@300;400;500;600;700&display=swap&family=Poppins:wght@600&display=swap");
@tailwind base;
@tailwind components;
+1
View File
@@ -76,6 +76,7 @@ module.exports = {
fontFamily: {
sans: ["Inter", "sans-serif"],
mono: ["Roboto Mono", "monospace"],
title: ["Poppins", "sans-serif"]
},
fontSize: {
xxs: [