Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.
TypeScript accessibilityalternativecloudflarecloudflare-workersdesignfreefrontendopen-sourceradix-uireactremixweb-developmentwebflowwebsite-builderwebsite-developmentwebsiteswebstudio
feat: Add pro badge (#2680)
Ivan Starkovff17a2348390
diff --git a/apps/builder/app/dashboard/header.tsx b/apps/builder/app/dashboard/header.tsxindex f5333025fb..287a01eebf 100644--- a/apps/builder/app/dashboard/header.tsx+++ b/apps/builder/app/dashboard/header.tsx@@ -1,8 +1,13 @@-import { ChevronDownIcon, WebstudioIcon } from "@webstudio-is/icons";+import {+ ChevronDownIcon,+ UploadIcon,+ WebstudioIcon,+} from "@webstudio-is/icons";import {DropdownMenu,DropdownMenuTrigger,DropdownMenuContent,+ DropdownMenuPortal,DropdownMenuItem,DropdownMenuLabel,Flex,@@ -11,8 +16,8 @@ import {rawTheme,theme,Button,- Box,Text,+ styled,} from "@webstudio-is/design-system";import { useNavigate } from "@remix-run/react";import { logoutPath, userPlanSubscriptionPath } from "~/shared/router-utils";@@ -30,6 +35,22 @@ const getAvatarLetter = (title?: string) => {return (title || "X").charAt(0).toLocaleUpperCase();};+export const ProBadge = styled(Text, {+ display: "inline-flex",+ borderRadius: theme.borderRadius[2],+ px: theme.spacing[3],+ py: theme.spacing[1],+ height: theme.spacing[9],+ color: theme.colors.foregroundContrastMain,+ alignItems: "center",+ maxWidth: "100%",+ whiteSpace: "nowrap",+ overflow: "hidden",+ // @tood doesn't work in tooltips, needs a workaround+ textOverflow: "ellipsis",+ background: theme.colors.backgroundStyleSourceNeutral,+});+const Menu = ({user,userPlanFeatures,@@ -44,6 +65,13 @@ const Menu = ({<DropdownMenuTrigger asChild><Button color="ghost" aria-label="Menu Button" css={{ height: "100%" }}><Flex gap="1" align="center">+ {userPlanFeatures.hasProPlan && (+ <>+ <ProBadge>Pro</ProBadge>+ <div />+ </>+ )}+<Avatarsrc={user?.image || undefined}fallback={getAvatarLetter(title)}@@ -58,20 +86,35 @@ const Menu = ({</Flex></Button></DropdownMenuTrigger>- <DropdownMenuContent align="end">- <DropdownMenuLabel>{title}</DropdownMenuLabel>- <DropdownMenuItem onSelect={() => navigate(logoutPath())}>- Logout- </DropdownMenuItem>-- {userPlanFeatures.hasSubscription && (- <DropdownMenuItem- onSelect={() => navigate(userPlanSubscriptionPath())}- >- Subscriptions+ <DropdownMenuPortal>+ <DropdownMenuContent align="end">+ <DropdownMenuLabel>{title}</DropdownMenuLabel>+ <DropdownMenuItem onSelect={() => navigate(logoutPath())}>+ Logout</DropdownMenuItem>- )}- </DropdownMenuContent>++ {userPlanFeatures.hasSubscription && (+ <DropdownMenuItem+ onSelect={() => navigate(userPlanSubscriptionPath())}+ >+ Manage Subscription+ </DropdownMenuItem>+ )}+ {userPlanFeatures.hasProPlan === false && (+ <DropdownMenuItem+ onSelect={() => {+ window.location.assign("https://webstudio.is/pricing");+ }}+ css={{+ gap: theme.spacing[3],+ }}+ >+ <UploadIcon />+ <div>Upgrade to Pro</div>+ </DropdownMenuItem>+ )}+ </DropdownMenuContent>+ </DropdownMenuPortal></DropdownMenu>);};@@ -91,34 +134,8 @@ export const Header = ({className={containerStyle()}><WebstudioIcon width={30} height={23} />- <Flex gap="1" align="center" css={{ position: "relative" }}>- <Menu user={user} userPlanFeatures={userPlanFeatures} />- {userPlanFeatures.hasProPlan && (- <Flex- css={{- position: "absolute",- left: theme.spacing[6],- top: -4,- width: 0,- }}- align={"center"}- justify={"center"}- >- <Box- css={{- backgroundColor: theme.colors.primary,- minWidth: "fit-content",- py: theme.spacing[1],- px: theme.spacing[3],- borderRadius: theme.borderRadius[3],- color: theme.colors.white,- }}- >- <Text variant={"small"}>Pro</Text>- </Box>- </Flex>- )}- </Flex>++ <Menu user={user} userPlanFeatures={userPlanFeatures} /></Flex>);};diff --git a/packages/design-system/src/components/avatar.tsx b/packages/design-system/src/components/avatar.tsxindex ba954fd4f5..f88c03e2c6 100644--- a/packages/design-system/src/components/avatar.tsx+++ b/packages/design-system/src/components/avatar.tsx@@ -4,11 +4,9 @@ import {type ReactNode,forwardRef,} from "react";-import { styled, type VariantProps, type CSS } from "../stitches.config";+import { theme, styled, type VariantProps, type CSS } from "../stitches.config";import * as AvatarPrimitive from "@radix-ui/react-avatar";import { Box } from "./box";-import { Status } from "./status";-import { theme } from "../stitches.config";const StyledAvatar = styled(AvatarPrimitive.Root, {alignItems: "center",@@ -28,168 +26,10 @@ const StyledAvatar = styled(AvatarPrimitive.Root, {padding: "0",fontWeight: "500",color: theme.colors.hiContrast,-- "&::before": {- content: '""',- position: "absolute",- top: 0,- right: 0,- bottom: 0,- left: 0,- borderRadius: "inherit",- boxShadow: "inset 0px 0px 1px rgba(0, 0, 0, 0.12)",- },-- variants: {- size: {- "1": {- width: theme.spacing[9],- height: theme.spacing[9],- },- "2": {- width: theme.spacing[12],- height: theme.spacing[12],- },- "3": {- width: theme.spacing[13],- height: theme.spacing[13],- },- "4": {- width: theme.spacing[17],- height: theme.spacing[17],- },- "5": {- width: theme.spacing[19],- height: theme.spacing[19],- },- "6": {- width: theme.spacing[20],- height: theme.spacing[20],- },- },- variant: {- hiContrast: {- backgroundColor: theme.colors.hiContrast,- color: theme.colors.loContrast,- },- gray: {- backgroundColor: theme.colors.slate6,- },- tomato: {- backgroundColor: theme.colors.tomato5,- },- red: {- backgroundColor: theme.colors.red5,- },- crimson: {- backgroundColor: theme.colors.crimson5,- },- pink: {- backgroundColor: theme.colors.pink5,- },- plum: {- backgroundColor: theme.colors.plum5,- },- purple: {- backgroundColor: theme.colors.purple5,- },- violet: {- backgroundColor: theme.colors.violet5,- },- indigo: {- backgroundColor: theme.colors.indigo5,- },- blue: {- backgroundColor: theme.colors.blue5,- },- cyan: {- backgroundColor: theme.colors.cyan5,- },- teal: {- backgroundColor: theme.colors.teal5,- },- green: {- backgroundColor: theme.colors.green5,- },- grass: {- backgroundColor: theme.colors.grass5,- },- brown: {- backgroundColor: theme.colors.brown5,- },- bronze: {- backgroundColor: theme.colors.bronze5,- },- gold: {- backgroundColor: theme.colors.gold5,- },- sky: {- backgroundColor: theme.colors.sky5,- },- mint: {- backgroundColor: theme.colors.mint5,- },- lime: {- backgroundColor: theme.colors.lime5,- },- yellow: {- backgroundColor: theme.colors.yellow5,- },- amber: {- backgroundColor: theme.colors.amber5,- },- orange: {- backgroundColor: theme.colors.orange5,- },- },- shape: {- square: {- borderRadius: theme.borderRadius[6],- },- circle: {- borderRadius: "50%",- },- },- inactive: {- true: {- opacity: ".3",- },- },- interactive: {- true: {- "&::after": {- content: '""',- position: "absolute",- top: "0",- right: "0",- bottom: "0",- left: "0",- backgroundColor: "rgba(0,0,0,.08)",- opacity: "0",- pointerEvents: "none",- transition: "opacity 25ms linear",- },- "@hover": {- "&:hover": {- "&::after": {- opacity: "1",- },- },- },- '&[data-state="open"]': {- "&::after": {- backgroundColor: "rgba(0,0,0,.12)",- opacity: "1",- },- },- },- },- },- defaultVariants: {- size: "2",- variant: "gray",- shape: "circle",- },+ width: 22,+ height: 22,+ backgroundColor: theme.colors.foregroundSubtle,+ borderRadius: "50%",});const StyledAvatarImage = styled(AvatarPrimitive.Image, {@@ -204,50 +44,10 @@ const StyledAvatarImage = styled(AvatarPrimitive.Image, {const StyledAvatarFallback = styled(AvatarPrimitive.Fallback, {textTransform: "uppercase",borderRadius: "50%",- variants: {- size: {- "1": {- fontSize: theme.deprecatedFontSize[2],- lineHeight: theme.deprecatedLineHeight[3],- },- "2": {- fontSize: theme.deprecatedFontSize[4],- },- "3": {- fontSize: theme.deprecatedFontSize[6],- },- "4": {- fontSize: theme.deprecatedFontSize[7],- },- "5": {- fontSize: theme.deprecatedFontSize[8],- },- "6": {- fontSize: theme.deprecatedFontSize[9],- },- },- },- defaultVariants: {- size: "2",- },-});--export const AvatarNestedItem = styled("div", {- boxShadow: `0 0 0 2px ${theme.colors.loContrast}`,- borderRadius: "50%",+ fontSize: theme.deprecatedFontSize[4],+ color: theme.colors.white,});-export const AvatarGroup = styled("div", {- display: "flex",- flexDirection: "row-reverse",- [`& ${AvatarNestedItem}:nth-child(n+2)`]: {- marginRight: `-${theme.spacing[3]}`,- },-});--type StatusVariants = ComponentProps<typeof Status>;-type StatusColors = Pick<StatusVariants, "variant">;-type AvatarVariants = VariantProps<typeof StyledAvatar>;type AvatarPrimitiveProps = ComponentProps<typeof AvatarPrimitive.Root>;type AvatarOwnProps = AvatarPrimitiveProps &@@ -256,62 +56,27 @@ type AvatarOwnProps = AvatarPrimitiveProps &alt?: string;src?: string;fallback?: ReactNode;- status?: StatusColors["variant"];};export const Avatar = forwardRef<ElementRef<typeof StyledAvatar>,AvatarOwnProps->(- (- { alt, src, fallback, size, variant, shape, css, status, ...props },- forwardedRef- ) => {- return (- <Box- css={{- ...css,- position: "relative",- height: "fit-content",- width: "fit-content",- }}- >- <StyledAvatar- {...props}- ref={forwardedRef}- size={size}- variant={variant}- shape={shape}- >- <StyledAvatarImage alt={alt} src={src} />- <StyledAvatarFallback size={size}>{fallback}</StyledAvatarFallback>- </StyledAvatar>- {status && (- <Box- css={{- position: "absolute",- bottom: "0",- right: "0",- boxShadow: `0 0 0 3px ${theme.colors.loContrast}`,- borderRadius: theme.borderRadius.round,- mr: `-${theme.spacing[2]}`,- mb: `-${theme.spacing[2]}`,- }}- >- <Status- size={- (typeof size === "number" && size > 2) ||- (typeof size === "string" && Number.parseInt(size, 10) > 2)- ? "2"- : "1"- }- variant={status}- />- </Box>- )}- </Box>- );- }-);+>(({ alt, src, fallback, css, ...props }, forwardedRef) => {+ return (+ <Box+ css={{+ ...css,+ position: "relative",+ height: "fit-content",+ width: "fit-content",+ }}+ >+ <StyledAvatar {...props} ref={forwardedRef}>+ <StyledAvatarImage alt={alt} src={src} />+ <StyledAvatarFallback>{fallback}</StyledAvatarFallback>+ </StyledAvatar>+ </Box>+ );+});Avatar.displayName = "Avatar";diff --git a/packages/icons/icons/upload.svg b/packages/icons/icons/upload.svgnew file mode 100644index 0000000000..f6e515c03d--- /dev/null+++ b/packages/icons/icons/upload.svg@@ -0,0 +1,4 @@+<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="currentColor">+ <path fill-rule="evenodd" clip-rule="evenodd" d="M8.0001 2.6501C5.04537 2.6501 2.6501 5.04537 2.6501 8.0001C2.6501 10.9548 5.04537 13.3501 8.0001 13.3501C10.9548 13.3501 13.3501 10.9548 13.3501 8.0001C13.3501 5.04537 10.9548 2.6501 8.0001 2.6501ZM1.3501 8.0001C1.3501 4.3274 4.3274 1.3501 8.0001 1.3501C11.6728 1.3501 14.6501 4.3274 14.6501 8.0001C14.6501 11.6728 11.6728 14.6501 8.0001 14.6501C4.3274 14.6501 1.3501 11.6728 1.3501 8.0001Z" />+ <path fill-rule="evenodd" clip-rule="evenodd" d="M7.5405 4.87365C7.79434 4.61981 8.2059 4.61981 8.45974 4.87365L11.1264 7.54032C11.3802 7.79416 11.3802 8.20571 11.1264 8.45955C10.8726 8.7134 10.461 8.7134 10.2072 8.45955L8.65012 6.90251V10.6666C8.65012 11.0256 8.3591 11.3166 8.00012 11.3166C7.64113 11.3166 7.35012 11.0256 7.35012 10.6666V6.90251L5.79307 8.45955C5.53923 8.7134 5.12767 8.7134 4.87383 8.45955C4.61999 8.20571 4.61999 7.79416 4.87383 7.54032L7.5405 4.87365Z"/>+</svg>\ No newline at end of filediff --git a/packages/icons/src/__generated__/index.ts b/packages/icons/src/__generated__/index.tsindex 43b83c1c64..98687c9b5e 100644--- a/packages/icons/src/__generated__/index.ts+++ b/packages/icons/src/__generated__/index.ts@@ -160,6 +160,7 @@ export * from "./text";export * from "./tooltip";export * from "./trigger";export * from "./twitter";+export * from "./upload";export * from "./video";export * from "./viewport";export * from "./vimeo";diff --git a/packages/icons/src/__generated__/svg/index.ts b/packages/icons/src/__generated__/svg/index.tsindex 921da7e197..72a64615cb 100644--- a/packages/icons/src/__generated__/svg/index.ts+++ b/packages/icons/src/__generated__/svg/index.ts@@ -160,6 +160,7 @@ export { TextIcon } from "./text";export { TooltipIcon } from "./tooltip";export { TriggerIcon } from "./trigger";export { TwitterIcon } from "./twitter";+export { UploadIcon } from "./upload";export { VideoIcon } from "./video";export { ViewportIcon } from "./viewport";export { VimeoIcon } from "./vimeo";diff --git a/packages/icons/src/__generated__/svg/upload.ts b/packages/icons/src/__generated__/svg/upload.tsnew file mode 100644index 0000000000..bbe7f5632f--- /dev/null+++ b/packages/icons/src/__generated__/svg/upload.ts@@ -0,0 +1 @@+export const UploadIcon = `<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 16 16" width="100%" height="100%" style="display: block;"><path fill-rule="evenodd" d="M8 2.65a5.35 5.35 0 1 0 0 10.7 5.35 5.35 0 0 0 0-10.7ZM1.35 8a6.65 6.65 0 1 1 13.3 0 6.65 6.65 0 0 1-13.3 0Z" clip-rule="evenodd"/><path fill-rule="evenodd" d="M7.54 4.874a.65.65 0 0 1 .92 0l2.666 2.666a.65.65 0 0 1-.919.92L8.65 6.903v3.764a.65.65 0 1 1-1.3 0V6.903L5.793 8.46a.65.65 0 1 1-.92-.92L7.54 4.874Z" clip-rule="evenodd"/></svg>`;diff --git a/packages/icons/src/__generated__/upload.tsx b/packages/icons/src/__generated__/upload.tsxnew file mode 100644index 0000000000..2da8828375--- /dev/null+++ b/packages/icons/src/__generated__/upload.tsx@@ -0,0 +1,15 @@+// Generated from icons/upload.svg++import { forwardRef } from "react";+import type { IconProps } from "../types";++// prettier-ignore+export const UploadIcon = forwardRef<SVGSVGElement, IconProps>(+ ({ color = "currentColor", size = 16, ...props }, forwardedRef) => {+ return (+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width={size} height={size} fill={color} {...props} ref={forwardedRef}><path fillRule="evenodd" d="M8 2.65a5.35 5.35 0 1 0 0 10.7 5.35 5.35 0 0 0 0-10.7ZM1.35 8a6.65 6.65 0 1 1 13.3 0 6.65 6.65 0 0 1-13.3 0Z" clipRule="evenodd" /><path fillRule="evenodd" d="M7.54 4.874a.65.65 0 0 1 .92 0l2.666 2.666a.65.65 0 0 1-.919.92L8.65 6.903v3.764a.65.65 0 1 1-1.3 0V6.903L5.793 8.46a.65.65 0 1 1-.92-.92L7.54 4.874Z" clipRule="evenodd" /></svg>+ );+ }+);++UploadIcon.displayName = "UploadIcon";diff --git a/packages/icons/src/index.ts b/packages/icons/src/index.tsindex e0ec25f624..294042b5af 100644--- a/packages/icons/src/index.ts+++ b/packages/icons/src/index.ts@@ -12,7 +12,6 @@ export * from "./justify-items-start";export * from "./cloud";export * from "./trash";export * from "./size";-export * from "./upload";export * from "./gear";export * from "./new-page";export * from "./new-folder";diff --git a/packages/icons/src/upload.tsx b/packages/icons/src/upload.tsxdeleted file mode 100644index 6887d851cf..0000000000--- a/packages/icons/src/upload.tsx+++ /dev/null@@ -1,24 +0,0 @@-import * as React from "react";-import type { IconProps } from "./types";--export const UploadIcon = React.forwardRef<SVGSVGElement, IconProps>(- ({ color = "currentColor", ...props }, forwardedRef) => {- return (- <svg- width="16"- height="16"- viewBox="0 0 16 16"- xmlns="http://www.w3.org/2000/svg"- {...props}- ref={forwardedRef}- >- <path- d="M9.758 8.442a.625.625 0 10.884-.884l-.884.884zM8 5.8l.442-.442a.625.625 0 00-.884 0L8 5.8zM5.358 7.558a.625.625 0 10.884.884l-.884-.884zM7.375 10.2a.625.625 0 101.25 0h-1.25zm5.5-2.2A4.875 4.875 0 018 12.875v1.25A6.125 6.125 0 0014.125 8h-1.25zM8 12.875A4.875 4.875 0 013.125 8h-1.25A6.125 6.125 0 008 14.125v-1.25zM3.125 8A4.875 4.875 0 018 3.125v-1.25A6.125 6.125 0 001.875 8h1.25zM8 3.125A4.875 4.875 0 0112.875 8h1.25A6.125 6.125 0 008 1.875v1.25zm2.642 4.433l-2.2-2.2-.884.884 2.2 2.2.884-.884zm-3.084-2.2l-2.2 2.2.884.884 2.2-2.2-.884-.884zM8.625 10.2V5.8h-1.25v4.4h1.25z"- fill={color}- />- </svg>- );- }-);--UploadIcon.displayName = "UploadIcon";