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

Misc - Improved Callout Card #498

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions app/public/assets/icons/info-green.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 6 additions & 3 deletions app/src/components/application/5/ApplicationProjectImpact.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,12 @@ const ApplicationProjectImpactForm = ({
{!!!projects?.length && (
<Callout
type="error"
text="You haven't added or joined any projects"
linkText="View projects"
linkHref="/dashboard"
leftAlignedContent="You haven't added or joined any projects"
rightAlignedContent={
<ExternalLink href="/dashboard">View projects</ExternalLink>
}
leftHandSize="sm"
rightHandSize="sm"
/>
)}

Expand Down
4 changes: 2 additions & 2 deletions app/src/components/application/5/ProjectImpactForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,9 @@ const ProjectImpactForm = ({
focus on communicating your project’s impact.
</p>
<Callout
className="!text-sm"
type="info"
text="Promises of future deliverables or impact are not allowed."
leftAlignedContent="Promises of future deliverables or impact are not allowed."
leftHandSize="sm"
/>

{categories
Expand Down
9 changes: 6 additions & 3 deletions app/src/components/application/6/ApplicationProjectImpact.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,12 @@ const ApplicationProjectImpactForm = ({
{!!!projects?.length && (
<Callout
type="error"
text="You haven't added or joined any projects"
linkText="View projects"
linkHref="/dashboard"
leftAlignedContent="You haven't added or joined any projects"
rightAlignedContent={
<ExternalLink href={"/dashboard"}>View projects</ExternalLink>
}
leftHandSize="sm"
rightHandSize="sm"
/>
)}

Expand Down
4 changes: 2 additions & 2 deletions app/src/components/application/6/ProjectImpactForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,9 @@ const ProjectImpactForm = ({
Instead, focus on communicating your project&apos;s impact.
</p>
<Callout
className="!text-sm"
type="info"
text="Promises of future deliverables or impact are not allowed."
leftAlignedContent="Promises of future deliverables or impact are not allowed."
leftHandSize="sm"
/>

{(() => {
Expand Down
9 changes: 6 additions & 3 deletions app/src/components/application/FundingApplication.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,12 @@ export const FundingApplication = ({
{projects.length === 0 ? (
<Callout
type="error"
text="You haven't created or joined any projects"
linkText="View projects"
linkHref="/dashboard"
leftAlignedContent={"You haven't created or joined any projects"}
rightAlignedContent={
<ExternalLink href={"/dashboard"}>View projects</ExternalLink>
}
leftHandSize="sm"
rightHandSize="sm"
/>
) : (
<div className="flex flex-col gap-y-2">
Expand Down
121 changes: 82 additions & 39 deletions app/src/components/common/Callout.tsx
Original file line number Diff line number Diff line change
@@ -1,59 +1,102 @@
import Image from "next/image"
import Link from "next/link"
import { memo } from "react"
import React, { memo, ReactNode } from "react"

import { cn } from "@/lib/utils"
type CalloutProperties = {
backgroundColor: string
textColor: string
icon: string
}

import ExternalLink from "../ExternalLink"
const types = {
info: {
backgroundColor: "bg-accent",
textColor: "text-accent-foreground",
icon: "/assets/icons/info-blue.svg",
} as CalloutProperties,
error: {
backgroundColor: "bg-red-200",
textColor: "text-destructive-foreground",
icon: "/assets/icons/info-red.svg",
} as CalloutProperties,
success: {
backgroundColor: "bg-green-100",
textColor: "text-green-800",
icon: "/assets/icons/info-green.svg",
} as CalloutProperties,

optimism: {
backgroundColor: "bg-optimismRed",
textColor: "text-white",
} as CalloutProperties,

optimismBright: {
backgroundColor: "bg-red-100",
textColor: "text-red-600",
} as CalloutProperties,
}

const textSizes = {
xs: "text-xs",
sm: "text-sm",
base: "",
lg: "text-lg",
xl: "text-xl",
xxl: "text-2xl",
}

const iconSizes = {
xs: 8,
sm: 12,
base: 16.5,
lg: 20,
xl: 24,
xxl: 28,
}

export const Callout = memo(function Callout({
className,
type,
text,
linkText,
linkHref,
showIcon = true,
leftAlignedContent,
rightAlignedContent,
leftHandSize = "base",
rightHandSize = "base",
iconSize = "base",
}: {
className?: string
type: "info" | "error"
text: string
linkText?: string
linkHref?: string
type?: keyof typeof types
showIcon?: boolean
leftAlignedContent?: ReactNode
rightAlignedContent?: ReactNode
leftHandSize?: keyof typeof textSizes
rightHandSize?: keyof typeof textSizes
iconSize?: keyof typeof iconSizes
}) {
return (
<div
className={cn(
"flex items-center rounded-md py-2.5 px-3 w-full",
type === "error"
? "bg-red-200 text-destructive-foreground"
: "bg-accent text-accent-foreground",
className,
)}
className={`flex items-center rounded-md py-2.5 px-3 w-full ${
type && types[type].backgroundColor
} ${type && types[type].textColor}`}
>
{showIcon && (
{showIcon && type && types[type].icon && (
<Image
alt="Info"
src={
type === "error"
? "/assets/icons/info-red.svg"
: "/assets/icons/info-blue.svg"
}
width={16.5}
height={16.5}
src={types[type].icon}
width={iconSizes[iconSize]}
height={iconSizes[iconSize]}
/>
)}
<p className={cn("mr-5 text-sm font-medium", showIcon && "ml-2")}>
{text}
</p>
{linkText && (
<ExternalLink
href={linkHref ?? "#"}
className="ml-auto text-sm font-medium shrink-0"
>
{linkText}
</ExternalLink>
)}

<div
className={`mr-5 font-medium ${textSizes[leftHandSize]} ${
showIcon && "ml-2"
}`}
>
{leftAlignedContent}
</div>
<div
className={`ml-auto shrink-0 font-medium ${textSizes[rightHandSize]}`}
>
{rightAlignedContent}
</div>
</div>
)
})
5 changes: 4 additions & 1 deletion app/src/components/projects/grants/GrantsForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import {
PRICING_MODEL_TYPES,
PRICINGMODELTYPES,
} from "./schema"
import ExternalLink from "@/components/ExternalLink"

function toFormValues(
project: ProjectWithDetails,
Expand Down Expand Up @@ -332,9 +333,11 @@ export const GrantsForm = ({ project }: { project: ProjectWithDetails }) => {
Describe your pricing model, and list any Optimism Grants, Optimism
Retro Funding, or investment your project has received.
</p>

<Callout
type="info"
text="Failure to report will result in disqualification from Retro Funding"
leftAlignedContent="Failure to report will result in disqualification from Retro Funding"
leftHandSize="sm"
/>
<div className="flex flex-col gap-y-2">
<p className="text-sm font-medium text-foreground">
Expand Down
3 changes: 2 additions & 1 deletion app/src/components/projects/teams/TeamForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ export default function AddTeamDetailsForm({
</p>
<Callout
type="info"
text="Access to an admin account is needed to claim Retro Funding rewards"
leftAlignedContent="Access to an admin account is needed to claim Retro Funding rewards"
leftHandSize="sm"
/>
</div>
<div className="flex flex-col gap-1.5">
Expand Down
3 changes: 2 additions & 1 deletion app/src/components/rewards/ClaimForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -470,10 +470,11 @@ function ClaimFormSuperfluid({
<Callout
type="info"
showIcon={false}
text={`You can start your token stream on or after ${format(
leftAlignedContent={`You can start your token stream on or after ${format(
reward.claim.tokenStreamClaimableAt,
"eeee, MMMM d",
)}`}
leftHandSize="sm"
/>
) : (
<MaybeLink
Expand Down